File tree 1 file changed +5
-1
lines changed
1 file changed +5
-1
lines changed Original file line number Diff line number Diff line change 2
2
3
3
#![ feature( const_size_of_val, const_align_of_val) ]
4
4
#![ feature( const_size_of_val_raw, const_align_of_val_raw, layout_for_ptr) ]
5
+ #![ feature( const_slice_from_raw_parts) ]
5
6
6
- use std:: mem;
7
+ use std:: { mem, ptr } ;
7
8
8
9
struct Foo ( u32 ) ;
9
10
@@ -34,6 +35,8 @@ const ALIGN_OF_UGH: usize = mem::align_of_val(&UGH);
34
35
const SIZE_OF_SLICE : usize = mem:: size_of_val ( "foobar" . as_bytes ( ) ) ;
35
36
36
37
const 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 ) ) } ;
37
40
const ALIGN_OF_DANGLING : usize = unsafe { mem:: align_of_val_raw ( 0x100 as * const i16 ) } ;
38
41
39
42
fn main ( ) {
@@ -46,6 +49,7 @@ fn main() {
46
49
assert_eq ! ( ALIGN_OF_UGH , mem:: align_of:: <Ugh >( ) ) ;
47
50
48
51
assert_eq ! ( SIZE_OF_DANGLING , mem:: size_of:: <i32 >( ) ) ;
52
+ assert_eq ! ( SIZE_OF_BIG , isize :: MAX as usize ) ;
49
53
assert_eq ! ( ALIGN_OF_DANGLING , mem:: align_of:: <i16 >( ) ) ;
50
54
51
55
assert_eq ! ( SIZE_OF_SLICE , "foobar" . len( ) ) ;
You can’t perform that action at this time.
0 commit comments