Rename and add another test

This commit is contained in:
Alona Enraght-Moony 2023-11-28 22:31:53 +00:00
parent 9121a41450
commit 6e956c0a38
3 changed files with 30 additions and 3 deletions

View file

@ -0,0 +1,26 @@
// unit-test: ConstProp
// compile-flags: -O
// 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>();
}
// EMIT_MIR overwrite_with_const_with_params.size_of.ConstProp.diff
fn size_of<T>() -> usize {
// 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>());
}

View file

@ -1,6 +1,8 @@
// unit-test: ConstProp
// compile-flags: -O
// skip-filecheck
// run-pass
// Regression test for https://github.com/rust-lang/rust/issues/118328
#![allow(unused_assignments)]
struct SizeOfConst<T>(std::marker::PhantomData<T>);
@ -8,7 +10,6 @@ impl<T> SizeOfConst<T> {
const SIZE: usize = std::mem::size_of::<T>();
}
// EMIT_MIR issue_118328.size_of.ConstProp.diff
fn size_of<T>() -> usize {
let mut a = 0;
a = SizeOfConst::<T>::SIZE;