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 5
5
#![ feature( bigint_helper_methods) ]
6
6
#![ feature( cell_update) ]
7
7
#![ feature( const_assume) ]
8
+ #![ feature( const_align_of_val_raw) ]
8
9
#![ feature( const_black_box) ]
9
10
#![ feature( const_bool_to_option) ]
10
11
#![ feature( const_caller_location) ]
42
43
#![ feature( try_find) ]
43
44
#![ feature( inline_const) ]
44
45
#![ feature( is_sorted) ]
46
+ #![ feature( layout_for_ptr) ]
45
47
#![ feature( pattern) ]
46
48
#![ feature( pin_macro) ]
47
49
#![ feature( sort_internals) ]
Original file line number Diff line number Diff line change 1
1
use core:: mem:: * ;
2
+ use core:: ptr;
2
3
3
4
#[ cfg( panic = "unwind" ) ]
4
5
use std:: rc:: Rc ;
@@ -75,6 +76,25 @@ fn align_of_val_basic() {
75
76
assert_eq ! ( align_of_val( & 1u32 ) , 4 ) ;
76
77
}
77
78
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
+
78
98
#[ test]
79
99
fn test_swap ( ) {
80
100
let mut x = 31337 ;
You can’t perform that action at this time.
0 commit comments