File tree Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Original file line number Diff line number Diff line change 55#![ feature( bigint_helper_methods) ]
66#![ feature( cell_update) ]
77#![ feature( const_assume) ]
8+ #![ feature( const_align_of_val_raw) ]
89#![ feature( const_black_box) ]
910#![ feature( const_bool_to_option) ]
1011#![ feature( const_caller_location) ]
4243#![ feature( try_find) ]
4344#![ feature( inline_const) ]
4445#![ feature( is_sorted) ]
46+ #![ feature( layout_for_ptr) ]
4547#![ feature( pattern) ]
4648#![ feature( pin_macro) ]
4749#![ feature( sort_internals) ]
Original file line number Diff line number Diff line change 11use core:: mem:: * ;
2+ use core:: ptr;
23
34#[ cfg( panic = "unwind" ) ]
45use std:: rc:: Rc ;
@@ -75,6 +76,25 @@ fn align_of_val_basic() {
7576 assert_eq ! ( align_of_val( & 1u32 ) , 4 ) ;
7677}
7778
79+ #[ test]
80+ #[ cfg( not( bootstrap) ) ] // stage 0 doesn't have the fix yet, so the test fails
81+ fn align_of_val_raw_packed ( ) {
82+ #[ repr( C , packed) ]
83+ struct B {
84+ f : [ u32 ] ,
85+ }
86+ let storage = [ 0u8 ; 4 ] ;
87+ let b: * const B = ptr:: from_raw_parts ( storage. as_ptr ( ) . cast ( ) , 1 ) ;
88+ assert_eq ! ( unsafe { align_of_val_raw( b) } , 1 ) ;
89+
90+ const ALIGN_OF_VAL_RAW : usize = {
91+ let storage = [ 0u8 ; 4 ] ;
92+ let b: * const B = ptr:: from_raw_parts ( storage. as_ptr ( ) . cast ( ) , 1 ) ;
93+ unsafe { align_of_val_raw ( b) }
94+ } ;
95+ assert_eq ! ( ALIGN_OF_VAL_RAW , 1 ) ;
96+ }
97+
7898#[ test]
7999fn test_swap ( ) {
80100 let mut x = 31337 ;
You can’t perform that action at this time.
0 commit comments