Skip to content

Commit 2d34b82

Browse files
authored
Rollup merge of rust-lang#142410 - RalfJung:align_of, r=WaffleLapkin,workingjubilee
intrinsics: rename min_align_of to align_of Now that `pref_align_of` is gone (rust-lang#141803), we can give the intrinsic backing `align_of` its proper name. r? `@workingjubilee` or `@bjorn3`
2 parents d430461 + 0cc8ed7 commit 2d34b82

File tree

2 files changed

+10
-18
lines changed

2 files changed

+10
-18
lines changed

core/src/intrinsics/mod.rs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -926,8 +926,7 @@ pub const unsafe fn slice_get_unchecked<
926926
pub fn ptr_mask<T>(ptr: *const T, mask: usize) -> *const T;
927927

928928
/// Equivalent to the appropriate `llvm.memcpy.p0i8.0i8.*` intrinsic, with
929-
/// a size of `count` * `size_of::<T>()` and an alignment of
930-
/// `min_align_of::<T>()`
929+
/// a size of `count` * `size_of::<T>()` and an alignment of `align_of::<T>()`.
931930
///
932931
/// This intrinsic does not have a stable counterpart.
933932
/// # Safety
@@ -941,8 +940,7 @@ pub fn ptr_mask<T>(ptr: *const T, mask: usize) -> *const T;
941940
#[rustc_nounwind]
942941
pub unsafe fn volatile_copy_nonoverlapping_memory<T>(dst: *mut T, src: *const T, count: usize);
943942
/// Equivalent to the appropriate `llvm.memmove.p0i8.0i8.*` intrinsic, with
944-
/// a size of `count * size_of::<T>()` and an alignment of
945-
/// `min_align_of::<T>()`
943+
/// a size of `count * size_of::<T>()` and an alignment of `align_of::<T>()`.
946944
///
947945
/// The volatile parameter is set to `true`, so it will not be optimized out
948946
/// unless size is equal to zero.
@@ -952,8 +950,7 @@ pub unsafe fn volatile_copy_nonoverlapping_memory<T>(dst: *mut T, src: *const T,
952950
#[rustc_nounwind]
953951
pub unsafe fn volatile_copy_memory<T>(dst: *mut T, src: *const T, count: usize);
954952
/// Equivalent to the appropriate `llvm.memset.p0i8.*` intrinsic, with a
955-
/// size of `count * size_of::<T>()` and an alignment of
956-
/// `min_align_of::<T>()`.
953+
/// size of `count * size_of::<T>()` and an alignment of `align_of::<T>()`.
957954
///
958955
/// This intrinsic does not have a stable counterpart.
959956
/// # Safety
@@ -2649,7 +2646,7 @@ pub const fn size_of<T>() -> usize;
26492646
#[unstable(feature = "core_intrinsics", issue = "none")]
26502647
#[rustc_intrinsic_const_stable_indirect]
26512648
#[rustc_intrinsic]
2652-
pub const fn min_align_of<T>() -> usize;
2649+
pub const fn align_of<T>() -> usize;
26532650

26542651
/// Returns the number of variants of the type `T` cast to a `usize`;
26552652
/// if `T` has no variants, returns `0`. Uninhabited variants will be counted.
@@ -2689,7 +2686,7 @@ pub const unsafe fn size_of_val<T: ?Sized>(ptr: *const T) -> usize;
26892686
#[unstable(feature = "core_intrinsics", issue = "none")]
26902687
#[rustc_intrinsic]
26912688
#[rustc_intrinsic_const_stable_indirect]
2692-
pub const unsafe fn min_align_of_val<T: ?Sized>(ptr: *const T) -> usize;
2689+
pub const unsafe fn align_of_val<T: ?Sized>(ptr: *const T) -> usize;
26932690

26942691
/// Gets a static string slice containing the name of a type.
26952692
///

core/src/mem/mod.rs

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,7 @@ pub const unsafe fn size_of_val_raw<T: ?Sized>(val: *const T) -> usize {
412412
#[stable(feature = "rust1", since = "1.0.0")]
413413
#[deprecated(note = "use `align_of` instead", since = "1.2.0", suggestion = "align_of")]
414414
pub fn min_align_of<T>() -> usize {
415-
intrinsics::min_align_of::<T>()
415+
intrinsics::align_of::<T>()
416416
}
417417

418418
/// Returns the [ABI]-required minimum alignment of the type of the value that `val` points to in
@@ -436,7 +436,7 @@ pub fn min_align_of<T>() -> usize {
436436
#[deprecated(note = "use `align_of_val` instead", since = "1.2.0", suggestion = "align_of_val")]
437437
pub fn min_align_of_val<T: ?Sized>(val: &T) -> usize {
438438
// SAFETY: val is a reference, so it's a valid raw pointer
439-
unsafe { intrinsics::min_align_of_val(val) }
439+
unsafe { intrinsics::align_of_val(val) }
440440
}
441441

442442
/// Returns the [ABI]-required minimum alignment of a type in bytes.
@@ -458,7 +458,7 @@ pub fn min_align_of_val<T: ?Sized>(val: &T) -> usize {
458458
#[rustc_promotable]
459459
#[rustc_const_stable(feature = "const_align_of", since = "1.24.0")]
460460
pub const fn align_of<T>() -> usize {
461-
intrinsics::min_align_of::<T>()
461+
intrinsics::align_of::<T>()
462462
}
463463

464464
/// Returns the [ABI]-required minimum alignment of the type of the value that `val` points to in
@@ -477,10 +477,9 @@ pub const fn align_of<T>() -> usize {
477477
#[must_use]
478478
#[stable(feature = "rust1", since = "1.0.0")]
479479
#[rustc_const_stable(feature = "const_align_of_val", since = "1.85.0")]
480-
#[allow(deprecated)]
481480
pub const fn align_of_val<T: ?Sized>(val: &T) -> usize {
482481
// SAFETY: val is a reference, so it's a valid raw pointer
483-
unsafe { intrinsics::min_align_of_val(val) }
482+
unsafe { intrinsics::align_of_val(val) }
484483
}
485484

486485
/// Returns the [ABI]-required minimum alignment of the type of the value that `val` points to in
@@ -527,7 +526,7 @@ pub const fn align_of_val<T: ?Sized>(val: &T) -> usize {
527526
#[unstable(feature = "layout_for_ptr", issue = "69835")]
528527
pub const unsafe fn align_of_val_raw<T: ?Sized>(val: *const T) -> usize {
529528
// SAFETY: the caller must provide a valid raw pointer
530-
unsafe { intrinsics::min_align_of_val(val) }
529+
unsafe { intrinsics::align_of_val(val) }
531530
}
532531

533532
/// Returns `true` if dropping values of type `T` matters.
@@ -637,8 +636,6 @@ pub const fn needs_drop<T: ?Sized>() -> bool {
637636
#[inline(always)]
638637
#[must_use]
639638
#[stable(feature = "rust1", since = "1.0.0")]
640-
#[allow(deprecated_in_future)]
641-
#[allow(deprecated)]
642639
#[rustc_diagnostic_item = "mem_zeroed"]
643640
#[track_caller]
644641
#[rustc_const_stable(feature = "const_mem_zeroed", since = "1.75.0")]
@@ -677,8 +674,6 @@ pub const unsafe fn zeroed<T>() -> T {
677674
#[must_use]
678675
#[deprecated(since = "1.39.0", note = "use `mem::MaybeUninit` instead")]
679676
#[stable(feature = "rust1", since = "1.0.0")]
680-
#[allow(deprecated_in_future)]
681-
#[allow(deprecated)]
682677
#[rustc_diagnostic_item = "mem_uninitialized"]
683678
#[track_caller]
684679
pub unsafe fn uninitialized<T>() -> T {

0 commit comments

Comments
 (0)