Skip to content

Don't round the number of bits passed to {Size,Align}::from_bits - #166650

Merged
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
beetrees:size-align-from-bits-exact
Nov 27, 2026
Merged

rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
beetrees:size-align-from-bits-exact

Conversation

@beetrees

Copy link
Copy Markdown
Contributor

The current behaviour is more likely to mask typos than be the intended behaviour, and can give the misleading impression that Size can store sizes that are a non-whole-number of bytes. This is particularly nonsensical for Align::from_bits where Align::from_bits(24) has always been an error whereas Align::from_bits(25) was rounded up to a 32-bit alignment before this PR. The only places where the current rounding behaviour is relied upon are a few places where Size::from_bits(1) is used as a constant to represent the size of a bool (1 byte) - this PR replaces those with the more explicit Size::from_bytes(1)/Size::from_bits(8). If the rounding behaviour is needed in the future, a dedicated Size::ceil_from_bits method can be added.

r? @folkertdev

@rustbot

rustbot commented Nov 27, 2026

Copy link
Copy Markdown
Collaborator

Some changes occurred to MIR optimizations

cc @rust-lang/wg-mir-opt

@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 Nov 27, 2026
@rustbot

rustbot commented Nov 27, 2026

Copy link
Copy Markdown
Collaborator

folkertdev is currently at their maximum review capacity.
They may take a while to respond.

@rust-log-analyzer

This comment has been minimized.

@beetrees
beetrees force-pushed the size-align-from-bits-exact branch from ab5ce88 to 2d0354e Compare November 27, 2026 09:38
@rustbot

rustbot commented Nov 27, 2026

Copy link
Copy Markdown
Collaborator

miri is developed in its own repository. If the Miri part of this change can be broken out, consider making this change to rust-lang/miri instead. However, if Miri needs adjusting for rustc changes, just ignore this message.

cc @rust-lang/miri

@folkertdev

Copy link
Copy Markdown
Contributor

@bors r+

@rust-bors

rust-bors Bot commented Nov 27, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 2d0354e has been approved by folkertdev

It is now in the queue for this repository.

@rust-bors rust-bors Bot 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 27, 2026
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Nov 27, 2026
…t, r=folkertdev

Don't round the number of bits passed to `{Size,Align}::from_bits`

The current behaviour is more likely to mask typos than be the intended behaviour, and can give the misleading impression that `Size` can store sizes that are a non-whole-number of bytes. This is particularly nonsensical for `Align::from_bits` where `Align::from_bits(24)` has always been an error whereas `Align::from_bits(25)` was rounded up to a 32-bit alignment before this PR. The only places where the current rounding behaviour is relied upon are a few places where `Size::from_bits(1)` is used as a constant to represent the size of a `bool` (1 byte) - this PR replaces those with the more explicit `Size::from_bytes(1)`/`Size::from_bits(8)`. If the rounding behaviour is needed in the future, a dedicated `Size::ceil_from_bits` method can be added.

r? @folkertdev
rust-bors Bot pushed a commit that referenced this pull request Nov 27, 2026
…uwer

Rollup of 9 pull requests

Successful merges:

 - #163895 (Stabilize `--remap-path-scope` in rustdoc and the `documentation` scope)
 - #163910 (debugger: stabilize trim-paths unremap file loading)
 - #166175 (Use `__fastfail()` for `crash()` on Windows)
 - #166377 (fix: ignore format literal source availability in stable hashes)
 - #166510 (add c-variadic support for `x87_f80`)
 - #166650 (Don't round the number of bits passed to `{Size,Align}::from_bits`)
 - #161531 (Remove `T: Send + Sync` bound from `Arc::downcast`)
 - #166641 (fix: bootstrap build directory handling with --set)
 - #166655 (Submodule update of rustc-perf)
rust-bors Bot pushed a commit that referenced this pull request Nov 27, 2026
…uwer

Rollup of 9 pull requests

Successful merges:

 - #163895 (Stabilize `--remap-path-scope` in rustdoc and the `documentation` scope)
 - #163910 (debugger: stabilize trim-paths unremap file loading)
 - #166377 (fix: ignore format literal source availability in stable hashes)
 - #166510 (add c-variadic support for `x87_f80`)
 - #166631 (Remove `fn terminator()` and `terminator_mut()`)
 - #166650 (Don't round the number of bits passed to `{Size,Align}::from_bits`)
 - #161531 (Remove `T: Send + Sync` bound from `Arc::downcast`)
 - #166641 (fix: bootstrap build directory handling with --set)
 - #166655 (Submodule update of rustc-perf)
@rust-bors
rust-bors Bot merged commit 4095436 into rust-lang:main Nov 27, 2026
14 checks passed
@rustbot rustbot added this to the 1.102.0 milestone Nov 27, 2026
rust-bors Bot pushed a commit that referenced this pull request Nov 27, 2026
Rollup merge of #166650 - beetrees:size-align-from-bits-exact, r=folkertdev

Don't round the number of bits passed to `{Size,Align}::from_bits`

The current behaviour is more likely to mask typos than be the intended behaviour, and can give the misleading impression that `Size` can store sizes that are a non-whole-number of bytes. This is particularly nonsensical for `Align::from_bits` where `Align::from_bits(24)` has always been an error whereas `Align::from_bits(25)` was rounded up to a 32-bit alignment before this PR. The only places where the current rounding behaviour is relied upon are a few places where `Size::from_bits(1)` is used as a constant to represent the size of a `bool` (1 byte) - this PR replaces those with the more explicit `Size::from_bytes(1)`/`Size::from_bits(8)`. If the rounding behaviour is needed in the future, a dedicated `Size::ceil_from_bits` method can be added.

r? @folkertdev
mehmettoplu-rs pushed a commit to mehmettoplu-rs/miri that referenced this pull request Nov 28, 2026
…uwer

Rollup of 9 pull requests

Successful merges:

 - rust-lang/rust#163895 (Stabilize `--remap-path-scope` in rustdoc and the `documentation` scope)
 - rust-lang/rust#163910 (debugger: stabilize trim-paths unremap file loading)
 - rust-lang/rust#166377 (fix: ignore format literal source availability in stable hashes)
 - rust-lang/rust#166510 (add c-variadic support for `x87_f80`)
 - rust-lang/rust#166631 (Remove `fn terminator()` and `terminator_mut()`)
 - rust-lang/rust#166650 (Don't round the number of bits passed to `{Size,Align}::from_bits`)
 - rust-lang/rust#161531 (Remove `T: Send + Sync` bound from `Arc::downcast`)
 - rust-lang/rust#166641 (fix: bootstrap build directory handling with --set)
 - rust-lang/rust#166655 (Submodule update of rustc-perf)
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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants