turn aligned-in-packed error into lint - #162160
Open
RalfJung wants to merge 1 commit into
Open
Conversation
Collaborator
|
r? @mu001999 rustbot has assigned @mu001999. Use Why was this reviewer chosen?The reviewer was selected based on:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #80926:
The aligned-in-packed check ignores the fact that generics exist, so it can trivially be bypassed. Acknowledge that by downgrading the hard error to a lint. The lint also only fires for
repr(C)types, because that's the only case where that is a problem: the type may not actually match what the C compiler for the target does, if that C compiler is MSVC. This is tied up with rust-lang/rfcs#3845 and the general tension aroundrepr(C)as a repr for predictable stable layout vs C compatibility. The error doesn't really help to make fixing the mess any easier though, so let's de-fang it.Also fixes rust-lang/rfcs#3060; see that issue for a usecase that's made unnecessarily hard by the status quo.
Three years ago, the t-lang vibes seem to have been "yes let's downgrade this to a lint, that's kind of what it already is anyway".
Questions for t-lang:
aligned_fields_in_packed.repr(C). For Rust types I see no reason at all to forbid this combination, we can just define whatever we want for the layout there and IMO the current behavior makes a lot of sense.Cc @rust-lang/opsem