You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In Rust, a struct is Copyable if it explicitly derives or implements
Copy. All fields being Copy is not enough.
Add the `derives` attribute in the IR that lists all traits that a
mapped Rust type derives. For example rustls_slice_bytes, a struct with
Copyable fields, doesn't derive Copy. So `derives` contains only
Default.
User defined types and builtin types also have their `derives` field
filled. The entire PR is built around the following check:
```cpp
if (auto *rec = element_type->getAsRecordDecl()) {
if (!RecordDerivesCopy(rec)) {
return std::format("std::array::from_fn::<_, {}, _>(|_| {})",
size_as_string.c_str(), element_type_as_string);
}
}
```
Arrays of non-copyable types cannot be initialized with
`[non_copyable_default, N]`, they have to use the `std::array:from_fn`
format.
0 commit comments