Skip to content

Commit 6e956c0

Browse files
committed
Rename and add another test
1 parent 9121a41 commit 6e956c0

File tree

3 files changed

+30
-3
lines changed

3 files changed

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

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

+4-3
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)