Skip to content

Commit e787d06

Browse files
committed
intrinsics: rename min_align_of to align_of
1 parent fd50e10 commit e787d06

File tree

15 files changed

+33
-47
lines changed

15 files changed

+33
-47
lines changed

compiler/rustc_codegen_cranelift/example/mini_core.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -644,9 +644,9 @@ pub mod intrinsics {
644644
#[rustc_intrinsic]
645645
pub unsafe fn size_of_val<T: ?::Sized>(val: *const T) -> usize;
646646
#[rustc_intrinsic]
647-
pub fn min_align_of<T>() -> usize;
647+
pub fn align_of<T>() -> usize;
648648
#[rustc_intrinsic]
649-
pub unsafe fn min_align_of_val<T: ?::Sized>(val: *const T) -> usize;
649+
pub unsafe fn align_of_val<T: ?::Sized>(val: *const T) -> usize;
650650
#[rustc_intrinsic]
651651
pub unsafe fn copy<T>(src: *const T, dst: *mut T, count: usize);
652652
#[rustc_intrinsic]

compiler/rustc_codegen_cranelift/example/mini_core_hello_world.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -204,11 +204,8 @@ fn main() {
204204
assert_eq!(intrinsics::size_of_val(a) as u8, 16);
205205
assert_eq!(intrinsics::size_of_val(&0u32) as u8, 4);
206206

207-
assert_eq!(intrinsics::min_align_of::<u16>() as u8, 2);
208-
assert_eq!(
209-
intrinsics::min_align_of_val(&a) as u8,
210-
intrinsics::min_align_of::<&str>() as u8
211-
);
207+
assert_eq!(intrinsics::align_of::<u16>() as u8, 2);
208+
assert_eq!(intrinsics::align_of_val(&a) as u8, intrinsics::align_of::<&str>() as u8);
212209

213210
assert!(!intrinsics::needs_drop::<u8>());
214211
assert!(!intrinsics::needs_drop::<[u8]>());

compiler/rustc_codegen_cranelift/src/intrinsics/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -586,7 +586,7 @@ fn codegen_regular_intrinsic_call<'tcx>(
586586
let (size, _align) = crate::unsize::size_and_align_of(fx, layout, meta);
587587
ret.write_cvalue(fx, CValue::by_val(size, usize_layout));
588588
}
589-
sym::min_align_of_val => {
589+
sym::align_of_val => {
590590
intrinsic_args!(fx, args => (ptr); intrinsic);
591591

592592
let layout = fx.layout_of(generic_args.type_at(0));
@@ -613,7 +613,7 @@ fn codegen_regular_intrinsic_call<'tcx>(
613613
intrinsic_args!(fx, args => (vtable); intrinsic);
614614
let vtable = vtable.load_scalar(fx);
615615

616-
let align = crate::vtable::min_align_of_obj(fx, vtable);
616+
let align = crate::vtable::align_of_obj(fx, vtable);
617617
ret.write_cvalue(fx, CValue::by_val(align, usize_layout));
618618
}
619619

compiler/rustc_codegen_cranelift/src/unsize.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ pub(crate) fn size_and_align_of<'tcx>(
212212
// load size/align from vtable
213213
(
214214
crate::vtable::size_of_obj(fx, info.unwrap()),
215-
crate::vtable::min_align_of_obj(fx, info.unwrap()),
215+
crate::vtable::align_of_obj(fx, info.unwrap()),
216216
)
217217
}
218218
ty::Slice(_) | ty::Str => {

compiler/rustc_codegen_cranelift/src/vtable.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ pub(crate) fn size_of_obj(fx: &mut FunctionCx<'_, '_, '_>, vtable: Value) -> Val
3131
)
3232
}
3333

34-
pub(crate) fn min_align_of_obj(fx: &mut FunctionCx<'_, '_, '_>, vtable: Value) -> Value {
34+
pub(crate) fn align_of_obj(fx: &mut FunctionCx<'_, '_, '_>, vtable: Value) -> Value {
3535
let usize_size = fx.layout_of(fx.tcx.types.usize).size.bytes() as usize;
3636
fx.bcx.ins().load(
3737
fx.pointer_type,

compiler/rustc_codegen_gcc/example/mini_core.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -655,9 +655,9 @@ pub mod intrinsics {
655655
#[rustc_intrinsic]
656656
pub unsafe fn size_of_val<T: ?::Sized>(val: *const T) -> usize;
657657
#[rustc_intrinsic]
658-
pub fn min_align_of<T>() -> usize;
658+
pub fn align_of<T>() -> usize;
659659
#[rustc_intrinsic]
660-
pub unsafe fn min_align_of_val<T: ?::Sized>(val: *const T) -> usize;
660+
pub unsafe fn align_of_val<T: ?::Sized>(val: *const T) -> usize;
661661
#[rustc_intrinsic]
662662
pub unsafe fn copy<T>(src: *const T, dst: *mut T, count: usize);
663663
#[rustc_intrinsic]

compiler/rustc_codegen_gcc/example/mini_core_hello_world.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ fn main() {
153153
let slice = &[0, 1] as &[i32];
154154
let slice_ptr = slice as *const [i32] as *const i32;
155155

156-
let align = intrinsics::min_align_of::<*const i32>();
156+
let align = intrinsics::align_of::<*const i32>();
157157
assert_eq!(slice_ptr as usize % align, 0);
158158

159159
//return;
@@ -194,8 +194,8 @@ fn main() {
194194
assert_eq!(intrinsics::size_of_val(a) as u8, 8);
195195
assert_eq!(intrinsics::size_of_val(&0u32) as u8, 4);
196196

197-
assert_eq!(intrinsics::min_align_of::<u16>() as u8, 2);
198-
assert_eq!(intrinsics::min_align_of_val(&a) as u8, intrinsics::min_align_of::<&str>() as u8);
197+
assert_eq!(intrinsics::align_of::<u16>() as u8, 2);
198+
assert_eq!(intrinsics::align_of_val(&a) as u8, intrinsics::align_of::<&str>() as u8);
199199

200200
assert!(!intrinsics::needs_drop::<u8>());
201201
assert!(!intrinsics::needs_drop::<[u8]>());

compiler/rustc_codegen_ssa/src/mir/intrinsic.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
118118
let (llsize, _) = size_of_val::size_and_align_of_dst(bx, tp_ty, meta);
119119
llsize
120120
}
121-
sym::min_align_of_val => {
121+
sym::align_of_val => {
122122
let tp_ty = fn_args.type_at(0);
123123
let (_, meta) = args[0].val.pointer_parts();
124124
let (_, llalign) = size_of_val::size_and_align_of_dst(bx, tp_ty, meta);

compiler/rustc_const_eval/src/interpret/intrinsics.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
120120
self.copy_op(&val, dest)?;
121121
}
122122

123-
sym::min_align_of_val | sym::size_of_val => {
123+
sym::align_of_val | sym::size_of_val => {
124124
// Avoid `deref_pointer` -- this is not a deref, the ptr does not have to be
125125
// dereferenceable!
126126
let place = self.ref_to_mplace(&self.read_immediate(&args[0])?)?;
@@ -129,7 +129,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
129129
.ok_or_else(|| err_unsup_format!("`extern type` does not have known layout"))?;
130130

131131
let result = match intrinsic_name {
132-
sym::min_align_of_val => align.bytes(),
132+
sym::align_of_val => align.bytes(),
133133
sym::size_of_val => size.bytes(),
134134
_ => bug!(),
135135
};

compiler/rustc_hir_analysis/src/check/intrinsic.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ fn intrinsic_operation_unsafety(tcx: TyCtxt<'_>, intrinsic_id: LocalDefId) -> hi
7171
| sym::box_new
7272
| sym::breakpoint
7373
| sym::size_of
74-
| sym::min_align_of
74+
| sym::align_of
7575
| sym::needs_drop
7676
| sym::caller_location
7777
| sym::add_with_overflow
@@ -200,10 +200,8 @@ pub(crate) fn check_intrinsic_type(
200200
sym::abort => (0, 0, vec![], tcx.types.never),
201201
sym::unreachable => (0, 0, vec![], tcx.types.never),
202202
sym::breakpoint => (0, 0, vec![], tcx.types.unit),
203-
sym::size_of | sym::pref_align_of | sym::min_align_of | sym::variant_count => {
204-
(1, 0, vec![], tcx.types.usize)
205-
}
206-
sym::size_of_val | sym::min_align_of_val => {
203+
sym::size_of | sym::align_of | sym::variant_count => (1, 0, vec![], tcx.types.usize),
204+
sym::size_of_val | sym::align_of_val => {
207205
(1, 0, vec![Ty::new_imm_ptr(tcx, param(0))], tcx.types.usize)
208206
}
209207
sym::rustc_peek => (1, 0, vec![param(0)], param(0)),

compiler/rustc_mir_transform/src/lower_intrinsics.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,12 +150,12 @@ impl<'tcx> crate::MirPass<'tcx> for LowerIntrinsics {
150150
});
151151
terminator.kind = TerminatorKind::Goto { target };
152152
}
153-
sym::size_of | sym::min_align_of => {
153+
sym::size_of | sym::align_of => {
154154
let target = target.unwrap();
155155
let tp_ty = generic_args.type_at(0);
156156
let null_op = match intrinsic.name {
157157
sym::size_of => NullOp::SizeOf,
158-
sym::min_align_of => NullOp::AlignOf,
158+
sym::align_of => NullOp::AlignOf,
159159
_ => bug!("unexpected intrinsic"),
160160
};
161161
block.statements.push(Statement {

compiler/rustc_span/src/symbol.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,8 @@ symbols! {
429429
aggregate_raw_ptr,
430430
alias,
431431
align,
432+
align_of,
433+
align_of_val,
432434
alignment,
433435
all,
434436
alloc,
@@ -1353,8 +1355,6 @@ symbols! {
13531355
message,
13541356
meta,
13551357
metadata_type,
1356-
min_align_of,
1357-
min_align_of_val,
13581358
min_const_fn,
13591359
min_const_generics,
13601360
min_const_unsafe_fn,

library/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
///

library/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 {

src/tools/clippy/clippy_utils/src/sym.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ generate! {
7676
Visitor,
7777
Weak,
7878
abs,
79-
align_of,
8079
ambiguous_glob_reexports,
8180
append,
8281
arg,

0 commit comments

Comments
 (0)