rust/tests/mir-opt/const_prop/overwrite_with_const_with_params.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

27 lines
625 B
Rust
Raw Normal View History

2023-09-20 21:43:33 +00:00
// unit-test: GVN
// compile-flags: -O
2023-11-28 22:31:53 +00:00
// Regression test for https://github.com/rust-lang/rust/issues/118328
#![allow(unused_assignments)]
struct SizeOfConst<T>(std::marker::PhantomData<T>);
impl<T> SizeOfConst<T> {
const SIZE: usize = std::mem::size_of::<T>();
}
2023-09-20 21:43:33 +00:00
// EMIT_MIR overwrite_with_const_with_params.size_of.GVN.diff
fn size_of<T>() -> usize {
2023-11-28 22:31:53 +00:00
// CHECK-LABEL: fn size_of(
// CHECK: _1 = const 0_usize;
// CHECK-NEXT: _1 = const _;
// CHECK-NEXT: _0 = _1;
let mut a = 0;
a = SizeOfConst::<T>::SIZE;
a
}
fn main() {
assert_eq!(size_of::<u32>(), std::mem::size_of::<u32>());
}