Skip to content

Commit

Permalink
Rollup merge of rust-lang#109378 - MU001999:master, r=scottmcm
Browse files Browse the repository at this point in the history
Remove Ty::is_region_ptr

Fixes rust-lang#109372
  • Loading branch information
Dylan-DPC committed Mar 22, 2023
2 parents 9749318 + 20dc532 commit 7297fe4
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 24 deletions.
13 changes: 4 additions & 9 deletions compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
&& !self.upvars.is_empty()
{
item_msg = access_place_desc;
debug_assert!(
self.body.local_decls[ty::CAPTURE_STRUCT_LOCAL].ty.is_region_ptr()
);
debug_assert!(self.body.local_decls[ty::CAPTURE_STRUCT_LOCAL].ty.is_ref());
debug_assert!(is_closure_or_generator(
Place::ty_from(
the_place_err.local,
Expand Down Expand Up @@ -470,11 +468,8 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
{
let local_decl = &self.body.local_decls[local];

let (pointer_sigil, pointer_desc) = if local_decl.ty.is_region_ptr() {
("&", "reference")
} else {
("*const", "pointer")
};
let (pointer_sigil, pointer_desc) =
if local_decl.ty.is_ref() { ("&", "reference") } else { ("*const", "pointer") };

match self.local_names[local] {
Some(name) if !local_decl.from_compiler_desugaring() => {
Expand Down Expand Up @@ -1258,7 +1253,7 @@ fn suggest_ampmut<'tcx>(
(
suggestability,
highlight_span,
if local_decl.ty.is_region_ptr() {
if local_decl.ty.is_ref() {
format!("&mut {}", ty_mut.ty)
} else {
format!("*mut {}", ty_mut.ty)
Expand Down
4 changes: 1 addition & 3 deletions compiler/rustc_codegen_cranelift/src/vtable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,7 @@ pub(crate) fn get_ptr_and_method_ref<'tcx>(
) -> (Pointer, Value) {
let (ptr, vtable) = 'block: {
if let Abi::Scalar(_) = arg.layout().abi {
'descend_newtypes: while !arg.layout().ty.is_unsafe_ptr()
&& !arg.layout().ty.is_region_ptr()
{
'descend_newtypes: while !arg.layout().ty.is_unsafe_ptr() && !arg.layout().ty.is_ref() {
for i in 0..arg.layout().fields.count() {
let field = arg.value_field(fx, mir::Field::new(i));
if !field.layout().is_zst() {
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_codegen_ssa/src/mir/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -917,7 +917,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
//
// This is also relevant for `Pin<&mut Self>`, where we need to peel the `Pin`.
'descend_newtypes: while !op.layout.ty.is_unsafe_ptr()
&& !op.layout.ty.is_region_ptr()
&& !op.layout.ty.is_ref()
{
for i in 0..op.layout.fields.count() {
let field = op.extract_field(bx, i);
Expand Down Expand Up @@ -959,7 +959,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
Immediate(_) => {
// See comment above explaining why we peel these newtypes
'descend_newtypes: while !op.layout.ty.is_unsafe_ptr()
&& !op.layout.ty.is_region_ptr()
&& !op.layout.ty.is_ref()
{
for i in 0..op.layout.fields.count() {
let field = op.extract_field(bx, i);
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_hir_typeck/src/demand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1487,7 +1487,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
{
let deref_kind = if checked_ty.is_box() {
"unboxing the value"
} else if checked_ty.is_region_ptr() {
} else if checked_ty.is_ref() {
"dereferencing the borrow"
} else {
"dereferencing the type"
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_hir_typeck/src/method/suggest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1182,7 +1182,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
.inputs()
.skip_binder()
.get(0)
.filter(|ty| ty.is_region_ptr() && !rcvr_ty.is_region_ptr())
.filter(|ty| ty.is_ref() && !rcvr_ty.is_ref())
.copied()
.unwrap_or(rcvr_ty),
};
Expand Down
7 changes: 1 addition & 6 deletions compiler/rustc_middle/src/ty/sty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1925,11 +1925,6 @@ impl<'tcx> Ty<'tcx> {
}
}

#[inline]
pub fn is_region_ptr(self) -> bool {
matches!(self.kind(), Ref(..))
}

#[inline]
pub fn is_mutable_ptr(self) -> bool {
matches!(
Expand All @@ -1956,7 +1951,7 @@ impl<'tcx> Ty<'tcx> {
/// Tests if this is any kind of primitive pointer type (reference, raw pointer, fn pointer).
#[inline]
pub fn is_any_ptr(self) -> bool {
self.is_region_ptr() || self.is_unsafe_ptr() || self.is_fn_ptr()
self.is_ref() || self.is_unsafe_ptr() || self.is_fn_ptr()
}

#[inline]
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_mir_build/src/thir/cx/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ impl<'tcx> Cx<'tcx> {
if self.typeck_results().is_coercion_cast(source.hir_id) {
// Convert the lexpr to a vexpr.
ExprKind::Use { source: self.mirror_expr(source) }
} else if self.typeck_results().expr_ty(source).is_region_ptr() {
} else if self.typeck_results().expr_ty(source).is_ref() {
// Special cased so that we can type check that the element
// type of the source matches the pointed to type of the
// destination.
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_ty_utils/src/abi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,7 @@ fn make_thin_self_ptr<'tcx>(
// get a built-in pointer type
let mut fat_pointer_layout = layout;
'descend_newtypes: while !fat_pointer_layout.ty.is_unsafe_ptr()
&& !fat_pointer_layout.ty.is_region_ptr()
&& !fat_pointer_layout.ty.is_ref()
{
for i in 0..fat_pointer_layout.fields.count() {
let field_layout = fat_pointer_layout.field(cx, i);
Expand Down

0 comments on commit 7297fe4

Please sign in to comment.