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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 4 additions & 4 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

0 commit comments

Comments
 (0)