diff options
| author | Alona Enraght-Moony <code@alona.page> | 2023-11-28 22:31:53 +0000 |
|---|---|---|
| committer | Alona Enraght-Moony <code@alona.page> | 2023-11-28 23:17:28 +0000 |
| commit | 6e956c0a383444a25cc0e690cbc9fa6f859b07b4 (patch) | |
| tree | a8d306ffdd35979b422d659745f3faccdc92b267 | |
| parent | 9121a41450e905fe5a12c11c955acc14ab1f92fe (diff) | |
| download | rust-6e956c0a383444a25cc0e690cbc9fa6f859b07b4.tar.gz rust-6e956c0a383444a25cc0e690cbc9fa6f859b07b4.zip | |
Rename and add another test
| -rw-r--r-- | tests/mir-opt/const_prop/overwrite_with_const_with_params.rs | 26 | ||||
| -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; |
