Repository navigation
Don't round the number of bits passed to {Size,Align}::from_bits - #166650
Merged
rust-bors[bot] merged 1 commit intoNov 27, 2026
Merged
Conversation
Collaborator
|
Some changes occurred to MIR optimizations cc @rust-lang/wg-mir-opt |
Collaborator
|
|
This comment has been minimized.
This comment has been minimized.
beetrees
force-pushed
the
size-align-from-bits-exact
branch
from
November 27, 2026 09:38
ab5ce88 to
2d0354e
Compare
Collaborator
|
cc @rust-lang/miri |
Contributor
|
@bors r+ |
Contributor
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 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)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The current behaviour is more likely to mask typos than be the intended behaviour, and can give the misleading impression that
Sizecan store sizes that are a non-whole-number of bytes. This is particularly nonsensical forAlign::from_bitswhereAlign::from_bits(24)has always been an error whereasAlign::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 whereSize::from_bits(1)is used as a constant to represent the size of abool(1 byte) - this PR replaces those with the more explicitSize::from_bytes(1)/Size::from_bits(8). If the rounding behaviour is needed in the future, a dedicatedSize::ceil_from_bitsmethod can be added.r? @folkertdev