Skip to content

AlignmentEnum should just be repr(usize) now #144667

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

scottmcm
Copy link
Member

These used to use specific sizes because they were compiled on all widths. But now that the types themselves are #[cfg]'d, we can save some conversions by having it always be repr(usize).

@rustbot
Copy link
Collaborator

rustbot commented Jul 30, 2025

r? @tgross35

rustbot has assigned @tgross35.
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

@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. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Jul 30, 2025
Comment on lines 90 to +91
_10 = discriminant(_8);
_11 = move _10 as usize (IntToInt);
StorageDead(_10);
_12 = alloc::alloc::__rust_dealloc(move _9, move _5, move _11) -> [return: bb3, unwind unreachable];
_11 = alloc::alloc::__rust_dealloc(move _9, move _5, move _10) -> [return: bb3, unwind unreachable];
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This way the discriminant just gives usize, rather than u64, so the no-op cast (and extra local) isn't needed any more.

@rust-log-analyzer

This comment has been minimized.

Since it's cfg'd instead of type-aliased
@scottmcm scottmcm force-pushed the alignment-is-usize branch from d525ac1 to 4220587 Compare July 30, 2025 07:09
@tgross35
Copy link
Contributor

tgross35 commented Aug 1, 2025

Awesome!

@bors r+

@bors
Copy link
Collaborator

bors commented Aug 1, 2025

📌 Commit 4220587 has been approved by tgross35

It is now in the queue for this repository.

@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 Aug 1, 2025
Zalathar added a commit to Zalathar/rust that referenced this pull request Aug 3, 2025
…oss35

`AlignmentEnum` should just be `repr(usize)` now

These used to use specific sizes because they were compiled on all widths.  But now that the types themselves are `#[cfg]`'d, we can save some conversions by having it always be `repr(usize)`.
bors added a commit that referenced this pull request Aug 3, 2025
Rollup of 14 pull requests

Successful merges:

 - #143857 (Port #[macro_export] to the new attribute parsing infrastructure)
 - #143900 ([rustdoc] Correctly handle `should_panic` doctest attribute and fix `--no-run` test flag on the 2024 edition)
 - #144070 (Implement `hash_map` macro )
 - #144322 (Add lint against dangling pointers from local variables)
 - #144443 (Make target pointer width in target json an integer)
 - #144667 (`AlignmentEnum` should just be `repr(usize)` now)
 - #144779 (Implement debugging output of the bootstrap Step graph into a DOT file)
 - #144790 (Multiple bounds checking elision failures)
 - #144794 (Port `#[coroutine]` to the new attribute system)
 - #144808 (`Interner` arg to `EarlyBinder` does not affect auto traits)
 - #144816 (Update E0562 to account for the new impl trait positions)
 - #144822 (Return a struct with named fields from `hash_owner_nodes`)
 - #144824 (Updated test links in compiler)
 - #144829 (Use full flag name in strip command for Darwin)

r? `@ghost`
`@rustbot` modify labels: rollup
Zalathar added a commit to Zalathar/rust that referenced this pull request Aug 3, 2025
…oss35

`AlignmentEnum` should just be `repr(usize)` now

These used to use specific sizes because they were compiled on all widths.  But now that the types themselves are `#[cfg]`'d, we can save some conversions by having it always be `repr(usize)`.
bors added a commit that referenced this pull request Aug 3, 2025
Rollup of 13 pull requests

Successful merges:

 - #143857 (Port #[macro_export] to the new attribute parsing infrastructure)
 - #143900 ([rustdoc] Correctly handle `should_panic` doctest attribute and fix `--no-run` test flag on the 2024 edition)
 - #144070 (Implement `hash_map` macro )
 - #144322 (Add lint against dangling pointers from local variables)
 - #144443 (Make target pointer width in target json an integer)
 - #144667 (`AlignmentEnum` should just be `repr(usize)` now)
 - #144790 (Multiple bounds checking elision failures)
 - #144794 (Port `#[coroutine]` to the new attribute system)
 - #144808 (`Interner` arg to `EarlyBinder` does not affect auto traits)
 - #144816 (Update E0562 to account for the new impl trait positions)
 - #144822 (Return a struct with named fields from `hash_owner_nodes`)
 - #144824 (Updated test links in compiler)
 - #144829 (Use full flag name in strip command for Darwin)

r? `@ghost`
`@rustbot` modify labels: rollup
Zalathar added a commit to Zalathar/rust that referenced this pull request Aug 3, 2025
…oss35

`AlignmentEnum` should just be `repr(usize)` now

These used to use specific sizes because they were compiled on all widths.  But now that the types themselves are `#[cfg]`'d, we can save some conversions by having it always be `repr(usize)`.
bors added a commit that referenced this pull request Aug 3, 2025
Rollup of 13 pull requests

Successful merges:

 - #143857 (Port #[macro_export] to the new attribute parsing infrastructure)
 - #144070 (Implement `hash_map` macro )
 - #144322 (Add lint against dangling pointers from local variables)
 - #144667 (`AlignmentEnum` should just be `repr(usize)` now)
 - #144678 (Make no_mangle on foreign items explicit instead of implicit)
 - #144790 (Multiple bounds checking elision failures)
 - #144794 (Port `#[coroutine]` to the new attribute system)
 - #144805 (compiletest: Preliminary cleanup of `ProcRes` printing/unwinding)
 - #144808 (`Interner` arg to `EarlyBinder` does not affect auto traits)
 - #144816 (Update E0562 to account for the new impl trait positions)
 - #144822 (Return a struct with named fields from `hash_owner_nodes`)
 - #144824 (Updated test links in compiler)
 - #144829 (Use full flag name in strip command for Darwin)

r? `@ghost`
`@rustbot` modify labels: rollup
Zalathar added a commit to Zalathar/rust that referenced this pull request Aug 3, 2025
…oss35

`AlignmentEnum` should just be `repr(usize)` now

These used to use specific sizes because they were compiled on all widths.  But now that the types themselves are `#[cfg]`'d, we can save some conversions by having it always be `repr(usize)`.
bors added a commit that referenced this pull request Aug 3, 2025
Rollup of 13 pull requests

Successful merges:

 - #143857 (Port #[macro_export] to the new attribute parsing infrastructure)
 - #144070 (Implement `hash_map` macro )
 - #144322 (Add lint against dangling pointers from local variables)
 - #144667 (`AlignmentEnum` should just be `repr(usize)` now)
 - #144706 (Do not give function allocations alignment in consteval and Miri.)
 - #144790 (Multiple bounds checking elision failures)
 - #144794 (Port `#[coroutine]` to the new attribute system)
 - #144805 (compiletest: Preliminary cleanup of `ProcRes` printing/unwinding)
 - #144808 (`Interner` arg to `EarlyBinder` does not affect auto traits)
 - #144816 (Update E0562 to account for the new impl trait positions)
 - #144822 (Return a struct with named fields from `hash_owner_nodes`)
 - #144824 (Updated test links in compiler)
 - #144829 (Use full flag name in strip command for Darwin)

r? `@ghost`
`@rustbot` modify labels: rollup
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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. T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants