Skip to content

Commit f842ee8

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 rust-lang#134424.
1 parent 80c0919 commit f842ee8

File tree

28 files changed

+43
-43
lines changed

28 files changed

+43
-43
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_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/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

+3-3
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,7 +2102,7 @@ fn restrict_precision_for_unsafe(
21022102
}
21032103

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

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
@@ -369,7 +369,7 @@ impl<'tcx> SizeSkeleton<'tcx> {
369369

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

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

compiler/rustc_middle/src/ty/sty.rs

+2-2
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

+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
@@ -753,7 +753,7 @@ fn make_thin_self_ptr<'tcx>(
753753
// To get the type `*mut RcInner<Self>`, we just keep unwrapping newtypes until we
754754
// get a built-in pointer type
755755
let mut wide_pointer_layout = layout;
756-
while !wide_pointer_layout.ty.is_unsafe_ptr() && !wide_pointer_layout.ty.is_ref() {
756+
while !wide_pointer_layout.ty.is_raw_ptr() && !wide_pointer_layout.ty.is_ref() {
757757
wide_pointer_layout = wide_pointer_layout
758758
.non_1zst_field(cx)
759759
.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

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

+1-1
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

+1-1
Original file line numberDiff line numberDiff line change
@@ -682,7 +682,7 @@ fn try_parse_ref_op<'tcx>(
682682
},
683683
[arg],
684684
) => (true, typeck.qpath_res(path, *hir_id).opt_def_id()?, arg),
685-
ExprKind::Unary(UnOp::Deref, sub_expr) if !typeck.expr_ty(sub_expr).is_unsafe_ptr() => {
685+
ExprKind::Unary(UnOp::Deref, sub_expr) if !typeck.expr_ty(sub_expr).is_raw_ptr() => {
686686
return Some((RefOp::Deref, sub_expr));
687687
},
688688
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

+1-1
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ fn collect_unsafe_exprs<'tcx>(
122122
unsafe_ops.push(("access of a mutable static occurs here", expr.span));
123123
},
124124

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

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

+3-3
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

+1-1
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

+1-1
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!(

src/tools/clippy/clippy_utils/src/visitors.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ pub fn is_expr_unsafe<'tcx>(cx: &LateContext<'tcx>, e: &'tcx Expr<'_>) -> bool {
417417
}
418418
fn visit_expr(&mut self, e: &'tcx Expr<'_>) -> Self::Result {
419419
match e.kind {
420-
ExprKind::Unary(UnOp::Deref, e) if self.cx.typeck_results().expr_ty(e).is_unsafe_ptr() => {
420+
ExprKind::Unary(UnOp::Deref, e) if self.cx.typeck_results().expr_ty(e).is_raw_ptr() => {
421421
ControlFlow::Break(())
422422
},
423423
ExprKind::MethodCall(..)

0 commit comments

Comments
 (0)