summary refs log tree commit diff
diff options
context:
space:
mode:
authorAlona Enraght-Moony <code@alona.page>2023-11-28 22:31:53 +0000
committerJosh Stone <jistone@redhat.com>2023-11-30 16:53:37 -0800
commit98d3e99b8c1aaf745be6e53c121e052d1e9ae31a (patch)
tree13e1d8fbba8bf63215cd19ccd96372de1d1046fc
parentcb4f87af3490997fa31e751ecf62647acd058bd3 (diff)
downloadrust-98d3e99b8c1aaf745be6e53c121e052d1e9ae31a.tar.gz
rust-98d3e99b8c1aaf745be6e53c121e052d1e9ae31a.zip
Rename and add another test
(cherry picked from commit 6e956c0a383444a25cc0e690cbc9fa6f859b07b4)
-rw-r--r--tests/mir-opt/const_prop/overwrite_with_const_with_params.rs26
-rw-r--r--tests/mir-opt/const_prop/overwrite_with_const_with_params.size_of.ConstProp.diff (renamed from tests/mir-opt/const_prop/issue_118328.size_of.ConstProp.diff)0
-rw-r--r--tests/ui/const_prop/overwrite_with_const_with_params.rs (renamed from tests/mir-opt/const_prop/issue_118328.rs)7
3 files changed, 30 insertions, 3 deletions
diff --git a/tests/mir-opt/const_prop/overwrite_with_const_with_params.rs b/tests/mir-opt/const_prop/overwrite_with_const_with_params.rs
new file mode 100644
index 00000000000..4cf6d7c1396
--- /dev/null
+++ b/tests/mir-opt/const_prop/overwrite_with_const_with_params.rs
@@ -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>());
+}
diff --git a/tests/mir-opt/const_prop/issue_118328.size_of.ConstProp.diff b/tests/mir-opt/const_prop/overwrite_with_const_with_params.size_of.ConstProp.diff
index ad8318832d6..ad8318832d6 100644
--- a/tests/mir-opt/const_prop/issue_118328.size_of.ConstProp.diff
+++ b/tests/mir-opt/const_prop/overwrite_with_const_with_params.size_of.ConstProp.diff
diff --git a/tests/mir-opt/const_prop/issue_118328.rs b/tests/ui/const_prop/overwrite_with_const_with_params.rs
index 5072091ddfc..6f533919a47 100644
--- a/tests/mir-opt/const_prop/issue_118328.rs
+++ b/tests/ui/const_prop/overwrite_with_const_with_params.rs
@@ -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;