-
Notifications
You must be signed in to change notification settings - Fork 13.8k
repr(transparent): do not consider repr(C) types to be 1-ZST #147185
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
base: master
Are you sure you want to change the base?
Conversation
rustbot has assigned @petrochenkov. Use |
@bors try |
This comment has been minimized.
This comment has been minimized.
The job Click to see the possible cause of the failure (guessed by this bot)
|
@craterbot check |
👌 Experiment ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more |
Context: rust-lang/unsafe-code-guidelines#552
This experiments with a suggestion by @RustyYato to stop considering repr(C) types as 1-ZST for the purpose of repr(transparent). If we go with rust-lang/rfcs#3845 (or another approach for fixing repr(C)), they will anyway not be ZST on all targets any more, so this removes a portability hazard. Furthermore, zero-sized repr(C) structs may have to be treated as non-ZST for the win64 ABI (at least that's what gcc/clang do), so allowing them to be ignored in repr(transparent) types is not entirely coherent.
Turns out we already have an FCW for repr(transparent), namely #78586. This extends that lint to also check for repr(C) -- without actually updating the wording so the errors you get make little sense for now. Before landing we need to decide if these should be the same lint or not and then adjust the wording accordingly. Note that some types are only rejected if we check for both non-exhaustive structs and repr(C) structs so it's not entierly clear how to disentangle this into separate lints.
The 2nd commit makes the lint a hard error so that we can crater this. I think crater will mostly find errors related to the non-exhaustive check, not the new repr(C) check, but as it's hard to disentangle them let's just see what happens before making the lint setup more complicated.