Rename and add another test
This commit is contained in:
parent
9121a41450
commit
6e956c0a38
3 changed files with 30 additions and 3 deletions
26
tests/mir-opt/const_prop/overwrite_with_const_with_params.rs
Normal file
26
tests/mir-opt/const_prop/overwrite_with_const_with_params.rs
Normal 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>());
|
||||
}
|
|
@ -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;
|
Loading…
Add table
Reference in a new issue