Skip to content

Commit 0981b7b

Browse files
committed
Rename and add another test
1 parent 9121a41 commit 0981b7b

File tree

3 files changed

+31
-3
lines changed

3 files changed

+31
-3
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// unit-test: ConstProp
2+
// compile-flags: -O
3+
// skip-filecheck
4+
5+
// Regression test for https://github.com/rust-lang/rust/issues/118328
6+
7+
#![allow(unused_assignments)]
8+
9+
struct SizeOfConst<T>(std::marker::PhantomData<T>);
10+
impl<T> SizeOfConst<T> {
11+
const SIZE: usize = std::mem::size_of::<T>();
12+
}
13+
14+
// EMIT_MIR overwrite_with_const_with_params.size_of.ConstProp.diff
15+
fn size_of<T>() -> usize {
16+
// CHECK-LABEL: fn size_of(
17+
// CHECK: _1 = const 0_usize;
18+
// CHECK-NEXT: _1 = const _;
19+
// CHECK-NEXT: _0 = _1;
20+
let mut a = 0;
21+
a = SizeOfConst::<T>::SIZE;
22+
a
23+
}
24+
25+
fn main() {
26+
assert_eq!(size_of::<u32>(), std::mem::size_of::<u32>());
27+
}

tests/mir-opt/const_prop/issue_118328.rs renamed to tests/ui/const_prop/overwrite_with_const_with_params.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
1-
// unit-test: ConstProp
21
// compile-flags: -O
3-
// skip-filecheck
2+
// run-pass
3+
4+
// Regression test for https://github.com/rust-lang/rust/issues/118328
5+
46
#![allow(unused_assignments)]
57

68
struct SizeOfConst<T>(std::marker::PhantomData<T>);
79
impl<T> SizeOfConst<T> {
810
const SIZE: usize = std::mem::size_of::<T>();
911
}
1012

11-
// EMIT_MIR issue_118328.size_of.ConstProp.diff
1213
fn size_of<T>() -> usize {
1314
let mut a = 0;
1415
a = SizeOfConst::<T>::SIZE;

0 commit comments

Comments
 (0)