This repository was archived by the owner on May 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +11
-2
lines changed Expand file tree Collapse file tree 2 files changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -374,7 +374,8 @@ pub const fn size_of_val<T: ?Sized>(val: &T) -> usize {
374374/// ```
375375#[ inline]
376376#[ unstable( feature = "layout_for_ptr" , issue = "69835" ) ]
377- pub unsafe fn size_of_val_raw < T : ?Sized > ( val : * const T ) -> usize {
377+ #[ rustc_const_unstable( feature = "const_size_of_val_raw" , issue = "46571" ) ]
378+ pub const unsafe fn size_of_val_raw < T : ?Sized > ( val : * const T ) -> usize {
378379 intrinsics:: size_of_val ( val)
379380}
380381
@@ -505,7 +506,8 @@ pub const fn align_of_val<T: ?Sized>(val: &T) -> usize {
505506/// ```
506507#[ inline]
507508#[ unstable( feature = "layout_for_ptr" , issue = "69835" ) ]
508- pub unsafe fn align_of_val_raw < T : ?Sized > ( val : * const T ) -> usize {
509+ #[ rustc_const_unstable( feature = "const_align_of_val_raw" , issue = "46571" ) ]
510+ pub const unsafe fn align_of_val_raw < T : ?Sized > ( val : * const T ) -> usize {
509511 intrinsics:: min_align_of_val ( val)
510512}
511513
Original file line number Diff line number Diff line change 11// run-pass
22
33#![ feature( const_size_of_val, const_align_of_val) ]
4+ #![ feature( const_size_of_val_raw, const_align_of_val_raw, layout_for_ptr) ]
45
56use std:: mem;
67
@@ -32,6 +33,9 @@ const ALIGN_OF_UGH: usize = mem::align_of_val(&UGH);
3233
3334const SIZE_OF_SLICE : usize = mem:: size_of_val ( "foobar" . as_bytes ( ) ) ;
3435
36+ const SIZE_OF_DANGLING : usize = unsafe { mem:: size_of_val_raw ( 0x100 as * const i32 ) } ;
37+ const ALIGN_OF_DANGLING : usize = unsafe { mem:: align_of_val_raw ( 0x100 as * const i16 ) } ;
38+
3539fn main ( ) {
3640 assert_eq ! ( SIZE_OF_FOO , mem:: size_of:: <Foo >( ) ) ;
3741 assert_eq ! ( SIZE_OF_BAR , mem:: size_of:: <Bar >( ) ) ;
@@ -41,5 +45,8 @@ fn main() {
4145 assert_eq ! ( ALIGN_OF_BAR , mem:: align_of:: <Bar >( ) ) ;
4246 assert_eq ! ( ALIGN_OF_UGH , mem:: align_of:: <Ugh >( ) ) ;
4347
48+ assert_eq ! ( SIZE_OF_DANGLING , mem:: size_of:: <i32 >( ) ) ;
49+ assert_eq ! ( ALIGN_OF_DANGLING , mem:: align_of:: <i16 >( ) ) ;
50+
4451 assert_eq ! ( SIZE_OF_SLICE , "foobar" . len( ) ) ;
4552}
You can’t perform that action at this time.
0 commit comments