File tree 3 files changed +7
-1
lines changed
3 files changed +7
-1
lines changed Original file line number Diff line number Diff line change @@ -65,6 +65,7 @@ impl Layout {
65
65
#[ stable( feature = "alloc_layout" , since = "1.28.0" ) ]
66
66
#[ rustc_const_stable( feature = "const_alloc_layout_size_align" , since = "1.50.0" ) ]
67
67
#[ inline]
68
+ #[ rustc_allow_const_fn_unstable( ptr_alignment_type) ]
68
69
pub const fn from_size_align ( size : usize , align : usize ) -> Result < Self , LayoutError > {
69
70
if !align. is_power_of_two ( ) {
70
71
return Err ( LayoutError ) ;
@@ -114,6 +115,7 @@ impl Layout {
114
115
#[ rustc_const_stable( feature = "const_alloc_layout_unchecked" , since = "1.36.0" ) ]
115
116
#[ must_use]
116
117
#[ inline]
118
+ #[ rustc_allow_const_fn_unstable( ptr_alignment_type) ]
117
119
pub const unsafe fn from_size_align_unchecked ( size : usize , align : usize ) -> Self {
118
120
// SAFETY: the caller is required to uphold the preconditions.
119
121
unsafe { Layout { size, align : ValidAlign :: new_unchecked ( align) } }
@@ -134,6 +136,7 @@ impl Layout {
134
136
#[ must_use = "this returns the minimum alignment, \
135
137
without modifying the layout"]
136
138
#[ inline]
139
+ #[ rustc_allow_const_fn_unstable( ptr_alignment_type) ]
137
140
pub const fn align ( & self ) -> usize {
138
141
self . align . as_usize ( )
139
142
}
Original file line number Diff line number Diff line change 148
148
#![ feature( core_panic) ]
149
149
#![ feature( duration_consts_float) ]
150
150
#![ feature( maybe_uninit_uninit_array) ]
151
+ #![ feature( ptr_alignment_type) ]
151
152
#![ feature( ptr_metadata) ]
152
153
#![ feature( slice_ptr_get) ]
153
154
#![ feature( slice_split_at_unchecked) ]
Original file line number Diff line number Diff line change @@ -24,7 +24,7 @@ impl Alignment {
24
24
/// but in an `Alignment` instead of a `usize.
25
25
#[ unstable( feature = "ptr_alignment_type" , issue = "102070" ) ]
26
26
#[ inline]
27
- pub ( crate ) fn of < T > ( ) -> Self {
27
+ pub const fn of < T > ( ) -> Self {
28
28
// SAFETY: rustc ensures that type alignment is always a power of two.
29
29
unsafe { Alignment :: new_unchecked ( mem:: align_of :: < T > ( ) ) }
30
30
}
@@ -53,6 +53,7 @@ impl Alignment {
53
53
/// Equivalently, it must be `1 << exp` for some `exp` in `0..usize::BITS`.
54
54
/// It must *not* be zero.
55
55
#[ unstable( feature = "ptr_alignment_type" , issue = "102070" ) ]
56
+ #[ rustc_const_unstable( feature = "ptr_alignment_type" , issue = "102070" ) ]
56
57
#[ inline]
57
58
pub const unsafe fn new_unchecked ( align : usize ) -> Self {
58
59
// SAFETY: Precondition passed to the caller.
@@ -65,6 +66,7 @@ impl Alignment {
65
66
66
67
/// Returns the alignment as a [`NonZeroUsize`]
67
68
#[ unstable( feature = "ptr_alignment_type" , issue = "102070" ) ]
69
+ #[ rustc_const_unstable( feature = "ptr_alignment_type" , issue = "102070" ) ]
68
70
#[ inline]
69
71
pub const fn as_usize ( self ) -> usize {
70
72
self . 0 as usize
You can’t perform that action at this time.
0 commit comments