Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[lint request] unspecified_repr_Rust_transmute #3999

Open
gnzlbg opened this issue Apr 18, 2019 · 1 comment
Open

[lint request] unspecified_repr_Rust_transmute #3999

gnzlbg opened this issue Apr 18, 2019 · 1 comment
Labels
A-lint Area: New lints

Comments

@gnzlbg
Copy link
Contributor

gnzlbg commented Apr 18, 2019

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.

cc @eddyb

@matthiaskrgr matthiaskrgr added the A-lint Area: New lints label Apr 19, 2019
@oli-obk
Copy link
Contributor

oli-obk commented Apr 24, 2019

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)

bors added a commit that referenced this issue Feb 6, 2022
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`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lint Area: New lints
Projects
None yet
Development

No branches or pull requests

3 participants