-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
46a24ed
commit b1a6cf4
Showing
2 changed files
with
41 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// unit-test: ConstProp | ||
// compile-flags: -O | ||
// skip-filecheck | ||
#![allow(unused_assignments)] | ||
|
||
struct SizeOfConst<T>(std::marker::PhantomData<T>); | ||
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; | ||
a | ||
} | ||
|
||
fn main() { | ||
assert_eq!(size_of::<u32>(), std::mem::size_of::<u32>()); | ||
} |
21 changes: 21 additions & 0 deletions
21
tests/mir-opt/const_prop/issue_118328.size_of.ConstProp.diff
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
} | ||
|