Skip to content

Commit

Permalink
Rename and add another test
Browse files Browse the repository at this point in the history
  • Loading branch information
aDotInTheVoid committed Nov 28, 2023
1 parent 9121a41 commit 4f310a3
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
23 changes: 23 additions & 0 deletions tests/mir-opt/const_prop/overwrite_with_const_with_params.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// unit-test: ConstProp
// compile-flags: -O
// skip-filecheck

// 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 {
let mut a = 0;
a = SizeOfConst::<T>::SIZE;
a
}

fn main() {
assert_eq!(size_of::<u32>(), std::mem::size_of::<u32>());
}
Original file line number Diff line number Diff line change
@@ -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>);
Expand Down

0 comments on commit 4f310a3

Please sign in to comment.