tests: rustc_public: Check const allocation for all variables (1 of 11 was missing)#152628
Open
Enselic wants to merge 1 commit intorust-lang:mainfrom
Open
tests: rustc_public: Check const allocation for all variables (1 of 11 was missing)#152628Enselic wants to merge 1 commit intorust-lang:mainfrom
Enselic wants to merge 1 commit intorust-lang:mainfrom
Conversation
…1 was missing)
In the test `tests/ui-fulldeps/rustc_public/check_allocation.rs` there
is a check for constant allocations of local variables of this function:
fn other_consts() {{
let _max_u128 = u128::MAX;
let _min_i128 = i128::MIN;
let _max_i8 = i8::MAX;
let _char = 'x';
let _false = false;
let _true = true;
let _ptr = &BAR;
let _null_ptr: *const u8 = NULL;
let _tuple = TUPLE;
let _char_id = const {{ type_id::<char>() }};
let _bool_id = const {{ type_id::<bool>() }};
}}
The current test only finds 10 out of 11 allocations. The constant
allocation for
let _ptr = &BAR;
is not checked, because the `SingleUseConsts` MIR pass does not optimize
away that assignment. Add code to also collect constant allocation from
assignment rvalues. Not only does this change make sense on its own, it
also makes the test pass both with and without the `SingleUseConsts`
pass.
Collaborator
|
rustbot has assigned @Mark-Simulacrum. Use Why was this reviewer chosen?The reviewer was selected based on:
|
Member
|
r? compiler |
Member
|
@bors reroll |
This comment has been minimized.
This comment has been minimized.
Member
|
@rustbot reroll |
Member
|
oops, assign the same reviwer @rustbot reroll |
This comment has been minimized.
This comment has been minimized.
Member
|
r? me |
jieyouxu
approved these changes
Feb 18, 2026
Contributor
JonathanBrouwer
added a commit
to JonathanBrouwer/rust
that referenced
this pull request
Feb 18, 2026
…eyouxu
tests: rustc_public: Check const allocation for all variables (1 of 11 was missing)
In the test `tests/ui-fulldeps/rustc_public/check_allocation.rs` there is a check for constant allocations of local variables of this function:
fn other_consts() {{
let _max_u128 = u128::MAX;
let _min_i128 = i128::MIN;
let _max_i8 = i8::MAX;
let _char = 'x';
let _false = false;
let _true = true;
let _ptr = &BAR;
let _null_ptr: *const u8 = NULL;
let _tuple = TUPLE;
let _char_id = const {{ type_id::<char>() }};
let _bool_id = const {{ type_id::<bool>() }};
}}
The current test only finds 10 out of 11 allocations. The constant allocation for
let _ptr = &BAR;
is not checked, because the `SingleUseConsts` MIR pass does not optimize away that assignment. Add code to also collect constant allocation from assignment rvalues to find the constant allocation for that last variable.
Not only does this change make sense on its own, it also makes the test pass both with and without the `SingleUseConsts` pass.
Discovered while investigating ways to avoid [this tests/ui-fulldeps/rustc_public/check_allocation.rs](Enselic@d7fffab#diff-c4a926f9e8ba22bcfb1e6f2491b79b80608ab018641f85f66d6718d7f3716a5e) hack from rust-lang#151426 which wants to stop running `SingleUseConsts` for non-optimized builds.
JonathanBrouwer
added a commit
to JonathanBrouwer/rust
that referenced
this pull request
Feb 18, 2026
…eyouxu
tests: rustc_public: Check const allocation for all variables (1 of 11 was missing)
In the test `tests/ui-fulldeps/rustc_public/check_allocation.rs` there is a check for constant allocations of local variables of this function:
fn other_consts() {{
let _max_u128 = u128::MAX;
let _min_i128 = i128::MIN;
let _max_i8 = i8::MAX;
let _char = 'x';
let _false = false;
let _true = true;
let _ptr = &BAR;
let _null_ptr: *const u8 = NULL;
let _tuple = TUPLE;
let _char_id = const {{ type_id::<char>() }};
let _bool_id = const {{ type_id::<bool>() }};
}}
The current test only finds 10 out of 11 allocations. The constant allocation for
let _ptr = &BAR;
is not checked, because the `SingleUseConsts` MIR pass does not optimize away that assignment. Add code to also collect constant allocation from assignment rvalues to find the constant allocation for that last variable.
Not only does this change make sense on its own, it also makes the test pass both with and without the `SingleUseConsts` pass.
Discovered while investigating ways to avoid [this tests/ui-fulldeps/rustc_public/check_allocation.rs](Enselic@d7fffab#diff-c4a926f9e8ba22bcfb1e6f2491b79b80608ab018641f85f66d6718d7f3716a5e) hack from rust-lang#151426 which wants to stop running `SingleUseConsts` for non-optimized builds.
JonathanBrouwer
added a commit
to JonathanBrouwer/rust
that referenced
this pull request
Feb 18, 2026
…eyouxu
tests: rustc_public: Check const allocation for all variables (1 of 11 was missing)
In the test `tests/ui-fulldeps/rustc_public/check_allocation.rs` there is a check for constant allocations of local variables of this function:
fn other_consts() {{
let _max_u128 = u128::MAX;
let _min_i128 = i128::MIN;
let _max_i8 = i8::MAX;
let _char = 'x';
let _false = false;
let _true = true;
let _ptr = &BAR;
let _null_ptr: *const u8 = NULL;
let _tuple = TUPLE;
let _char_id = const {{ type_id::<char>() }};
let _bool_id = const {{ type_id::<bool>() }};
}}
The current test only finds 10 out of 11 allocations. The constant allocation for
let _ptr = &BAR;
is not checked, because the `SingleUseConsts` MIR pass does not optimize away that assignment. Add code to also collect constant allocation from assignment rvalues to find the constant allocation for that last variable.
Not only does this change make sense on its own, it also makes the test pass both with and without the `SingleUseConsts` pass.
Discovered while investigating ways to avoid [this tests/ui-fulldeps/rustc_public/check_allocation.rs](Enselic@d7fffab#diff-c4a926f9e8ba22bcfb1e6f2491b79b80608ab018641f85f66d6718d7f3716a5e) hack from rust-lang#151426 which wants to stop running `SingleUseConsts` for non-optimized builds.
rust-bors bot
pushed a commit
that referenced
this pull request
Feb 18, 2026
…uwer Rollup of 18 pull requests Successful merges: - #152799 (Subtree sync for rustc_codegen_cranelift) - #152569 (Stop using rustc_layout_scalar_valid_range_* in rustc) - #151059 (x86: support passing `u128`/`i128` to inline assembly) - #152097 (Suggest local variables for captured format args) - #152734 (Respect the `--ci` flag in more places in bootstrap) - #151703 (Fix ICE in transmutability error reporting when type aliases are normalized) - #152173 (Reflection TypeKind::FnPtr) - #152564 (Remove unnecessary closure.) - #152628 (tests: rustc_public: Check const allocation for all variables (1 of 11 was missing)) - #152658 (compiletest: normalize stderr before SVG rendering) - #152766 (std::r#try! - avoid link to nightly docs) - #152780 (Remove some clones in deriving) - #152787 (Add a mir-opt test for alignment check generation [zero changes outside tests]) - #152790 (Fix incorrect target in aarch64-unknown-linux-gnu docs) - #152792 (Fix an ICE while checking param env shadowing on an erroneous trait impl) - #152793 (Do no add -no-pie on Windows) - #152803 (Avoid delayed-bug ICE for malformed diagnostic attrs) - #152806 (interpret: fix comment typo)
JonathanBrouwer
added a commit
to JonathanBrouwer/rust
that referenced
this pull request
Feb 18, 2026
…eyouxu
tests: rustc_public: Check const allocation for all variables (1 of 11 was missing)
In the test `tests/ui-fulldeps/rustc_public/check_allocation.rs` there is a check for constant allocations of local variables of this function:
fn other_consts() {{
let _max_u128 = u128::MAX;
let _min_i128 = i128::MIN;
let _max_i8 = i8::MAX;
let _char = 'x';
let _false = false;
let _true = true;
let _ptr = &BAR;
let _null_ptr: *const u8 = NULL;
let _tuple = TUPLE;
let _char_id = const {{ type_id::<char>() }};
let _bool_id = const {{ type_id::<bool>() }};
}}
The current test only finds 10 out of 11 allocations. The constant allocation for
let _ptr = &BAR;
is not checked, because the `SingleUseConsts` MIR pass does not optimize away that assignment. Add code to also collect constant allocation from assignment rvalues to find the constant allocation for that last variable.
Not only does this change make sense on its own, it also makes the test pass both with and without the `SingleUseConsts` pass.
Discovered while investigating ways to avoid [this tests/ui-fulldeps/rustc_public/check_allocation.rs](Enselic@d7fffab#diff-c4a926f9e8ba22bcfb1e6f2491b79b80608ab018641f85f66d6718d7f3716a5e) hack from rust-lang#151426 which wants to stop running `SingleUseConsts` for non-optimized builds.
rust-bors bot
pushed a commit
that referenced
this pull request
Feb 19, 2026
…uwer Rollup of 18 pull requests Successful merges: - #152799 (Subtree sync for rustc_codegen_cranelift) - #152814 (stdarch subtree update) - #151059 (x86: support passing `u128`/`i128` to inline assembly) - #152097 (Suggest local variables for captured format args) - #152734 (Respect the `--ci` flag in more places in bootstrap) - #151703 (Fix ICE in transmutability error reporting when type aliases are normalized) - #152173 (Reflection TypeKind::FnPtr) - #152564 (Remove unnecessary closure.) - #152628 (tests: rustc_public: Check const allocation for all variables (1 of 11 was missing)) - #152658 (compiletest: normalize stderr before SVG rendering) - #152766 (std::r#try! - avoid link to nightly docs) - #152780 (Remove some clones in deriving) - #152787 (Add a mir-opt test for alignment check generation [zero changes outside tests]) - #152790 (Fix incorrect target in aarch64-unknown-linux-gnu docs) - #152792 (Fix an ICE while checking param env shadowing on an erroneous trait impl) - #152793 (Do no add -no-pie on Windows) - #152803 (Avoid delayed-bug ICE for malformed diagnostic attrs) - #152806 (interpret: fix comment typo)
rust-bors bot
pushed a commit
that referenced
this pull request
Feb 19, 2026
…uwer Rollup of 18 pull requests Successful merges: - #152799 (Subtree sync for rustc_codegen_cranelift) - #152814 (stdarch subtree update) - #151059 (x86: support passing `u128`/`i128` to inline assembly) - #152097 (Suggest local variables for captured format args) - #152734 (Respect the `--ci` flag in more places in bootstrap) - #151703 (Fix ICE in transmutability error reporting when type aliases are normalized) - #152173 (Reflection TypeKind::FnPtr) - #152564 (Remove unnecessary closure.) - #152628 (tests: rustc_public: Check const allocation for all variables (1 of 11 was missing)) - #152658 (compiletest: normalize stderr before SVG rendering) - #152766 (std::r#try! - avoid link to nightly docs) - #152780 (Remove some clones in deriving) - #152787 (Add a mir-opt test for alignment check generation [zero changes outside tests]) - #152790 (Fix incorrect target in aarch64-unknown-linux-gnu docs) - #152792 (Fix an ICE while checking param env shadowing on an erroneous trait impl) - #152793 (Do no add -no-pie on Windows) - #152803 (Avoid delayed-bug ICE for malformed diagnostic attrs) - #152806 (interpret: fix comment typo)
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.
In the test
tests/ui-fulldeps/rustc_public/check_allocation.rsthere is a check for constant allocations of local variables of this function:The current test only finds 10 out of 11 allocations. The constant allocation for
is not checked, because the
SingleUseConstsMIR pass does not optimize away that assignment. Add code to also collect constant allocation from assignment rvalues to find the constant allocation for that last variable.Not only does this change make sense on its own, it also makes the test pass both with and without the
SingleUseConstspass.Discovered while investigating ways to avoid this tests/ui-fulldeps/rustc_public/check_allocation.rs hack from #151426 which wants to stop running
SingleUseConstsfor non-optimized builds.