Skip to content

Commit 4159409

Browse files
authored
Rollup merge of #109378 - MU001999:master, r=scottmcm
Remove Ty::is_region_ptr Fixes #109372
2 parents 61df888 + 20dc532 commit 4159409

File tree

8 files changed

+12
-24
lines changed

8 files changed

+12
-24
lines changed

compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs

+4-9
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
120120
&& !self.upvars.is_empty()
121121
{
122122
item_msg = access_place_desc;
123-
debug_assert!(
124-
self.body.local_decls[ty::CAPTURE_STRUCT_LOCAL].ty.is_region_ptr()
125-
);
123+
debug_assert!(self.body.local_decls[ty::CAPTURE_STRUCT_LOCAL].ty.is_ref());
126124
debug_assert!(is_closure_or_generator(
127125
Place::ty_from(
128126
the_place_err.local,
@@ -470,11 +468,8 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
470468
{
471469
let local_decl = &self.body.local_decls[local];
472470

473-
let (pointer_sigil, pointer_desc) = if local_decl.ty.is_region_ptr() {
474-
("&", "reference")
475-
} else {
476-
("*const", "pointer")
477-
};
471+
let (pointer_sigil, pointer_desc) =
472+
if local_decl.ty.is_ref() { ("&", "reference") } else { ("*const", "pointer") };
478473

479474
match self.local_names[local] {
480475
Some(name) if !local_decl.from_compiler_desugaring() => {
@@ -1258,7 +1253,7 @@ fn suggest_ampmut<'tcx>(
12581253
(
12591254
suggestability,
12601255
highlight_span,
1261-
if local_decl.ty.is_region_ptr() {
1256+
if local_decl.ty.is_ref() {
12621257
format!("&mut {}", ty_mut.ty)
12631258
} else {
12641259
format!("*mut {}", ty_mut.ty)

compiler/rustc_codegen_cranelift/src/vtable.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,7 @@ pub(crate) fn get_ptr_and_method_ref<'tcx>(
4848
) -> (Pointer, Value) {
4949
let (ptr, vtable) = 'block: {
5050
if let Abi::Scalar(_) = arg.layout().abi {
51-
'descend_newtypes: while !arg.layout().ty.is_unsafe_ptr()
52-
&& !arg.layout().ty.is_region_ptr()
53-
{
51+
'descend_newtypes: while !arg.layout().ty.is_unsafe_ptr() && !arg.layout().ty.is_ref() {
5452
for i in 0..arg.layout().fields.count() {
5553
let field = arg.value_field(fx, mir::Field::new(i));
5654
if !field.layout().is_zst() {

compiler/rustc_codegen_ssa/src/mir/block.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -917,7 +917,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
917917
//
918918
// This is also relevant for `Pin<&mut Self>`, where we need to peel the `Pin`.
919919
'descend_newtypes: while !op.layout.ty.is_unsafe_ptr()
920-
&& !op.layout.ty.is_region_ptr()
920+
&& !op.layout.ty.is_ref()
921921
{
922922
for i in 0..op.layout.fields.count() {
923923
let field = op.extract_field(bx, i);
@@ -959,7 +959,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
959959
Immediate(_) => {
960960
// See comment above explaining why we peel these newtypes
961961
'descend_newtypes: while !op.layout.ty.is_unsafe_ptr()
962-
&& !op.layout.ty.is_region_ptr()
962+
&& !op.layout.ty.is_ref()
963963
{
964964
for i in 0..op.layout.fields.count() {
965965
let field = op.extract_field(bx, i);

compiler/rustc_hir_typeck/src/demand.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1487,7 +1487,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
14871487
{
14881488
let deref_kind = if checked_ty.is_box() {
14891489
"unboxing the value"
1490-
} else if checked_ty.is_region_ptr() {
1490+
} else if checked_ty.is_ref() {
14911491
"dereferencing the borrow"
14921492
} else {
14931493
"dereferencing the type"

compiler/rustc_hir_typeck/src/method/suggest.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1182,7 +1182,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
11821182
.inputs()
11831183
.skip_binder()
11841184
.get(0)
1185-
.filter(|ty| ty.is_region_ptr() && !rcvr_ty.is_region_ptr())
1185+
.filter(|ty| ty.is_ref() && !rcvr_ty.is_ref())
11861186
.copied()
11871187
.unwrap_or(rcvr_ty),
11881188
};

compiler/rustc_middle/src/ty/sty.rs

+1-6
Original file line numberDiff line numberDiff line change
@@ -1913,11 +1913,6 @@ impl<'tcx> Ty<'tcx> {
19131913
}
19141914
}
19151915

1916-
#[inline]
1917-
pub fn is_region_ptr(self) -> bool {
1918-
matches!(self.kind(), Ref(..))
1919-
}
1920-
19211916
#[inline]
19221917
pub fn is_mutable_ptr(self) -> bool {
19231918
matches!(
@@ -1944,7 +1939,7 @@ impl<'tcx> Ty<'tcx> {
19441939
/// Tests if this is any kind of primitive pointer type (reference, raw pointer, fn pointer).
19451940
#[inline]
19461941
pub fn is_any_ptr(self) -> bool {
1947-
self.is_region_ptr() || self.is_unsafe_ptr() || self.is_fn_ptr()
1942+
self.is_ref() || self.is_unsafe_ptr() || self.is_fn_ptr()
19481943
}
19491944

19501945
#[inline]

compiler/rustc_mir_build/src/thir/cx/expr.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ impl<'tcx> Cx<'tcx> {
185185
if self.typeck_results().is_coercion_cast(source.hir_id) {
186186
// Convert the lexpr to a vexpr.
187187
ExprKind::Use { source: self.mirror_expr(source) }
188-
} else if self.typeck_results().expr_ty(source).is_region_ptr() {
188+
} else if self.typeck_results().expr_ty(source).is_ref() {
189189
// Special cased so that we can type check that the element
190190
// type of the source matches the pointed to type of the
191191
// destination.

compiler/rustc_ty_utils/src/abi.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -539,7 +539,7 @@ fn make_thin_self_ptr<'tcx>(
539539
// get a built-in pointer type
540540
let mut fat_pointer_layout = layout;
541541
'descend_newtypes: while !fat_pointer_layout.ty.is_unsafe_ptr()
542-
&& !fat_pointer_layout.ty.is_region_ptr()
542+
&& !fat_pointer_layout.ty.is_ref()
543543
{
544544
for i in 0..fat_pointer_layout.fields.count() {
545545
let field_layout = fat_pointer_layout.field(cx, i);

0 commit comments

Comments
 (0)