@@ -450,7 +450,7 @@ pub const unsafe fn size_of_val_raw<T: ?Sized>(val: *const T) -> usize {
450450#[ stable( feature = "rust1" , since = "1.0.0" ) ]
451451#[ deprecated( note = "use `align_of` instead" , since = "1.2.0" , suggestion = "align_of" ) ]
452452pub fn min_align_of < T > ( ) -> usize {
453- < T as SizedTypeProperties > :: ALIGN
453+ align_of :: < T > ( )
454454}
455455
456456/// Returns the [ABI]-required minimum alignment of the type of the value that `val` points to in
@@ -473,8 +473,7 @@ pub fn min_align_of<T>() -> usize {
473473#[ stable( feature = "rust1" , since = "1.0.0" ) ]
474474#[ deprecated( note = "use `align_of_val` instead" , since = "1.2.0" , suggestion = "align_of_val" ) ]
475475pub fn min_align_of_val < T : ?Sized > ( val : & T ) -> usize {
476- // SAFETY: val is a reference, so it's a valid raw pointer
477- unsafe { intrinsics:: align_of_val ( val) }
476+ align_of_val ( val)
478477}
479478
480479/// Returns the [ABI]-required minimum alignment of a type in bytes.
@@ -497,7 +496,7 @@ pub fn min_align_of_val<T: ?Sized>(val: &T) -> usize {
497496#[ rustc_const_stable( feature = "const_align_of" , since = "1.24.0" ) ]
498497#[ rustc_diagnostic_item = "mem_align_of" ]
499498pub const fn align_of < T > ( ) -> usize {
500- < T as SizedTypeProperties > :: ALIGN
499+ Alignment :: of :: < T > ( ) . as_usize ( )
501500}
502501
503502/// Returns the [ABI]-required minimum alignment of the type of the value that `val` points to in
@@ -517,8 +516,7 @@ pub const fn align_of<T>() -> usize {
517516#[ stable( feature = "rust1" , since = "1.0.0" ) ]
518517#[ rustc_const_stable( feature = "const_align_of_val" , since = "1.85.0" ) ]
519518pub const fn align_of_val < T : ?Sized > ( val : & T ) -> usize {
520- // SAFETY: val is a reference, so it's a valid raw pointer
521- unsafe { intrinsics:: align_of_val ( val) }
519+ Alignment :: of_val ( val) . as_usize ( )
522520}
523521
524522/// Returns the [ABI]-required minimum alignment of the type of the value that `val` points to in
@@ -565,7 +563,7 @@ pub const fn align_of_val<T: ?Sized>(val: &T) -> usize {
565563#[ unstable( feature = "layout_for_ptr" , issue = "69835" ) ]
566564pub const unsafe fn align_of_val_raw < T : ?Sized > ( val : * const T ) -> usize {
567565 // SAFETY: the caller must provide a valid raw pointer
568- unsafe { intrinsics :: align_of_val ( val) }
566+ unsafe { Alignment :: of_val_raw ( val) } . as_usize ( )
569567}
570568
571569/// Returns `true` if dropping values of type `T` matters.
@@ -1256,14 +1254,8 @@ pub trait SizedTypeProperties: Sized {
12561254 #[ doc( hidden) ]
12571255 #[ unstable( feature = "sized_type_properties" , issue = "none" ) ]
12581256 #[ lang = "mem_align_const" ]
1259- const ALIGN : usize = intrinsics:: align_of :: < Self > ( ) ;
1260-
1261- #[ doc( hidden) ]
1262- #[ unstable( feature = "ptr_alignment_type" , issue = "102070" ) ]
1263- const ALIGNMENT : Alignment = {
1264- // This can't panic since type alignment is always a power of two.
1265- Alignment :: new ( Self :: ALIGN ) . unwrap ( )
1266- } ;
1257+ // #[unstable(feature = "ptr_alignment_type", issue = "102070")]
1258+ const ALIGNMENT : Alignment = intrinsics:: align_of :: < Self > ( ) ;
12671259
12681260 /// `true` if this type requires no storage.
12691261 /// `false` if its [size](size_of) is greater than zero.
@@ -1300,7 +1292,7 @@ pub trait SizedTypeProperties: Sized {
13001292 // SAFETY: if the type is instantiated, rustc already ensures that its
13011293 // layout is valid. Use the unchecked constructor to avoid inserting a
13021294 // panicking codepath that needs to be optimized out.
1303- unsafe { Layout :: from_size_align_unchecked ( Self :: SIZE , Self :: ALIGN ) }
1295+ unsafe { Layout :: from_size_alignment_unchecked ( Self :: SIZE , Self :: ALIGNMENT ) }
13041296 } ;
13051297
13061298 /// The largest safe length for a `[Self]`.
0 commit comments