Skip to content

Commit 803fb5b

Browse files
committed
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 #134424.
1 parent 061ee95 commit 803fb5b

File tree

28 files changed

+47
-47
lines changed

28 files changed

+47
-47
lines changed

compiler/rustc_borrowck/src/diagnostics/mod.rs

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

compiler/rustc_codegen_ssa/src/mir/block.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1008,7 +1008,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
10081008
//
10091009
// This is also relevant for `Pin<&mut Self>`, where we need to peel the
10101010
// `Pin`.
1011-
while !op.layout.ty.is_unsafe_ptr() && !op.layout.ty.is_ref() {
1011+
while !op.layout.ty.is_raw_ptr() && !op.layout.ty.is_ref() {
10121012
let (idx, _) = op.layout.non_1zst_field(bx).expect(
10131013
"not exactly one non-1-ZST field in a `DispatchFromDyn` type",
10141014
);
@@ -1040,7 +1040,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
10401040
}
10411041
Immediate(_) => {
10421042
// See comment above explaining why we peel these newtypes
1043-
while !op.layout.ty.is_unsafe_ptr() && !op.layout.ty.is_ref() {
1043+
while !op.layout.ty.is_raw_ptr() && !op.layout.ty.is_ref() {
10441044
let (idx, _) = op.layout.non_1zst_field(bx).expect(
10451045
"not exactly one non-1-ZST field in a `DispatchFromDyn` type",
10461046
);

compiler/rustc_codegen_ssa/src/mir/intrinsic.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
362362
bx.sess().dcx().emit_fatal(errors::AtomicCompareExchange);
363363
};
364364
let ty = fn_args.type_at(0);
365-
if int_type_width_signed(ty, bx.tcx()).is_some() || ty.is_unsafe_ptr() {
365+
if int_type_width_signed(ty, bx.tcx()).is_some() || ty.is_raw_ptr() {
366366
let weak = instruction == "cxchgweak";
367367
let dst = args[0].immediate();
368368
let cmp = args[1].immediate();
@@ -390,7 +390,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
390390

391391
"load" => {
392392
let ty = fn_args.type_at(0);
393-
if int_type_width_signed(ty, bx.tcx()).is_some() || ty.is_unsafe_ptr() {
393+
if int_type_width_signed(ty, bx.tcx()).is_some() || ty.is_raw_ptr() {
394394
let layout = bx.layout_of(ty);
395395
let size = layout.size;
396396
let source = args[0].immediate();
@@ -408,7 +408,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
408408

409409
"store" => {
410410
let ty = fn_args.type_at(0);
411-
if int_type_width_signed(ty, bx.tcx()).is_some() || ty.is_unsafe_ptr() {
411+
if int_type_width_signed(ty, bx.tcx()).is_some() || ty.is_raw_ptr() {
412412
let size = bx.layout_of(ty).size;
413413
let val = args[1].immediate();
414414
let ptr = args[0].immediate();
@@ -453,7 +453,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
453453
};
454454

455455
let ty = fn_args.type_at(0);
456-
if int_type_width_signed(ty, bx.tcx()).is_some() || ty.is_unsafe_ptr() {
456+
if int_type_width_signed(ty, bx.tcx()).is_some() || ty.is_raw_ptr() {
457457
let ptr = args[0].immediate();
458458
let val = args[1].immediate();
459459
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
@@ -688,7 +688,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
688688
(OperandValue::Immediate(llval), operand.layout)
689689
}
690690
mir::UnOp::PtrMetadata => {
691-
assert!(operand.layout.ty.is_unsafe_ptr() || operand.layout.ty.is_ref(),);
691+
assert!(operand.layout.ty.is_raw_ptr() || operand.layout.ty.is_ref(),);
692692
let (_, meta) = operand.val.pointer_parts();
693693
assert_eq!(operand.layout.fields.count() > 1, meta.is_some());
694694
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
@@ -601,7 +601,7 @@ impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> {
601601

602602
if is_int_bool_float_or_char(lhs_ty) && is_int_bool_float_or_char(rhs_ty) {
603603
// Int, bool, float, and char operations are fine.
604-
} else if lhs_ty.is_fn_ptr() || lhs_ty.is_unsafe_ptr() {
604+
} else if lhs_ty.is_fn_ptr() || lhs_ty.is_raw_ptr() {
605605
assert_matches!(
606606
op,
607607
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
@@ -689,7 +689,7 @@ impl<'a, 'tcx> CastCheck<'tcx> {
689689
} else {
690690
match self.try_coercion_cast(fcx) {
691691
Ok(()) => {
692-
if self.expr_ty.is_unsafe_ptr() && self.cast_ty.is_unsafe_ptr() {
692+
if self.expr_ty.is_raw_ptr() && self.cast_ty.is_raw_ptr() {
693693
// When casting a raw pointer to another raw pointer, we cannot convert the cast into
694694
// a coercion because the pointee types might only differ in regions, which HIR typeck
695695
// cannot distinguish. This would cause us to erroneously discard a cast which will

compiler/rustc_hir_typeck/src/expr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3571,7 +3571,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
35713571
}
35723572
}
35733573

3574-
if base_t.is_unsafe_ptr() && idx_t.is_integral() {
3574+
if base_t.is_raw_ptr() && idx_t.is_integral() {
35753575
err.multipart_suggestion(
35763576
"consider using `wrapping_add` or `add` for indexing into raw pointer",
35773577
vec![

compiler/rustc_hir_typeck/src/method/probe.rs

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -638,7 +638,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
638638
// pointer + {integer} or pointer - pointer.
639639
if op.span.can_be_used_for_suggestions() {
640640
match op.node {
641-
hir::BinOpKind::Add if lhs_ty.is_unsafe_ptr() && rhs_ty.is_integral() => {
641+
hir::BinOpKind::Add if lhs_ty.is_raw_ptr() && rhs_ty.is_integral() => {
642642
err.multipart_suggestion(
643643
"consider using `wrapping_add` or `add` for pointer + {integer}",
644644
vec![
@@ -652,7 +652,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
652652
);
653653
}
654654
hir::BinOpKind::Sub => {
655-
if lhs_ty.is_unsafe_ptr() && rhs_ty.is_integral() {
655+
if lhs_ty.is_raw_ptr() && rhs_ty.is_integral() {
656656
err.multipart_suggestion(
657657
"consider using `wrapping_sub` or `sub` for pointer - {integer}",
658658
vec![
@@ -663,7 +663,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
663663
);
664664
}
665665

666-
if lhs_ty.is_unsafe_ptr() && rhs_ty.is_unsafe_ptr() {
666+
if lhs_ty.is_raw_ptr() && rhs_ty.is_raw_ptr() {
667667
err.multipart_suggestion(
668668
"consider using `offset_from` for pointer - pointer if the pointers point to the same allocation",
669669
vec![

compiler/rustc_hir_typeck/src/upvar.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2036,7 +2036,7 @@ impl<'tcx> euv::Delegate<'tcx> for InferBorrowKind<'tcx> {
20362036
restrict_repr_packed_field_ref_capture(place_with_id.place.clone(), capture_kind);
20372037

20382038
// Raw pointers don't inherit mutability
2039-
if place_with_id.place.deref_tys().any(Ty::is_unsafe_ptr) {
2039+
if place_with_id.place.deref_tys().any(Ty::is_raw_ptr) {
20402040
capture_kind = ty::UpvarCapture::ByRef(ty::BorrowKind::Immutable);
20412041
}
20422042

@@ -2084,7 +2084,7 @@ fn restrict_precision_for_unsafe(
20842084
mut place: Place<'_>,
20852085
mut curr_mode: ty::UpvarCapture,
20862086
) -> (Place<'_>, ty::UpvarCapture) {
2087-
if place.base_ty.is_unsafe_ptr() {
2087+
if place.base_ty.is_raw_ptr() {
20882088
truncate_place_to_len_and_update_capture_kind(&mut place, &mut curr_mode, 0);
20892089
}
20902090

@@ -2093,7 +2093,7 @@ fn restrict_precision_for_unsafe(
20932093
}
20942094

20952095
for (i, proj) in place.projections.iter().enumerate() {
2096-
if proj.ty.is_unsafe_ptr() {
2096+
if proj.ty.is_raw_ptr() {
20972097
// Don't apply any projections on top of an unsafe ptr.
20982098
truncate_place_to_len_and_update_capture_kind(&mut place, &mut curr_mode, i + 1);
20992099
break;

compiler/rustc_lint/src/builtin.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -581,7 +581,7 @@ impl<'tcx> LateLintPass<'tcx> for MissingCopyImplementations {
581581
// and recommending Copy might be a bad idea.
582582
for field in def.all_fields() {
583583
let did = field.did;
584-
if cx.tcx.type_of(did).instantiate_identity().is_unsafe_ptr() {
584+
if cx.tcx.type_of(did).instantiate_identity().is_raw_ptr() {
585585
return;
586586
}
587587
}

compiler/rustc_middle/src/ty/layout.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ impl<'tcx> SizeSkeleton<'tcx> {
362362

363363
match *ty.kind() {
364364
ty::Ref(_, pointee, _) | ty::RawPtr(pointee, _) => {
365-
let non_zero = !ty.is_unsafe_ptr();
365+
let non_zero = !ty.is_raw_ptr();
366366

367367
let tail = tcx.struct_tail_raw(
368368
pointee,
@@ -832,7 +832,7 @@ where
832832
// as the `Abi` or `FieldsShape` is checked by users.
833833
if i == 0 {
834834
let nil = tcx.types.unit;
835-
let unit_ptr_ty = if this.ty.is_unsafe_ptr() {
835+
let unit_ptr_ty = if this.ty.is_raw_ptr() {
836836
Ty::new_mut_ptr(tcx, nil)
837837
} else {
838838
Ty::new_mut_ref(tcx, tcx.lifetimes.re_static, nil)

compiler/rustc_middle/src/ty/sty.rs

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

compiler/rustc_mir_build/src/check_unsafety.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -549,7 +549,7 @@ impl<'a, 'tcx> Visitor<'a, 'tcx> for UnsafetyVisitor<'a, 'tcx> {
549549
_ => self.requires_unsafe(expr.span, UseOfExternStatic),
550550
}
551551
}
552-
} else if self.thir[arg].ty.is_unsafe_ptr() {
552+
} else if self.thir[arg].ty.is_raw_ptr() {
553553
self.requires_unsafe(expr.span, DerefOfRawPointer);
554554
}
555555
}

compiler/rustc_mir_transform/src/check_alignment.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,17 +98,17 @@ impl<'a, 'tcx> Visitor<'tcx> for PointerFinder<'a, 'tcx> {
9898
let pointer = Place::from(place.local);
9999
let pointer_ty = self.local_decls[place.local].ty;
100100

101-
// We only want to check places based on unsafe pointers
102-
if !pointer_ty.is_unsafe_ptr() {
103-
trace!("Indirect, but not based on an unsafe ptr, not checking {:?}", place);
101+
// We only want to check places based on raw pointers
102+
if !pointer_ty.is_raw_ptr() {
103+
trace!("Indirect, but not based on a raw ptr, not checking {:?}", place);
104104
return;
105105
}
106106

107107
let pointee_ty =
108-
pointer_ty.builtin_deref(true).expect("no builtin_deref for an unsafe pointer");
108+
pointer_ty.builtin_deref(true).expect("no builtin_deref for a raw pointer");
109109
// Ideally we'd support this in the future, but for now we are limited to sized types.
110110
if !pointee_ty.is_sized(self.tcx, self.typing_env) {
111-
debug!("Unsafe pointer, but pointee is not known to be sized: {:?}", pointer_ty);
111+
debug!("Raw pointer, but pointee is not known to be sized: {:?}", pointer_ty);
112112
return;
113113
}
114114

compiler/rustc_mir_transform/src/check_undefined_transmutes.rs

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1385,8 +1385,8 @@ impl<'body, 'tcx> VnState<'body, 'tcx> {
13851385
// or `*mut [i32]` <=> `*const [u64]`), including the common special
13861386
// case of `*const T` <=> `*mut T`.
13871387
if let Transmute = kind
1388-
&& from.is_unsafe_ptr()
1389-
&& to.is_unsafe_ptr()
1388+
&& from.is_raw_ptr()
1389+
&& to.is_raw_ptr()
13901390
&& self.pointers_have_same_metadata(from, to)
13911391
{
13921392
*kind = PtrToPtr;

compiler/rustc_ty_utils/src/abi.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -758,7 +758,7 @@ fn make_thin_self_ptr<'tcx>(
758758
// To get the type `*mut RcInner<Self>`, we just keep unwrapping newtypes until we
759759
// get a built-in pointer type
760760
let mut wide_pointer_layout = layout;
761-
while !wide_pointer_layout.ty.is_unsafe_ptr() && !wide_pointer_layout.ty.is_ref() {
761+
while !wide_pointer_layout.ty.is_raw_ptr() && !wide_pointer_layout.ty.is_ref() {
762762
wide_pointer_layout = wide_pointer_layout
763763
.non_1zst_field(cx)
764764
.expect("not exactly one non-1-ZST field in a `DispatchFromDyn` type")

compiler/rustc_ty_utils/src/layout.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ fn layout_of_uncached<'tcx>(
236236
// Potentially-wide pointers.
237237
ty::Ref(_, pointee, _) | ty::RawPtr(pointee, _) => {
238238
let mut data_ptr = scalar_unit(Pointer(AddressSpace::DATA));
239-
if !ty.is_unsafe_ptr() {
239+
if !ty.is_raw_ptr() {
240240
data_ptr.valid_range_mut().start = 1;
241241
}
242242

src/tools/clippy/clippy_lints/src/casts/cast_ptr_alignment.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ fn is_used_as_unaligned(cx: &LateContext<'_>, e: &Expr<'_>) -> bool {
6666
if matches!(name.ident.as_str(), "read_unaligned" | "write_unaligned")
6767
&& let Some(def_id) = cx.typeck_results().type_dependent_def_id(parent.hir_id)
6868
&& let Some(def_id) = cx.tcx.impl_of_method(def_id)
69-
&& cx.tcx.type_of(def_id).instantiate_identity().is_unsafe_ptr()
69+
&& cx.tcx.type_of(def_id).instantiate_identity().is_raw_ptr()
7070
{
7171
true
7272
} else {

src/tools/clippy/clippy_lints/src/dereference.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -670,7 +670,7 @@ fn try_parse_ref_op<'tcx>(
670670
},
671671
[arg],
672672
) => (true, typeck.qpath_res(path, *hir_id).opt_def_id()?, arg),
673-
ExprKind::Unary(UnOp::Deref, sub_expr) if !typeck.expr_ty(sub_expr).is_unsafe_ptr() => {
673+
ExprKind::Unary(UnOp::Deref, sub_expr) if !typeck.expr_ty(sub_expr).is_raw_ptr() => {
674674
return Some((RefOp::Deref, sub_expr));
675675
},
676676
ExprKind::AddrOf(BorrowKind::Ref, mutability, sub_expr) => return Some((RefOp::AddrOf(mutability), sub_expr)),

src/tools/clippy/clippy_lints/src/multiple_unsafe_ops_per_block.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ fn collect_unsafe_exprs<'tcx>(
123123
unsafe_ops.push(("access of a mutable static occurs here", expr.span));
124124
},
125125

126-
ExprKind::Unary(UnOp::Deref, e) if cx.typeck_results().expr_ty_adjusted(e).is_unsafe_ptr() => {
126+
ExprKind::Unary(UnOp::Deref, e) if cx.typeck_results().expr_ty_adjusted(e).is_raw_ptr() => {
127127
unsafe_ops.push(("raw pointer dereference occurs here", expr.span));
128128
},
129129

src/tools/clippy/clippy_lints/src/pass_by_ref_or_value.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -179,10 +179,10 @@ impl PassByRefOrValue {
179179
&& let hir::TyKind::Ref(_, MutTy { ty: decl_ty, .. }) = input.kind
180180
{
181181
if let Some(typeck) = cx.maybe_typeck_results() {
182-
// Don't lint if an unsafe pointer is created.
183-
// TODO: Limit the check only to unsafe pointers to the argument (or part of the argument)
182+
// Don't lint if a raw pointer is created.
183+
// TODO: Limit the check only to raw pointers to the argument (or part of the argument)
184184
// which escape the current function.
185-
if typeck.node_types().items().any(|(_, &ty)| ty.is_unsafe_ptr())
185+
if typeck.node_types().items().any(|(_, &ty)| ty.is_raw_ptr())
186186
|| typeck
187187
.adjustments()
188188
.items()

src/tools/clippy/clippy_lints/src/ptr_offset_with_cast.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ fn is_expr_ty_usize(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool {
111111

112112
// Is the type of the expression a raw pointer?
113113
fn is_expr_ty_raw_ptr(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool {
114-
cx.typeck_results().expr_ty(expr).is_unsafe_ptr()
114+
cx.typeck_results().expr_ty(expr).is_raw_ptr()
115115
}
116116

117117
fn build_suggestion(

src/tools/clippy/clippy_utils/src/eager_or_lazy.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ fn expr_eagerness<'tcx>(cx: &LateContext<'tcx>, e: &'tcx Expr<'_>) -> EagernessS
217217
self.eagerness |= NoChange;
218218
},
219219
// Dereferences should be cheap, but dereferencing a raw pointer earlier may not be safe.
220-
ExprKind::Unary(UnOp::Deref, e) if !self.cx.typeck_results().expr_ty(e).is_unsafe_ptr() => (),
220+
ExprKind::Unary(UnOp::Deref, e) if !self.cx.typeck_results().expr_ty(e).is_raw_ptr() => (),
221221
ExprKind::Unary(UnOp::Deref, _) => self.eagerness |= NoChange,
222222
ExprKind::Unary(_, e)
223223
if matches!(

0 commit comments

Comments
 (0)