rust/tests
Jonathan Brouwer 78fac697e7
Rollup merge of #152628 - Enselic:ptr-const-allocation, r=jieyouxu
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](d7fffabc31 (diff-c4a926f9e8ba22bcfb1e6f2491b79b80608ab018641f85f66d6718d7f3716a5e)) hack from https://github.com/rust-lang/rust/pull/151426 which wants to stop running `SingleUseConsts` for non-optimized builds.
2026-02-18 18:55:17 +01:00
..
assembly-llvm Rollup merge of #152404 - durin42:llvm-23-instcombine-shrink-constant, r=Mark-Simulacrum 2026-02-14 22:11:54 +01:00
auxiliary Rollup merge of #151059 - folkertdev:x86-u128-reg, r=Amanieu 2026-02-18 18:55:14 +01:00
build-std/configurations Test that -Zbuild-std=core works on a variety of profiles 2026-01-14 20:39:12 -05:00
codegen-llvm make rustc_allow_const_fn_unstable an actual rustc_attrs attribute 2026-02-17 20:16:29 +00:00
codegen-units add write_box_via_move intrinsic and use it for vec! 2026-02-16 17:27:40 +01:00
coverage coverage: Add a test case for a previously-unknown span mismatch 2026-02-03 22:53:38 +11:00
coverage-run-rustdoc
crashes Revert "Fix an ICE in the vtable iteration for a trait reference" 2026-02-16 17:52:06 -08:00
debuginfo Allow provisional mgca syntax of type const <IDENT> = <EXPR> to be reconized. 2026-02-09 07:59:24 -08:00
incremental Bless tests 2026-02-11 18:08:18 +09:00
mir-opt Rollup merge of #152729 - Enselic:single_use_consts-not-required, r=cjgillot 2026-02-18 17:29:43 +11:00
pretty Fix pretty print tests with #[prelude_import] 2026-02-12 17:43:58 +00:00
run-make Rollup merge of #152474 - sgasho:opt-bisect-limit-mir, r=saethlin 2026-02-18 17:29:46 +11:00
run-make-cargo Update cargo submodule 2026-01-30 19:15:24 -05:00
rustdoc-gui Remove the 4 failing tests from rustdoc-gui 2026-02-06 01:13:41 +01:00
rustdoc-html Rollup merge of #151783 - mu001999-contrib:impl/final-method, r=fee1-dead 2026-02-17 13:02:21 +11:00
rustdoc-js rustdoc: sort stable items first 2026-02-13 14:44:41 -06:00
rustdoc-js-std rustdoc: sort stable items first 2026-02-13 14:44:41 -06:00
rustdoc-json resolve: Mark items under ambigous imports as exported 2026-01-27 16:24:53 +03:00
rustdoc-ui Unify wording of resolve error 2026-02-17 16:51:44 +00:00
ui Rollup merge of #151703 - zedddie:fix-151462-ice, r=jdonszelmann 2026-02-18 18:55:15 +01:00
ui-fulldeps Rollup merge of #152628 - Enselic:ptr-const-allocation, r=jieyouxu 2026-02-18 18:55:17 +01:00
COMPILER_TESTS.md