File tree 2 files changed +41
-0
lines changed
2 files changed +41
-0
lines changed Original file line number Diff line number Diff line change
1
+ // unit-test: ConstProp
2
+ // compile-flags: -O
3
+ // skip-filecheck
4
+ #![ allow( unused_assignments) ]
5
+
6
+ struct SizeOfConst < T > ( std:: marker:: PhantomData < T > ) ;
7
+ impl < T > SizeOfConst < T > {
8
+ const SIZE : usize = std:: mem:: size_of :: < T > ( ) ;
9
+ }
10
+
11
+ // EMIT_MIR issue_118328.size_of.ConstProp.diff
12
+ fn size_of < T > ( ) -> usize {
13
+ let mut a = 0 ;
14
+ a = SizeOfConst :: < T > :: SIZE ;
15
+ a
16
+ }
17
+
18
+ fn main ( ) {
19
+ assert_eq ! ( size_of:: <u32 >( ) , std:: mem:: size_of:: <u32 >( ) ) ;
20
+ }
Original file line number Diff line number Diff line change
1
+ - // MIR for `size_of` before ConstProp
2
+ + // MIR for `size_of` after ConstProp
3
+
4
+ fn size_of() -> usize {
5
+ let mut _0: usize;
6
+ let mut _1: usize;
7
+ scope 1 {
8
+ debug a => _1;
9
+ }
10
+
11
+ bb0: {
12
+ StorageLive(_1);
13
+ _1 = const 0_usize;
14
+ _1 = const _;
15
+ - _0 = _1;
16
+ + _0 = const 0_usize;
17
+ StorageDead(_1);
18
+ return;
19
+ }
20
+ }
21
+
You can’t perform that action at this time.
0 commit comments