File tree 2 files changed +11
-2
lines changed
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 {
374
374
/// ```
375
375
#[ inline]
376
376
#[ 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 {
378
379
intrinsics:: size_of_val ( val)
379
380
}
380
381
@@ -505,7 +506,8 @@ pub const fn align_of_val<T: ?Sized>(val: &T) -> usize {
505
506
/// ```
506
507
#[ inline]
507
508
#[ 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 {
509
511
intrinsics:: min_align_of_val ( val)
510
512
}
511
513
Original file line number Diff line number Diff line change 1
1
// run-pass
2
2
3
3
#![ feature( const_size_of_val, const_align_of_val) ]
4
+ #![ feature( const_size_of_val_raw, const_align_of_val_raw, layout_for_ptr) ]
4
5
5
6
use std:: mem;
6
7
@@ -32,6 +33,9 @@ const ALIGN_OF_UGH: usize = mem::align_of_val(&UGH);
32
33
33
34
const SIZE_OF_SLICE : usize = mem:: size_of_val ( "foobar" . as_bytes ( ) ) ;
34
35
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
+
35
39
fn main ( ) {
36
40
assert_eq ! ( SIZE_OF_FOO , mem:: size_of:: <Foo >( ) ) ;
37
41
assert_eq ! ( SIZE_OF_BAR , mem:: size_of:: <Bar >( ) ) ;
@@ -41,5 +45,8 @@ fn main() {
41
45
assert_eq ! ( ALIGN_OF_BAR , mem:: align_of:: <Bar >( ) ) ;
42
46
assert_eq ! ( ALIGN_OF_UGH , mem:: align_of:: <Ugh >( ) ) ;
43
47
48
+ assert_eq ! ( SIZE_OF_DANGLING , mem:: size_of:: <i32 >( ) ) ;
49
+ assert_eq ! ( ALIGN_OF_DANGLING , mem:: align_of:: <i16 >( ) ) ;
50
+
44
51
assert_eq ! ( SIZE_OF_SLICE , "foobar" . len( ) ) ;
45
52
}
You can’t perform that action at this time.
0 commit comments