turn aligned-in-packed error into lint - #162160
Conversation
|
r? @mu001999 rustbot has assigned @mu001999. Use Why was this reviewer chosen?The reviewer was selected based on:
|
|
@traviscross has proposed to merge this. The next step is review by the rest of the tagged team members: No concerns currently listed. Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up! cc @rust-lang/lang-advisors: FCP proposed for lang, please feel free to register concerns. |
|
@rfcbot reviewed |
|
🔔 This is now entering its final comment period, as per the review above. 🔔 |
|
@rfcbot reviewed I had to think about it, but I agree with not linting on For deny-by-default, it's a reasonable choice since this misbehaves on a Tier 1 platform. |
|
Given that if it's generic or if you get the alignment via, say, @rfcbot reviewed |
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