mirror of
https://github.com/rust-lang/rust.git
synced 2025-05-14 02:49:40 +00:00
Extend the renaming to coerce_unsafe_ptr
This commit is contained in:
parent
f842ee8245
commit
432ff5e559
@ -900,8 +900,8 @@ fn codegen_stmt<'tcx>(
|
||||
};
|
||||
let data = codegen_operand(fx, data);
|
||||
let meta = codegen_operand(fx, meta);
|
||||
assert!(data.layout().ty.is_unsafe_ptr());
|
||||
assert!(layout.ty.is_unsafe_ptr());
|
||||
assert!(data.layout().ty.is_raw_ptr());
|
||||
assert!(layout.ty.is_raw_ptr());
|
||||
let ptr_val = if meta.layout().is_zst() {
|
||||
data.cast_pointer_to(layout)
|
||||
} else {
|
||||
|
@ -48,7 +48,7 @@ pub(crate) fn get_ptr_and_method_ref<'tcx>(
|
||||
) -> (Pointer, Value) {
|
||||
let (ptr, vtable) = 'block: {
|
||||
if let BackendRepr::Scalar(_) = arg.layout().backend_repr {
|
||||
while !arg.layout().ty.is_unsafe_ptr() && !arg.layout().ty.is_ref() {
|
||||
while !arg.layout().ty.is_raw_ptr() && !arg.layout().ty.is_ref() {
|
||||
let (idx, _) = arg
|
||||
.layout()
|
||||
.non_1zst_field(fx)
|
||||
|
@ -219,7 +219,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> {
|
||||
// or pin-ergonomics.
|
||||
match *b.kind() {
|
||||
ty::RawPtr(_, b_mutbl) => {
|
||||
return self.coerce_unsafe_ptr(a, b, b_mutbl);
|
||||
return self.coerce_raw_ptr(a, b, b_mutbl);
|
||||
}
|
||||
ty::Ref(r_b, _, mutbl_b) => {
|
||||
return self.coerce_borrowed_pointer(a, b, r_b, mutbl_b);
|
||||
@ -1017,13 +1017,13 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
fn coerce_unsafe_ptr(
|
||||
fn coerce_raw_ptr(
|
||||
&self,
|
||||
a: Ty<'tcx>,
|
||||
b: Ty<'tcx>,
|
||||
mutbl_b: hir::Mutability,
|
||||
) -> CoerceResult<'tcx> {
|
||||
debug!("coerce_unsafe_ptr(a={:?}, b={:?})", a, b);
|
||||
debug!("coerce_raw_ptr(a={:?}, b={:?})", a, b);
|
||||
|
||||
let (is_ref, mt_a) = match *a.kind() {
|
||||
ty::Ref(_, ty, mutbl) => (true, ty::TypeAndMut { ty, mutbl }),
|
||||
@ -1033,21 +1033,21 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> {
|
||||
coerce_mutbls(mt_a.mutbl, mutbl_b)?;
|
||||
|
||||
// Check that the types which they point at are compatible.
|
||||
let a_unsafe = Ty::new_ptr(self.tcx, mt_a.ty, mutbl_b);
|
||||
// Although references and unsafe ptrs have the same
|
||||
let a_raw = Ty::new_ptr(self.tcx, mt_a.ty, mutbl_b);
|
||||
// Although references and raw ptrs have the same
|
||||
// representation, we still register an Adjust::DerefRef so that
|
||||
// regionck knows that the region for `a` must be valid here.
|
||||
if is_ref {
|
||||
self.unify_and(a_unsafe, b, |target| {
|
||||
self.unify_and(a_raw, b, |target| {
|
||||
vec![
|
||||
Adjustment { kind: Adjust::Deref(None), target: mt_a.ty },
|
||||
Adjustment { kind: Adjust::Borrow(AutoBorrow::RawPtr(mutbl_b)), target },
|
||||
]
|
||||
})
|
||||
} else if mt_a.mutbl != mutbl_b {
|
||||
self.unify_and(a_unsafe, b, simple(Adjust::Pointer(PointerCoercion::MutToConstPointer)))
|
||||
self.unify_and(a_raw, b, simple(Adjust::Pointer(PointerCoercion::MutToConstPointer)))
|
||||
} else {
|
||||
self.unify_and(a_unsafe, b, identity)
|
||||
self.unify_and(a_raw, b, identity)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2103,7 +2103,7 @@ fn restrict_precision_for_unsafe(
|
||||
|
||||
for (i, proj) in place.projections.iter().enumerate() {
|
||||
if proj.ty.is_raw_ptr() {
|
||||
// Don't apply any projections on top of an unsafe ptr.
|
||||
// Don't apply any projections on top of a raw ptr.
|
||||
truncate_place_to_len_and_update_capture_kind(&mut place, &mut curr_mode, i + 1);
|
||||
break;
|
||||
}
|
||||
|
@ -1394,7 +1394,7 @@ impl<'tcx> Ty<'tcx> {
|
||||
/// Returns the type and mutability of `*ty`.
|
||||
///
|
||||
/// The parameter `explicit` indicates if this is an *explicit* dereference.
|
||||
/// Some types -- notably unsafe ptrs -- can only be dereferenced explicitly.
|
||||
/// Some types -- notably raw ptrs -- can only be dereferenced explicitly.
|
||||
pub fn builtin_deref(self, explicit: bool) -> Option<Ty<'tcx>> {
|
||||
match *self.kind() {
|
||||
_ if let Some(boxed) = self.boxed_ty() => Some(boxed),
|
||||
|
@ -489,7 +489,7 @@ impl TyKind {
|
||||
/// Returns the type and mutability of `*ty` for builtin types.
|
||||
///
|
||||
/// The parameter `explicit` indicates if this is an *explicit* dereference.
|
||||
/// Some types -- notably unsafe ptrs -- can only be dereferenced explicitly.
|
||||
/// Some types -- notably raw ptrs -- can only be dereferenced explicitly.
|
||||
pub fn builtin_deref(&self, explicit: bool) -> Option<TypeAndMut> {
|
||||
match self.rigid()? {
|
||||
RigidTy::Adt(def, args) if def.is_box() => {
|
||||
|
@ -373,7 +373,7 @@ impl InferenceTable<'_> {
|
||||
// Check that the types which they point at are compatible.
|
||||
let from_raw = TyKind::Raw(to_mt, from_inner.clone()).intern(Interner);
|
||||
|
||||
// Although references and unsafe ptrs have the same
|
||||
// Although references and raw ptrs have the same
|
||||
// representation, we still register an Adjust::DerefRef so that
|
||||
// regionck knows that the region for `a` must be valid here.
|
||||
if is_ref {
|
||||
|
@ -45,7 +45,7 @@ fn test<'a,T,U:Copy>(_: &'a isize) {
|
||||
// mutable object types are not ok
|
||||
assert_copy::<&'a mut (dyn Dummy + Send)>(); //~ ERROR : Copy` is not satisfied
|
||||
|
||||
// unsafe ptrs are ok
|
||||
// raw ptrs are ok
|
||||
assert_copy::<*const isize>();
|
||||
assert_copy::<*const &'a mut isize>();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user