From 98d3e99b8c1aaf745be6e53c121e052d1e9ae31a Mon Sep 17 00:00:00 2001 From: Alona Enraght-Moony Date: Tue, 28 Nov 2023 22:31:53 +0000 Subject: Rename and add another test (cherry picked from commit 6e956c0a383444a25cc0e690cbc9fa6f859b07b4) --- tests/mir-opt/const_prop/issue_118328.rs | 20 ----------------- .../const_prop/issue_118328.size_of.ConstProp.diff | 20 ----------------- .../const_prop/overwrite_with_const_with_params.rs | 26 ++++++++++++++++++++++ ...e_with_const_with_params.size_of.ConstProp.diff | 20 +++++++++++++++++ .../const_prop/overwrite_with_const_with_params.rs | 21 +++++++++++++++++ 5 files changed, 67 insertions(+), 40 deletions(-) delete mode 100644 tests/mir-opt/const_prop/issue_118328.rs delete mode 100644 tests/mir-opt/const_prop/issue_118328.size_of.ConstProp.diff create mode 100644 tests/mir-opt/const_prop/overwrite_with_const_with_params.rs create mode 100644 tests/mir-opt/const_prop/overwrite_with_const_with_params.size_of.ConstProp.diff create mode 100644 tests/ui/const_prop/overwrite_with_const_with_params.rs diff --git a/tests/mir-opt/const_prop/issue_118328.rs b/tests/mir-opt/const_prop/issue_118328.rs deleted file mode 100644 index 5072091ddfc..00000000000 --- a/tests/mir-opt/const_prop/issue_118328.rs +++ /dev/null @@ -1,20 +0,0 @@ -// unit-test: ConstProp -// compile-flags: -O -// skip-filecheck -#![allow(unused_assignments)] - -struct SizeOfConst(std::marker::PhantomData); -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; - 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/issue_118328.size_of.ConstProp.diff deleted file mode 100644 index ad8318832d6..00000000000 --- a/tests/mir-opt/const_prop/issue_118328.size_of.ConstProp.diff +++ /dev/null @@ -1,20 +0,0 @@ -- // MIR for `size_of` before ConstProp -+ // MIR for `size_of` after ConstProp - - fn size_of() -> usize { - let mut _0: usize; - let mut _1: usize; - scope 1 { - debug a => _1; - } - - bb0: { - StorageLive(_1); - _1 = const 0_usize; - _1 = const _; - _0 = _1; - StorageDead(_1); - return; - } - } - 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/overwrite_with_const_with_params.size_of.ConstProp.diff b/tests/mir-opt/const_prop/overwrite_with_const_with_params.size_of.ConstProp.diff new file mode 100644 index 00000000000..ad8318832d6 --- /dev/null +++ b/tests/mir-opt/const_prop/overwrite_with_const_with_params.size_of.ConstProp.diff @@ -0,0 +1,20 @@ +- // MIR for `size_of` before ConstProp ++ // MIR for `size_of` after ConstProp + + fn size_of() -> usize { + let mut _0: usize; + let mut _1: usize; + scope 1 { + debug a => _1; + } + + bb0: { + StorageLive(_1); + _1 = const 0_usize; + _1 = const _; + _0 = _1; + StorageDead(_1); + return; + } + } + diff --git a/tests/ui/const_prop/overwrite_with_const_with_params.rs b/tests/ui/const_prop/overwrite_with_const_with_params.rs new file mode 100644 index 00000000000..6f533919a47 --- /dev/null +++ b/tests/ui/const_prop/overwrite_with_const_with_params.rs @@ -0,0 +1,21 @@ +// compile-flags: -O +// run-pass + +// 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::(); +} + +fn size_of() -> usize { + let mut a = 0; + a = SizeOfConst::::SIZE; + a +} + +fn main() { + assert_eq!(size_of::(), std::mem::size_of::()); +} -- cgit 1.4.1-3-g733a5