Tighten the !range bounds on alignments in vtables#152929
Merged
rust-bors[bot] merged 1 commit intorust-lang:mainfrom Feb 21, 2026
Merged
Tighten the !range bounds on alignments in vtables#152929rust-bors[bot] merged 1 commit intorust-lang:mainfrom
!range bounds on alignments in vtables#152929rust-bors[bot] merged 1 commit intorust-lang:mainfrom
Conversation
…lignment from a vtable
Collaborator
|
r? @adwinwhite rustbot has assigned @adwinwhite. Use Why was this reviewer chosen?The reviewer was selected based on:
|
Contributor
|
@rustbot reroll |
Member
Author
|
Oh, looks like the bot isn't picking from the narrower group. |
Member
|
Nice. @bors r+ |
Contributor
matthiaskrgr
added a commit
to matthiaskrgr/rust
that referenced
this pull request
Feb 21, 2026
…r=mati865 Tighten the `!range` bounds on alignments in vtables Right now we're only telling LLVM that they're non-zero, but alignments must be powers of two so can't be more than `isize::MAX+1`. And we actually never emit anything beyond LLVM's limit of 2²⁹, so outside of 16-bit targets the limit is that. (Pulled out from rust-lang#152867 which is starting to have too much in it.)
rust-bors bot
pushed a commit
that referenced
this pull request
Feb 21, 2026
Rollup of 6 pull requests Successful merges: - #152929 (Tighten the `!range` bounds on alignments in vtables) - #151603 (Stabilize `str_as_str`) - #152878 (Remove two more flaky assertions from `oneshot` tests) - #152915 (Error on attempt to construct scalable vector type) - #152925 (Improve runtest revision redundant cfg check) - #152928 (Update wasm-component-ld)
| pub fn max_for_target(tdl: &TargetDataLayout) -> Align { | ||
| let pointer_bits = tdl.pointer_size().bits(); | ||
| if let Ok(pointer_bits) = u8::try_from(pointer_bits) | ||
| && pointer_bits <= Align::MAX.pow2 |
Contributor
There was a problem hiding this comment.
Question, are we taking the max between Align::MAX.pow2 and pointer_bits, or between Align::MAX.pow2 and pointer_bits - 1?
Could this be what we actually want?
Suggested change
| && pointer_bits <= Align::MAX.pow2 | |
| && pointer_bits - 1 <= Align::MAX.pow2 |
rust-bors bot
pushed a commit
that referenced
this pull request
Feb 21, 2026
Rollup of 6 pull requests Successful merges: - #152929 (Tighten the `!range` bounds on alignments in vtables) - #151603 (Stabilize `str_as_str`) - #152878 (Remove two more flaky assertions from `oneshot` tests) - #152915 (Error on attempt to construct scalable vector type) - #152925 (Improve runtest revision redundant cfg check) - #152928 (Update wasm-component-ld)
rust-timer
added a commit
that referenced
this pull request
Feb 21, 2026
Rollup merge of #152929 - scottmcm:better-alignment-ranges, r=mati865 Tighten the `!range` bounds on alignments in vtables Right now we're only telling LLVM that they're non-zero, but alignments must be powers of two so can't be more than `isize::MAX+1`. And we actually never emit anything beyond LLVM's limit of 2²⁹, so outside of 16-bit targets the limit is that. (Pulled out from #152867 which is starting to have too much in it.)
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.
Right now we're only telling LLVM that they're non-zero, but alignments must be powers of two so can't be more than
isize::MAX+1. And we actually never emit anything beyond LLVM's limit of 2²⁹, so outside of 16-bit targets the limit is that.(Pulled out from #152867 which is starting to have too much in it.)