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
There are some repr(Rust) types (structs, tuples, tuple structs, enums, unions, ...) for which we guarantee the layout (e.g. Option<NonZeroU32>), but we don't guarantee the layout of most repr(Rust) types, their layout is unspecified and allowed to change.
We should add a lint that warns about these, but I think we should try to at least compile a list of cases for which we do guarantee layout, and not warn on those.
Maybe we can "document" these in the ty::Layout so semverver can use the same logic for figuring out when changing a type is a breaking change (moving from guaranteed layout to not guaranteed layout on a public type is a breaking change)
Add lint `transmute_undefined_repr`
Partially implements #3999 and #546
This doesn't consider `enum`s at all right now as those are going to be a pain to deal with. This also allows `#[repr(Rust)]` structs with only one non-zero sized fields. I think those are technically undefined when transmuted.
changelog: Add lint `transmute_undefined_repr`
There are some
repr(Rust)
types (structs, tuples, tuple structs, enums, unions, ...) for which we guarantee the layout (e.g.Option<NonZeroU32>
), but we don't guarantee the layout of mostrepr(Rust)
types, their layout is unspecified and allowed to change.We should add a lint that warns about these, but I think we should try to at least compile a list of cases for which we do guarantee layout, and not warn on those.
cc @eddyb
The text was updated successfully, but these errors were encountered: