Skip to content

Commit 77c65a0

Browse files
committed
Extend the renaming to coerce_unsafe_ptr
1 parent 70fd576 commit 77c65a0

File tree

8 files changed

+16
-16
lines changed

8 files changed

+16
-16
lines changed

compiler/rustc_codegen_cranelift/src/base.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -891,8 +891,8 @@ fn codegen_stmt<'tcx>(
891891
};
892892
let data = codegen_operand(fx, data);
893893
let meta = codegen_operand(fx, meta);
894-
assert!(data.layout().ty.is_unsafe_ptr());
895-
assert!(layout.ty.is_unsafe_ptr());
894+
assert!(data.layout().ty.is_raw_ptr());
895+
assert!(layout.ty.is_raw_ptr());
896896
let ptr_val = if meta.layout().is_zst() {
897897
data.cast_pointer_to(layout)
898898
} 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_hir_typeck/src/coercion.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> {
220220
// or pin-ergonomics.
221221
match *b.kind() {
222222
ty::RawPtr(_, b_mutbl) => {
223-
return self.coerce_unsafe_ptr(a, b, b_mutbl);
223+
return self.coerce_raw_ptr(a, b, b_mutbl);
224224
}
225225
ty::Ref(r_b, _, mutbl_b) => {
226226
return self.coerce_borrowed_pointer(a, b, r_b, mutbl_b);
@@ -1035,13 +1035,13 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> {
10351035
}
10361036
}
10371037

1038-
fn coerce_unsafe_ptr(
1038+
fn coerce_raw_ptr(
10391039
&self,
10401040
a: Ty<'tcx>,
10411041
b: Ty<'tcx>,
10421042
mutbl_b: hir::Mutability,
10431043
) -> CoerceResult<'tcx> {
1044-
debug!("coerce_unsafe_ptr(a={:?}, b={:?})", a, b);
1044+
debug!("coerce_raw_ptr(a={:?}, b={:?})", a, b);
10451045

10461046
let (is_ref, mt_a) = match *a.kind() {
10471047
ty::Ref(_, ty, mutbl) => (true, ty::TypeAndMut { ty, mutbl }),
@@ -1051,21 +1051,21 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> {
10511051
coerce_mutbls(mt_a.mutbl, mutbl_b)?;
10521052

10531053
// Check that the types which they point at are compatible.
1054-
let a_unsafe = Ty::new_ptr(self.tcx, mt_a.ty, mutbl_b);
1055-
// Although references and unsafe ptrs have the same
1054+
let a_raw = Ty::new_ptr(self.tcx, mt_a.ty, mutbl_b);
1055+
// Although references and raw ptrs have the same
10561056
// representation, we still register an Adjust::DerefRef so that
10571057
// regionck knows that the region for `a` must be valid here.
10581058
if is_ref {
1059-
self.unify_and(a_unsafe, b, |target| {
1059+
self.unify_and(a_raw, b, |target| {
10601060
vec![Adjustment { kind: Adjust::Deref(None), target: mt_a.ty }, Adjustment {
10611061
kind: Adjust::Borrow(AutoBorrow::RawPtr(mutbl_b)),
10621062
target,
10631063
}]
10641064
})
10651065
} else if mt_a.mutbl != mutbl_b {
1066-
self.unify_and(a_unsafe, b, simple(Adjust::Pointer(PointerCoercion::MutToConstPointer)))
1066+
self.unify_and(a_raw, b, simple(Adjust::Pointer(PointerCoercion::MutToConstPointer)))
10671067
} else {
1068-
self.unify_and(a_unsafe, b, identity)
1068+
self.unify_and(a_raw, b, identity)
10691069
}
10701070
}
10711071
}

compiler/rustc_hir_typeck/src/upvar.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2094,7 +2094,7 @@ fn restrict_precision_for_unsafe(
20942094

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

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),

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

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 {

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)