Skip to content

Commit 6dce9f8

Browse files
committed
Auto merge of rust-lang#135994 - 1c3t3a:rename-unsafe-ptr, r=oli-obk
Rename rustc_middle::Ty::is_unsafe_ptr to is_raw_ptr The wording unsafe pointer is less common and not mentioned in a lot of places, instead this is usually called a "raw pointer". For the sake of uniformity, we rename this method. This came up during the review of rust-lang#134424. r? `@Noratrieb`
2 parents ef148cd + 0c7d5e2 commit 6dce9f8

File tree

38 files changed

+64
-64
lines changed

38 files changed

+64
-64
lines changed

compiler/rustc_borrowck/src/diagnostics/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -570,7 +570,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
570570
// If we didn't find an overloaded deref or index, then assume it's a
571571
// built in deref and check the type of the base.
572572
let base_ty = deref_base.ty(self.body, tcx).ty;
573-
if base_ty.is_unsafe_ptr() {
573+
if base_ty.is_raw_ptr() {
574574
BorrowedContentSource::DerefRawPointer
575575
} else if base_ty.is_mutable_ptr() {
576576
BorrowedContentSource::DerefMutableRef

compiler/rustc_codegen_cranelift/src/base.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -900,8 +900,8 @@ fn codegen_stmt<'tcx>(
900900
};
901901
let data = codegen_operand(fx, data);
902902
let meta = codegen_operand(fx, meta);
903-
assert!(data.layout().ty.is_unsafe_ptr());
904-
assert!(layout.ty.is_unsafe_ptr());
903+
assert!(data.layout().ty.is_raw_ptr());
904+
assert!(layout.ty.is_raw_ptr());
905905
let ptr_val = if meta.layout().is_zst() {
906906
data.cast_pointer_to(layout)
907907
} else {

compiler/rustc_codegen_cranelift/src/vtable.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ pub(crate) fn get_ptr_and_method_ref<'tcx>(
4848
) -> (Pointer, Value) {
4949
let (ptr, vtable) = 'block: {
5050
if let BackendRepr::Scalar(_) = arg.layout().backend_repr {
51-
while !arg.layout().ty.is_unsafe_ptr() && !arg.layout().ty.is_ref() {
51+
while !arg.layout().ty.is_raw_ptr() && !arg.layout().ty.is_ref() {
5252
let (idx, _) = arg
5353
.layout()
5454
.non_1zst_field(fx)

compiler/rustc_codegen_ssa/src/mir/block.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1013,7 +1013,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
10131013
//
10141014
// This is also relevant for `Pin<&mut Self>`, where we need to peel the
10151015
// `Pin`.
1016-
while !op.layout.ty.is_unsafe_ptr() && !op.layout.ty.is_ref() {
1016+
while !op.layout.ty.is_raw_ptr() && !op.layout.ty.is_ref() {
10171017
let (idx, _) = op.layout.non_1zst_field(bx).expect(
10181018
"not exactly one non-1-ZST field in a `DispatchFromDyn` type",
10191019
);
@@ -1045,7 +1045,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
10451045
}
10461046
Immediate(_) => {
10471047
// See comment above explaining why we peel these newtypes
1048-
while !op.layout.ty.is_unsafe_ptr() && !op.layout.ty.is_ref() {
1048+
while !op.layout.ty.is_raw_ptr() && !op.layout.ty.is_ref() {
10491049
let (idx, _) = op.layout.non_1zst_field(bx).expect(
10501050
"not exactly one non-1-ZST field in a `DispatchFromDyn` type",
10511051
);

compiler/rustc_codegen_ssa/src/mir/intrinsic.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
367367
bx.sess().dcx().emit_fatal(errors::AtomicCompareExchange);
368368
};
369369
let ty = fn_args.type_at(0);
370-
if int_type_width_signed(ty, bx.tcx()).is_some() || ty.is_unsafe_ptr() {
370+
if int_type_width_signed(ty, bx.tcx()).is_some() || ty.is_raw_ptr() {
371371
let weak = instruction == "cxchgweak";
372372
let dst = args[0].immediate();
373373
let cmp = args[1].immediate();
@@ -395,7 +395,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
395395

396396
"load" => {
397397
let ty = fn_args.type_at(0);
398-
if int_type_width_signed(ty, bx.tcx()).is_some() || ty.is_unsafe_ptr() {
398+
if int_type_width_signed(ty, bx.tcx()).is_some() || ty.is_raw_ptr() {
399399
let layout = bx.layout_of(ty);
400400
let size = layout.size;
401401
let source = args[0].immediate();
@@ -413,7 +413,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
413413

414414
"store" => {
415415
let ty = fn_args.type_at(0);
416-
if int_type_width_signed(ty, bx.tcx()).is_some() || ty.is_unsafe_ptr() {
416+
if int_type_width_signed(ty, bx.tcx()).is_some() || ty.is_raw_ptr() {
417417
let size = bx.layout_of(ty).size;
418418
let val = args[1].immediate();
419419
let ptr = args[0].immediate();
@@ -458,7 +458,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
458458
};
459459

460460
let ty = fn_args.type_at(0);
461-
if int_type_width_signed(ty, bx.tcx()).is_some() || ty.is_unsafe_ptr() {
461+
if int_type_width_signed(ty, bx.tcx()).is_some() || ty.is_raw_ptr() {
462462
let ptr = args[0].immediate();
463463
let val = args[1].immediate();
464464
bx.atomic_rmw(atom_op, ptr, val, parse_ordering(bx, ordering))

compiler/rustc_codegen_ssa/src/mir/rvalue.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -689,7 +689,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
689689
(OperandValue::Immediate(llval), operand.layout)
690690
}
691691
mir::UnOp::PtrMetadata => {
692-
assert!(operand.layout.ty.is_unsafe_ptr() || operand.layout.ty.is_ref(),);
692+
assert!(operand.layout.ty.is_raw_ptr() || operand.layout.ty.is_ref(),);
693693
let (_, meta) = operand.val.pointer_parts();
694694
assert_eq!(operand.layout.fields.count() > 1, meta.is_some());
695695
if let Some(meta) = meta {

compiler/rustc_const_eval/src/check_consts/check.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -710,7 +710,7 @@ impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> {
710710

711711
if is_int_bool_float_or_char(lhs_ty) && is_int_bool_float_or_char(rhs_ty) {
712712
// Int, bool, float, and char operations are fine.
713-
} else if lhs_ty.is_fn_ptr() || lhs_ty.is_unsafe_ptr() {
713+
} else if lhs_ty.is_fn_ptr() || lhs_ty.is_raw_ptr() {
714714
assert_matches!(
715715
op,
716716
BinOp::Eq

compiler/rustc_const_eval/src/interpret/cast.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
203203
cast_to: TyAndLayout<'tcx>,
204204
) -> InterpResult<'tcx, ImmTy<'tcx, M::Provenance>> {
205205
assert!(src.layout.ty.is_any_ptr());
206-
assert!(cast_to.ty.is_unsafe_ptr());
206+
assert!(cast_to.ty.is_raw_ptr());
207207
// Handle casting any ptr to raw ptr (might be a wide ptr).
208208
if cast_to.size == src.layout.size {
209209
// Thin or wide pointer that just has the ptr kind of target type changed.
@@ -212,7 +212,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
212212
// Casting the metadata away from a wide ptr.
213213
assert_eq!(src.layout.size, 2 * self.pointer_size());
214214
assert_eq!(cast_to.size, self.pointer_size());
215-
assert!(src.layout.ty.is_unsafe_ptr());
215+
assert!(src.layout.ty.is_raw_ptr());
216216
return match **src {
217217
Immediate::ScalarPair(data, _) => interp_ok(ImmTy::from_scalar(data, cast_to)),
218218
Immediate::Scalar(..) => span_bug!(

compiler/rustc_const_eval/src/interpret/step.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
241241
// Figure out whether this is an addr_of of an already raw place.
242242
let place_base_raw = if place.is_indirect_first_projection() {
243243
let ty = self.frame().body.local_decls[place.local].ty;
244-
ty.is_unsafe_ptr()
244+
ty.is_raw_ptr()
245245
} else {
246246
// Not a deref, and thus not raw.
247247
false

compiler/rustc_hir_typeck/src/cast.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -690,7 +690,7 @@ impl<'a, 'tcx> CastCheck<'tcx> {
690690
} else {
691691
match self.try_coercion_cast(fcx) {
692692
Ok(()) => {
693-
if self.expr_ty.is_unsafe_ptr() && self.cast_ty.is_unsafe_ptr() {
693+
if self.expr_ty.is_raw_ptr() && self.cast_ty.is_raw_ptr() {
694694
// When casting a raw pointer to another raw pointer, we cannot convert the cast into
695695
// a coercion because the pointee types might only differ in regions, which HIR typeck
696696
// cannot distinguish. This would cause us to erroneously discard a cast which will

compiler/rustc_hir_typeck/src/coercion.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> {
219219
// or pin-ergonomics.
220220
match *b.kind() {
221221
ty::RawPtr(_, b_mutbl) => {
222-
return self.coerce_unsafe_ptr(a, b, b_mutbl);
222+
return self.coerce_raw_ptr(a, b, b_mutbl);
223223
}
224224
ty::Ref(r_b, _, mutbl_b) => {
225225
return self.coerce_borrowed_pointer(a, b, r_b, mutbl_b);
@@ -1017,13 +1017,13 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> {
10171017
}
10181018
}
10191019

1020-
fn coerce_unsafe_ptr(
1020+
fn coerce_raw_ptr(
10211021
&self,
10221022
a: Ty<'tcx>,
10231023
b: Ty<'tcx>,
10241024
mutbl_b: hir::Mutability,
10251025
) -> CoerceResult<'tcx> {
1026-
debug!("coerce_unsafe_ptr(a={:?}, b={:?})", a, b);
1026+
debug!("coerce_raw_ptr(a={:?}, b={:?})", a, b);
10271027

10281028
let (is_ref, mt_a) = match *a.kind() {
10291029
ty::Ref(_, ty, mutbl) => (true, ty::TypeAndMut { ty, mutbl }),
@@ -1033,21 +1033,21 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> {
10331033
coerce_mutbls(mt_a.mutbl, mutbl_b)?;
10341034

10351035
// Check that the types which they point at are compatible.
1036-
let a_unsafe = Ty::new_ptr(self.tcx, mt_a.ty, mutbl_b);
1037-
// Although references and unsafe ptrs have the same
1036+
let a_raw = Ty::new_ptr(self.tcx, mt_a.ty, mutbl_b);
1037+
// Although references and raw ptrs have the same
10381038
// representation, we still register an Adjust::DerefRef so that
10391039
// regionck knows that the region for `a` must be valid here.
10401040
if is_ref {
1041-
self.unify_and(a_unsafe, b, |target| {
1041+
self.unify_and(a_raw, b, |target| {
10421042
vec![
10431043
Adjustment { kind: Adjust::Deref(None), target: mt_a.ty },
10441044
Adjustment { kind: Adjust::Borrow(AutoBorrow::RawPtr(mutbl_b)), target },
10451045
]
10461046
})
10471047
} else if mt_a.mutbl != mutbl_b {
1048-
self.unify_and(a_unsafe, b, simple(Adjust::Pointer(PointerCoercion::MutToConstPointer)))
1048+
self.unify_and(a_raw, b, simple(Adjust::Pointer(PointerCoercion::MutToConstPointer)))
10491049
} else {
1050-
self.unify_and(a_unsafe, b, identity)
1050+
self.unify_and(a_raw, b, identity)
10511051
}
10521052
}
10531053
}

compiler/rustc_hir_typeck/src/expr.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3556,7 +3556,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
35563556
}
35573557
}
35583558

3559-
if base_t.is_unsafe_ptr() && idx_t.is_integral() {
3559+
if base_t.is_raw_ptr() && idx_t.is_integral() {
35603560
err.multipart_suggestion(
35613561
"consider using `wrapping_add` or `add` for indexing into raw pointer",
35623562
vec![

compiler/rustc_hir_typeck/src/method/probe.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -598,7 +598,7 @@ fn method_autoderef_steps<'tcx>(
598598
unsize: false,
599599
reachable_via_deref,
600600
};
601-
if ty.is_unsafe_ptr() {
601+
if ty.is_raw_ptr() {
602602
// all the subsequent steps will be from_unsafe_deref
603603
reached_raw_pointer = true;
604604
}
@@ -618,7 +618,7 @@ fn method_autoderef_steps<'tcx>(
618618
unsize: false,
619619
reachable_via_deref: true,
620620
};
621-
if ty.is_unsafe_ptr() {
621+
if ty.is_raw_ptr() {
622622
// all the subsequent steps will be from_unsafe_deref
623623
reached_raw_pointer = true;
624624
}

compiler/rustc_hir_typeck/src/op.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -645,7 +645,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
645645
// pointer + {integer} or pointer - pointer.
646646
if op.span.can_be_used_for_suggestions() {
647647
match op.node {
648-
hir::BinOpKind::Add if lhs_ty.is_unsafe_ptr() && rhs_ty.is_integral() => {
648+
hir::BinOpKind::Add if lhs_ty.is_raw_ptr() && rhs_ty.is_integral() => {
649649
err.multipart_suggestion(
650650
"consider using `wrapping_add` or `add` for pointer + {integer}",
651651
vec![
@@ -659,7 +659,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
659659
);
660660
}
661661
hir::BinOpKind::Sub => {
662-
if lhs_ty.is_unsafe_ptr() && rhs_ty.is_integral() {
662+
if lhs_ty.is_raw_ptr() && rhs_ty.is_integral() {
663663
err.multipart_suggestion(
664664
"consider using `wrapping_sub` or `sub` for \
665665
pointer - {integer}",
@@ -674,7 +674,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
674674
);
675675
}
676676

677-
if lhs_ty.is_unsafe_ptr() && rhs_ty.is_unsafe_ptr() {
677+
if lhs_ty.is_raw_ptr() && rhs_ty.is_raw_ptr() {
678678
err.multipart_suggestion(
679679
"consider using `offset_from` for pointer - pointer if the \
680680
pointers point to the same allocation",

compiler/rustc_hir_typeck/src/upvar.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -2042,7 +2042,7 @@ impl<'tcx> euv::Delegate<'tcx> for InferBorrowKind<'tcx> {
20422042
restrict_repr_packed_field_ref_capture(place_with_id.place.clone(), capture_kind);
20432043

20442044
// Raw pointers don't inherit mutability
2045-
if place_with_id.place.deref_tys().any(Ty::is_unsafe_ptr) {
2045+
if place_with_id.place.deref_tys().any(Ty::is_raw_ptr) {
20462046
capture_kind = ty::UpvarCapture::ByRef(ty::BorrowKind::Immutable);
20472047
}
20482048

@@ -2093,7 +2093,7 @@ fn restrict_precision_for_unsafe(
20932093
mut place: Place<'_>,
20942094
mut curr_mode: ty::UpvarCapture,
20952095
) -> (Place<'_>, ty::UpvarCapture) {
2096-
if place.base_ty.is_unsafe_ptr() {
2096+
if place.base_ty.is_raw_ptr() {
20972097
truncate_place_to_len_and_update_capture_kind(&mut place, &mut curr_mode, 0);
20982098
}
20992099

@@ -2102,8 +2102,8 @@ fn restrict_precision_for_unsafe(
21022102
}
21032103

21042104
for (i, proj) in place.projections.iter().enumerate() {
2105-
if proj.ty.is_unsafe_ptr() {
2106-
// Don't apply any projections on top of an unsafe ptr.
2105+
if proj.ty.is_raw_ptr() {
2106+
// Don't apply any projections on top of a raw ptr.
21072107
truncate_place_to_len_and_update_capture_kind(&mut place, &mut curr_mode, i + 1);
21082108
break;
21092109
}

compiler/rustc_lint/src/builtin.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -576,7 +576,7 @@ impl<'tcx> LateLintPass<'tcx> for MissingCopyImplementations {
576576
// and recommending Copy might be a bad idea.
577577
for field in def.all_fields() {
578578
let did = field.did;
579-
if cx.tcx.type_of(did).instantiate_identity().is_unsafe_ptr() {
579+
if cx.tcx.type_of(did).instantiate_identity().is_raw_ptr() {
580580
return;
581581
}
582582
}

compiler/rustc_middle/src/ty/layout.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ impl<'tcx> SizeSkeleton<'tcx> {
368368

369369
match *ty.kind() {
370370
ty::Ref(_, pointee, _) | ty::RawPtr(pointee, _) => {
371-
let non_zero = !ty.is_unsafe_ptr();
371+
let non_zero = !ty.is_raw_ptr();
372372

373373
let tail = tcx.struct_tail_raw(
374374
pointee,
@@ -840,7 +840,7 @@ where
840840
// as the `Abi` or `FieldsShape` is checked by users.
841841
if i == 0 {
842842
let nil = tcx.types.unit;
843-
let unit_ptr_ty = if this.ty.is_unsafe_ptr() {
843+
let unit_ptr_ty = if this.ty.is_raw_ptr() {
844844
Ty::new_mut_ptr(tcx, nil)
845845
} else {
846846
Ty::new_mut_ref(tcx, tcx.lifetimes.re_static, nil)

compiler/rustc_middle/src/ty/sty.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1199,15 +1199,15 @@ impl<'tcx> Ty<'tcx> {
11991199
}
12001200

12011201
#[inline]
1202-
pub fn is_unsafe_ptr(self) -> bool {
1202+
pub fn is_raw_ptr(self) -> bool {
12031203
matches!(self.kind(), RawPtr(_, _))
12041204
}
12051205

12061206
/// Tests if this is any kind of primitive pointer type (reference, raw pointer, fn pointer).
12071207
/// `Box` is *not* considered a pointer here!
12081208
#[inline]
12091209
pub fn is_any_ptr(self) -> bool {
1210-
self.is_ref() || self.is_unsafe_ptr() || self.is_fn_ptr()
1210+
self.is_ref() || self.is_raw_ptr() || self.is_fn_ptr()
12111211
}
12121212

12131213
#[inline]
@@ -1394,7 +1394,7 @@ impl<'tcx> Ty<'tcx> {
13941394
/// Returns the type and mutability of `*ty`.
13951395
///
13961396
/// The parameter `explicit` indicates if this is an *explicit* dereference.
1397-
/// Some types -- notably unsafe ptrs -- can only be dereferenced explicitly.
1397+
/// Some types -- notably raw ptrs -- can only be dereferenced explicitly.
13981398
pub fn builtin_deref(self, explicit: bool) -> Option<Ty<'tcx>> {
13991399
match *self.kind() {
14001400
_ if let Some(boxed) = self.boxed_ty() => Some(boxed),

compiler/rustc_mir_build/src/check_unsafety.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -554,7 +554,7 @@ impl<'a, 'tcx> Visitor<'a, 'tcx> for UnsafetyVisitor<'a, 'tcx> {
554554
_ => self.requires_unsafe(expr.span, UseOfExternStatic),
555555
}
556556
}
557-
} else if self.thir[arg].ty.is_unsafe_ptr() {
557+
} else if self.thir[arg].ty.is_raw_ptr() {
558558
self.requires_unsafe(expr.span, DerefOfRawPointer);
559559
}
560560
}

compiler/rustc_mir_transform/src/check_pointers.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ impl<'a, 'tcx> Visitor<'tcx> for PointerFinder<'a, 'tcx> {
190190
let pointer_ty = self.local_decls[place.local].ty;
191191

192192
// We only want to check places based on raw pointers
193-
if !pointer_ty.is_unsafe_ptr() {
193+
if !pointer_ty.is_raw_ptr() {
194194
trace!("Indirect, but not based on an raw ptr, not checking {:?}", place);
195195
return;
196196
}

compiler/rustc_mir_transform/src/check_undefined_transmutes.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ impl<'a, 'tcx> UndefinedTransmutesChecker<'a, 'tcx> {
4747
{
4848
let fn_sig = function.ty(self.body, self.tcx).fn_sig(self.tcx).skip_binder();
4949
if let [input] = fn_sig.inputs() {
50-
return input.is_unsafe_ptr() && fn_sig.output().is_integral();
50+
return input.is_raw_ptr() && fn_sig.output().is_integral();
5151
}
5252
}
5353
false

compiler/rustc_mir_transform/src/gvn.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1397,8 +1397,8 @@ impl<'body, 'tcx> VnState<'body, 'tcx> {
13971397
// or `*mut [i32]` <=> `*const [u64]`), including the common special
13981398
// case of `*const T` <=> `*mut T`.
13991399
if let Transmute = kind
1400-
&& from.is_unsafe_ptr()
1401-
&& to.is_unsafe_ptr()
1400+
&& from.is_raw_ptr()
1401+
&& to.is_raw_ptr()
14021402
&& self.pointers_have_same_metadata(from, to)
14031403
{
14041404
kind = PtrToPtr;

compiler/rustc_ty_utils/src/abi.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -749,7 +749,7 @@ fn make_thin_self_ptr<'tcx>(
749749
// To get the type `*mut RcInner<Self>`, we just keep unwrapping newtypes until we
750750
// get a built-in pointer type
751751
let mut wide_pointer_layout = layout;
752-
while !wide_pointer_layout.ty.is_unsafe_ptr() && !wide_pointer_layout.ty.is_ref() {
752+
while !wide_pointer_layout.ty.is_raw_ptr() && !wide_pointer_layout.ty.is_ref() {
753753
wide_pointer_layout = wide_pointer_layout
754754
.non_1zst_field(cx)
755755
.expect("not exactly one non-1-ZST field in a `DispatchFromDyn` type")

compiler/rustc_ty_utils/src/layout.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ fn layout_of_uncached<'tcx>(
269269
// Potentially-wide pointers.
270270
ty::Ref(_, pointee, _) | ty::RawPtr(pointee, _) => {
271271
let mut data_ptr = scalar_unit(Pointer(AddressSpace::DATA));
272-
if !ty.is_unsafe_ptr() {
272+
if !ty.is_raw_ptr() {
273273
data_ptr.valid_range_mut().start = 1;
274274
}
275275

compiler/stable_mir/src/ty.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,7 @@ impl TyKind {
489489
/// Returns the type and mutability of `*ty` for builtin types.
490490
///
491491
/// The parameter `explicit` indicates if this is an *explicit* dereference.
492-
/// Some types -- notably unsafe ptrs -- can only be dereferenced explicitly.
492+
/// Some types -- notably raw ptrs -- can only be dereferenced explicitly.
493493
pub fn builtin_deref(&self, explicit: bool) -> Option<TypeAndMut> {
494494
match self.rigid()? {
495495
RigidTy::Adt(def, args) if def.is_box() => {

0 commit comments

Comments
 (0)