Skip to content

Commit a9b2632

Browse files
committed
Use from_fn for non-Copy libc records
1 parent 92e2e20 commit a9b2632

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

cpp2rust/converter/converter.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3311,6 +3311,12 @@ std::string Converter::GetArrayDefaultAsString(clang::QualType qual_type) {
33113311
auto size_as_string = GetNumAsString(array_type->getSize());
33123312
auto element_type = array_type->getElementType();
33133313
auto element_type_as_string = GetDefaultAsString(element_type);
3314+
if (auto *rec = element_type->getAsRecordDecl()) {
3315+
if (ctx_.getSourceManager().isInSystemHeader(rec->getLocation())) {
3316+
return std::format("std::array::from_fn::<_, {}, _>(|_| {})",
3317+
size_as_string.c_str(), element_type_as_string);
3318+
}
3319+
}
33143320
return std::format("[{}; {}]", element_type_as_string,
33153321
size_as_string.c_str());
33163322
}

0 commit comments

Comments
 (0)