Skip to content

Commit 432ff5e

Browse files
committed
Extend the renaming to coerce_unsafe_ptr
1 parent f842ee8 commit 432ff5e

File tree

8 files changed

+16
-16
lines changed

8 files changed

+16
-16
lines changed

Diff for: 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 {

Diff for: 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)

Diff for: 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
}

Diff for: compiler/rustc_hir_typeck/src/upvar.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2103,7 +2103,7 @@ fn restrict_precision_for_unsafe(
21032103

21042104
for (i, proj) in place.projections.iter().enumerate() {
21052105
if proj.ty.is_raw_ptr() {
2106-
// Don't apply any projections on top of an unsafe 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
}

Diff for: compiler/rustc_middle/src/ty/sty.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -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),

Diff for: 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() => {

Diff for: src/tools/rust-analyzer/crates/hir-ty/src/infer/coerce.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ impl InferenceTable<'_> {
373373
// Check that the types which they point at are compatible.
374374
let from_raw = TyKind::Raw(to_mt, from_inner.clone()).intern(Interner);
375375

376-
// Although references and unsafe ptrs have the same
376+
// Although references and raw ptrs have the same
377377
// representation, we still register an Adjust::DerefRef so that
378378
// regionck knows that the region for `a` must be valid here.
379379
if is_ref {

Diff for: tests/ui/kindck/kindck-copy.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ fn test<'a,T,U:Copy>(_: &'a isize) {
4545
// mutable object types are not ok
4646
assert_copy::<&'a mut (dyn Dummy + Send)>(); //~ ERROR : Copy` is not satisfied
4747

48-
// unsafe ptrs are ok
48+
// raw ptrs are ok
4949
assert_copy::<*const isize>();
5050
assert_copy::<*const &'a mut isize>();
5151

0 commit comments

Comments
 (0)