Skip to content

Conversation

@21aslade
Copy link
Contributor

@21aslade 21aslade commented Oct 15, 2025

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.

@rustbot
Copy link
Collaborator

rustbot commented Oct 15, 2025

Some changes occurred to MIR optimizations

cc @rust-lang/wg-mir-opt

Some changes occurred to the CTFE machinery

cc @RalfJung, @oli-obk, @lcnr

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Oct 15, 2025
@rustbot
Copy link
Collaborator

rustbot commented Oct 15, 2025

r? @madsmtm

rustbot has assigned @madsmtm.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rust-log-analyzer

This comment has been minimized.

@madsmtm madsmtm added A-diagnostics Area: Messages for errors, warnings, and lints A-repr-packed Area: the naughtiest repr labels Oct 16, 2025
Copy link
Contributor

@madsmtm madsmtm left a 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).

View changes since this review

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 16, 2025
@rustbot

This comment has been minimized.

@21aslade
Copy link
Contributor Author

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.
@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Oct 20, 2025
Copy link
Contributor

@madsmtm madsmtm left a 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.

View changes since this review

@rustbot rustbot assigned RalfJung and unassigned madsmtm Oct 24, 2025
| ^^^^
|
= 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
Copy link
Member

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...

@RalfJung
Copy link
Member

@rustbot author

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 30, 2025
@rustbot
Copy link
Collaborator

rustbot commented Oct 30, 2025

Reminder, once the PR becomes ready for a review, use @rustbot ready.

@rustbot
Copy link
Collaborator

rustbot commented Nov 7, 2025

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.

@rust-log-analyzer
Copy link
Collaborator

The job tidy failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)
spellchecking files
building external tool typos from package [email protected]
finished building tool typos
npm WARN deprecated [email protected]: < 24.10.2 is no longer supported
npm ERR! code 127
npm ERR! git dep preparation failed
npm ERR! command /node/bin/node /node/lib/node_modules/npm/bin/npm-cli.js install --force --cache=/home/user/.npm --prefer-offline=false --prefer-online=false --offline=false --no-progress --no-save --no-audit --include=dev --include=peer --include=optional --no-package-lock-only --no-dry-run
npm ERR! npm WARN using --force Recommended protections disabled.
npm ERR! npm WARN deprecated [email protected]: This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.
npm ERR! npm WARN deprecated [email protected]: Glob versions prior to v9 are no longer supported
npm ERR! npm WARN deprecated [email protected]: Glob versions prior to v9 are no longer supported
npm ERR! npm WARN deprecated [email protected]: This functionality has been moved to @npmcli/fs
npm ERR! npm WARN deprecated [email protected]: Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.
npm ERR! npm WARN deprecated [email protected]: This package is no longer supported. Please use @npmcli/package-json instead.
npm ERR! npm WARN deprecated [email protected]: This package is no longer supported.
npm ERR! npm ERR! code 127
npm ERR! npm ERR! path /home/user/.npm/_cacache/tmp/git-cloneXXXXXXg9iAQl/node_modules/rollup
npm ERR! npm ERR! command failed
npm ERR! npm ERR! command sh -c patch-package
npm ERR! npm ERR! sh: 1: patch-package: not found
npm ERR! 
npm ERR! npm ERR! A complete log of this run can be found in: /home/user/.npm/_logs/2025-11-07T21_04_16_242Z-debug-0.log

npm ERR! A complete log of this run can be found in: /home/user/.npm/_logs/2025-11-07T21_04_09_017Z-debug-0.log
npm install did not exit successfully
tidy [extra_checks]: IO error: npm install returned exit code exit status: 127
tidy [extra_checks]: FAIL
tidy: The following check failed: extra_checks
Command `/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-tools-bin/rust-tidy /checkout /checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo /checkout/obj/build 4 /node/bin/npm --extra-checks=py,cpp,js,spellcheck` failed with exit code 1
Created at: src/bootstrap/src/core/build_steps/tool.rs:1549:23
Executed at: src/bootstrap/src/core/build_steps/test.rs:1279:29

Command has failed. Rerun with -v to see more details.
Bootstrap failed while executing `test src/tools/tidy tidyselftest --extra-checks=py,cpp,js,spellcheck`
Build completed unsuccessfully in 0:02:59
  local time: Fri Nov  7 21:04:34 UTC 2025
  network time: Fri, 07 Nov 2025 21:04:34 GMT
##[error]Process completed with exit code 1.

@21aslade
Copy link
Contributor Author

21aslade commented Nov 7, 2025

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Nov 7, 2025
@RalfJung
Copy link
Member

RalfJung commented Nov 8, 2025

CI is not happy.
@rustbot author

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Nov 8, 2025
@RalfJung
Copy link
Member

RalfJung commented Nov 8, 2025

Ah, that was the npm network issue.
@rustbot ready
@bors r+

@rustbot rustbot removed the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Nov 8, 2025
@bors
Copy link
Collaborator

bors commented Nov 8, 2025

📌 Commit 566a86b has been approved by RalfJung

It is now in the queue for this repository.

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Nov 8, 2025
@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Nov 8, 2025
LL | let brw = unsafe { &bar.foo1.0 };
| ^^^^^^^^^^^
|
= note: this struct is 1-byte aligned, but the type of this field may require higher alignment
Copy link
Member

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.

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Nov 8, 2025
…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.
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Nov 8, 2025
…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.
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Nov 8, 2025
…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.
bors added a commit that referenced this pull request Nov 9, 2025
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
@bors bors merged commit 068e784 into rust-lang:master Nov 9, 2025
6 of 11 checks passed
@rustbot rustbot added this to the 1.93.0 milestone Nov 9, 2025
rust-timer added a commit that referenced this pull request Nov 9, 2025
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-diagnostics Area: Messages for errors, warnings, and lints A-repr-packed Area: the naughtiest repr S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Confusing error message with unaligned access to packed(n > 1) fields

6 participants