File tree Expand file tree Collapse file tree 1 file changed +5
-1
lines changed Expand file tree Collapse file tree 1 file changed +5
-1
lines changed Original file line number Diff line number Diff line change 22
33#![ feature( const_size_of_val, const_align_of_val) ]
44#![ feature( const_size_of_val_raw, const_align_of_val_raw, layout_for_ptr) ]
5+ #![ feature( const_slice_from_raw_parts) ]
56
6- use std:: mem;
7+ use std:: { mem, ptr } ;
78
89struct Foo ( u32 ) ;
910
@@ -34,6 +35,8 @@ const ALIGN_OF_UGH: usize = mem::align_of_val(&UGH);
3435const SIZE_OF_SLICE : usize = mem:: size_of_val ( "foobar" . as_bytes ( ) ) ;
3536
3637const SIZE_OF_DANGLING : usize = unsafe { mem:: size_of_val_raw ( 0x100 as * const i32 ) } ;
38+ const SIZE_OF_BIG : usize =
39+ unsafe { mem:: size_of_val_raw ( ptr:: slice_from_raw_parts ( 0 as * const u8 , isize:: MAX as usize ) ) } ;
3740const ALIGN_OF_DANGLING : usize = unsafe { mem:: align_of_val_raw ( 0x100 as * const i16 ) } ;
3841
3942fn main ( ) {
@@ -46,6 +49,7 @@ fn main() {
4649 assert_eq ! ( ALIGN_OF_UGH , mem:: align_of:: <Ugh >( ) ) ;
4750
4851 assert_eq ! ( SIZE_OF_DANGLING , mem:: size_of:: <i32 >( ) ) ;
52+ assert_eq ! ( SIZE_OF_BIG , isize :: MAX as usize ) ;
4953 assert_eq ! ( ALIGN_OF_DANGLING , mem:: align_of:: <i16 >( ) ) ;
5054
5155 assert_eq ! ( SIZE_OF_SLICE , "foobar" . len( ) ) ;
You can’t perform that action at this time.
0 commit comments