-
Notifications
You must be signed in to change notification settings - Fork 14k
Show packed field alignment in mir_transform_unaligned_packed_ref #147743
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
Conversation
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, and welcome to working on the compiler! Have a few comments, see below. Remember to squash once you're done.
Also, I see that you originally implemented the full message as discussed by the referenced issue, but then decided to do something simpler - could you edit your top-level comment to discuss why this wasn't done in the end? (see the review policy for why to put stuff in the PR message).
e314e04 to
4945197
Compare
This comment has been minimized.
This comment has been minimized.
4945197 to
077fc4e
Compare
|
Should be good now. The message still says "only x-byte aligned" because the alignment reported here should always be the minimum alignment, not the maximum. |
077fc4e to
5e6ea43
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me now, but since Ralf had input, I'll let him have the final say.
r? RalfJung
Feel free to r=me as well if you're happy with the message.
| | ^^^^ | ||
| | | ||
| = note: packed structs are only aligned by one byte, and many modern architectures penalize unaligned field accesses | ||
| = note: this struct is at most 1-byte aligned, but the type of this field may require higher alignment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we have a special case that drops the "at most" when the alignment is 1? It can't be less than 1, after all...
|
@rustbot author |
|
Reminder, once the PR becomes ready for a review, use |
5e6ea43 to
566a86b
Compare
|
This PR was rebased onto a different master commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
|
The job Click to see the possible cause of the failure (guessed by this bot) |
|
@rustbot ready |
|
CI is not happy. |
| LL | let brw = unsafe { &bar.foo1.0 }; | ||
| | ^^^^^^^^^^^ | ||
| | | ||
| = note: this struct is 1-byte aligned, but the type of this field may require higher alignment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When there are multiple projections it is not clear which one it means... further improvements are possible here, e.g. by saying "the struct Name is 1-byte aligned". But that can be left to a future PR.
…Jung Show packed field alignment in mir_transform_unaligned_packed_ref Fixes rust-lang#147528 I left the expected padding for the field out of the error message so the message would be the same on all platforms. It also isn't always possible to know the expected alignment, so this makes the message simpler.
…Jung Show packed field alignment in mir_transform_unaligned_packed_ref Fixes rust-lang#147528 I left the expected padding for the field out of the error message so the message would be the same on all platforms. It also isn't always possible to know the expected alignment, so this makes the message simpler.
…Jung Show packed field alignment in mir_transform_unaligned_packed_ref Fixes rust-lang#147528 I left the expected padding for the field out of the error message so the message would be the same on all platforms. It also isn't always possible to know the expected alignment, so this makes the message simpler.
Rollup of 22 pull requests Successful merges: - #128666 (Add `overflow_checks` intrinsic) - #146305 (Add correct suggestion for multi-references for self type in method) - #147179 ([DebugInfo] Fix container types failing to find template args) - #147743 (Show packed field alignment in mir_transform_unaligned_packed_ref) - #148079 (Rename `downcast_[ref|mut]_unchecked` -> `downcast_unchecked_[ref|mut]`) - #148084 (Optimize path components iteration on platforms that don't have prefixes) - #148126 (Fix rust stdlib build failing for VxWorks) - #148204 (Modify contributor email entries in .mailmap) - #148279 (rustc_builtin_macros: rename bench parameter to avoid collisions with user-defined function names) - #148333 (constify result unwrap unchecked) - #148539 (Add Allocator proxy impls for Box, Rc, and Arc) - #148601 (`invalid_atomic_ordering`: also lint `update` & `try_update`) - #148612 (Add note for identifier with attempted hygiene violation) - #148613 (Switch hexagon targets to rust-lld) - #148619 (Enable std locking functions on AIX) - #148644 ([bootstrap] Make `--open` option work with `doc src/tools/error_index_generator`) - #148649 (don't completely reset `HeadUsages`) - #148673 (Remove a remnant of `dyn*` from the parser) - #148675 (Remove eslint-js from npm dependencies) - #148680 (Recover `[T: N]` as `[T; N]`) - #148688 (Remove unused argument `features` from `eval_config_entry`) - #148711 (Use the current lint note id when parsing `cfg!()`) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of #147743 - 21aslade:packed-diagnostic, r=RalfJung Show packed field alignment in mir_transform_unaligned_packed_ref Fixes #147528 I left the expected padding for the field out of the error message so the message would be the same on all platforms. It also isn't always possible to know the expected alignment, so this makes the message simpler.
Fixes #147528
I left the expected padding for the field out of the error message so the message would be the same on all platforms. It also isn't always possible to know the expected alignment, so this makes the message simpler.