@@ -7,17 +7,20 @@ enum E {
7
7
Some ( & ' static ( ) , & ' static ( ) , usize ) ,
8
8
}
9
9
10
- fn main ( ) { unsafe {
11
- let mut p: mem:: MaybeUninit < E > = mem:: MaybeUninit :: zeroed ( ) ;
12
- // The copy when `E` is returned from `transmute` should destroy padding
13
- // (even when we use `write_unaligned`, which under the hood uses an untyped copy).
14
- p. as_mut_ptr ( ) . write_unaligned ( mem:: transmute ( ( 0usize , 0usize , 0usize ) ) ) ;
15
- // This is a `None`, so everything but the discriminant is padding.
16
- assert ! ( matches!( * p. as_ptr( ) , E :: None ) ) ;
10
+ fn main ( ) {
11
+ unsafe {
12
+ let mut p: mem:: MaybeUninit < E > = mem:: MaybeUninit :: zeroed ( ) ;
13
+ // The copy when `E` is returned from `transmute` should destroy padding
14
+ // (even when we use `write_unaligned`, which under the hood uses an untyped copy).
15
+ p. as_mut_ptr ( ) . write_unaligned ( mem:: transmute ( ( 0usize , 0usize , 0usize ) ) ) ;
16
+ // This is a `None`, so everything but the discriminant is padding.
17
+ assert ! ( matches!( * p. as_ptr( ) , E :: None ) ) ;
17
18
18
- // Turns out the discriminant is (currently) stored
19
- // in the 2nd pointer, so the first half is padding.
20
- let c = & p as * const _ as * const u8 ;
21
- let _val = * c. add ( 0 ) ; // Get a padding byte.
22
- //~^ERROR: uninitialized
23
- } }
19
+ // Turns out the discriminant is (currently) stored
20
+ // in the 2nd pointer, so the first half is padding.
21
+ let c = & p as * const _ as * const u8 ;
22
+ // Read a padding byte.
23
+ let _val = * c. add ( 0 ) ;
24
+ //~^ERROR: uninitialized
25
+ }
26
+ }
0 commit comments