From 6e956c0a383444a25cc0e690cbc9fa6f859b07b4 Mon Sep 17 00:00:00 2001 From: Alona Enraght-Moony Date: Tue, 28 Nov 2023 22:31:53 +0000 Subject: [PATCH] Rename and add another test --- .../overwrite_with_const_with_params.rs | 26 +++++++++++++++++++ ..._const_with_params.size_of.ConstProp.diff} | 0 .../overwrite_with_const_with_params.rs} | 7 ++--- 3 files changed, 30 insertions(+), 3 deletions(-) create mode 100644 tests/mir-opt/const_prop/overwrite_with_const_with_params.rs rename tests/mir-opt/const_prop/{issue_118328.size_of.ConstProp.diff => overwrite_with_const_with_params.size_of.ConstProp.diff} (100%) rename tests/{mir-opt/const_prop/issue_118328.rs => ui/const_prop/overwrite_with_const_with_params.rs} (79%) 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(std::marker::PhantomData); +impl SizeOfConst { + const SIZE: usize = std::mem::size_of::(); +} + +// EMIT_MIR overwrite_with_const_with_params.size_of.ConstProp.diff +fn size_of() -> 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::::SIZE; + a +} + +fn main() { + assert_eq!(size_of::(), std::mem::size_of::()); +} 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 similarity index 100% rename from tests/mir-opt/const_prop/issue_118328.size_of.ConstProp.diff rename to 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 similarity index 79% rename from tests/mir-opt/const_prop/issue_118328.rs rename to 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(std::marker::PhantomData); @@ -8,7 +10,6 @@ impl SizeOfConst { const SIZE: usize = std::mem::size_of::(); } -// EMIT_MIR issue_118328.size_of.ConstProp.diff fn size_of() -> usize { let mut a = 0; a = SizeOfConst::::SIZE;