//@ test-mir-pass: GVN //@ compile-flags: -O // Regression test for https://github.com/rust-lang/rust/issues/118328 #![allow(unused_assignments)] struct SizeOfConst(std::marker::PhantomData); impl SizeOfConst { const SIZE: usize = std::mem::size_of::(); } // EMIT_MIR overwrite_with_const_with_params.size_of.GVN.diff fn size_of() -> usize { // CHECK-LABEL: fn size_of( // CHECK: _1 = const 0_usize; // CHECK-NEXT: _1 = const SizeOfConst::::SIZE; // CHECK-NEXT: _0 = _1; let mut a = 0; a = SizeOfConst::::SIZE; a } fn main() { assert_eq!(size_of::(), std::mem::size_of::()); }