From b1a6cf4a0e7d6727516e943d86fdab8587b94722 Mon Sep 17 00:00:00 2001 From: Alona Enraght-Moony Date: Tue, 28 Nov 2023 15:12:46 +0000 Subject: [PATCH] Precommit test for https://github.com/rust-lang/rust/issues/118328. --- tests/mir-opt/const_prop/issue_118328.rs | 20 ++++++++++++++++++ .../issue_118328.size_of.ConstProp.diff | 21 +++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 tests/mir-opt/const_prop/issue_118328.rs create mode 100644 tests/mir-opt/const_prop/issue_118328.size_of.ConstProp.diff diff --git a/tests/mir-opt/const_prop/issue_118328.rs b/tests/mir-opt/const_prop/issue_118328.rs new file mode 100644 index 00000000000..5072091ddfc --- /dev/null +++ b/tests/mir-opt/const_prop/issue_118328.rs @@ -0,0 +1,20 @@ +// 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 new file mode 100644 index 00000000000..0f44c49bc4d --- /dev/null +++ b/tests/mir-opt/const_prop/issue_118328.size_of.ConstProp.diff @@ -0,0 +1,21 @@ +- // 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; ++ _0 = const 0_usize; + StorageDead(_1); + return; + } + } +