Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 30cf7a3

Browse files
committed
Introduce ReError
CC rust-lang#69314
1 parent c40919b commit 30cf7a3

File tree

51 files changed

+208
-211
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+208
-211
lines changed

compiler/rustc_borrowck/src/diagnostics/region_name.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -343,11 +343,11 @@ impl<'tcx> MirBorrowckCtxt<'_, 'tcx> {
343343
let note = match closure_kind_ty.to_opt_closure_kind() {
344344
Some(ty::ClosureKind::Fn) => {
345345
"closure implements `Fn`, so references to captured variables \
346-
can't escape the closure"
346+
can't escape the closure"
347347
}
348348
Some(ty::ClosureKind::FnMut) => {
349349
"closure implements `FnMut`, so references to captured variables \
350-
can't escape the closure"
350+
can't escape the closure"
351351
}
352352
Some(ty::ClosureKind::FnOnce) => {
353353
bug!("BrEnv in a `FnOnce` closure");
@@ -364,7 +364,11 @@ impl<'tcx> MirBorrowckCtxt<'_, 'tcx> {
364364
ty::BoundRegionKind::BrAnon(..) => None,
365365
},
366366

367-
ty::ReLateBound(..) | ty::ReVar(..) | ty::RePlaceholder(..) | ty::ReErased => None,
367+
ty::ReLateBound(..)
368+
| ty::ReVar(..)
369+
| ty::RePlaceholder(..)
370+
| ty::ReErased
371+
| ty::ReError => None,
368372
}
369373
}
370374

compiler/rustc_borrowck/src/region_infer/opaque_types.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
9595
concrete_type.span,
9696
"opaque type with non-universal region substs",
9797
);
98-
infcx.tcx.lifetimes.re_static
98+
infcx.tcx.lifetimes.re_error
9999
}
100100
}
101101
};

compiler/rustc_borrowck/src/universal_regions.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -821,6 +821,8 @@ impl<'tcx> UniversalRegionIndices<'tcx> {
821821
pub fn to_region_vid(&self, r: ty::Region<'tcx>) -> RegionVid {
822822
if let ty::ReVar(..) = *r {
823823
r.to_region_vid()
824+
} else if let ty::ReError = *r {
825+
RegionVid::new(0)
824826
} else {
825827
*self
826828
.indices

compiler/rustc_hir_analysis/src/astconv/mod.rs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -264,10 +264,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
264264
// reported an error in this case -- but if
265265
// not, let's error out.
266266
tcx.sess.delay_span_bug(lifetime.ident.span, "unelided lifetime in signature");
267-
268-
// Supply some dummy value. We don't have an
269-
// `re_error`, annoyingly, so use `'static`.
270-
tcx.lifetimes.re_static
267+
tcx.lifetimes.re_error
271268
})
272269
}
273270
}
@@ -482,10 +479,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
482479

483480
// This indicates an illegal lifetime in a non-assoc-trait position
484481
tcx.sess.delay_span_bug(self.span, "unelided lifetime in signature");
485-
486-
// Supply some dummy value. We don't have an
487-
// `re_error`, annoyingly, so use `'static`.
488-
tcx.lifetimes.re_static
482+
tcx.lifetimes.re_error
489483
})
490484
.into(),
491485
GenericParamDefKind::Type { has_default, .. } => {
@@ -1629,7 +1623,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
16291623
} else {
16301624
err.emit();
16311625
}
1632-
tcx.lifetimes.re_static
1626+
tcx.lifetimes.re_error
16331627
})
16341628
}
16351629
})

compiler/rustc_hir_analysis/src/check/compare_impl_item.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -792,7 +792,7 @@ pub(super) fn collect_return_position_impl_trait_in_trait_tys<'tcx>(
792792
return_span,
793793
"expected ReFree to map to ReEarlyBound"
794794
);
795-
return tcx.lifetimes.re_static;
795+
return tcx.lifetimes.re_error;
796796
};
797797
tcx.mk_region(ty::ReEarlyBound(ty::EarlyBoundRegion {
798798
def_id: e.def_id,

compiler/rustc_hir_analysis/src/collect/type_of.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -928,7 +928,7 @@ fn infer_placeholder_type<'a>(
928928

929929
// Typeck doesn't expect erased regions to be returned from `type_of`.
930930
tcx.fold_regions(ty, |r, _| match *r {
931-
ty::ReErased => tcx.lifetimes.re_static,
931+
ty::ReErased | ty::ReError => tcx.lifetimes.re_static,
932932
_ => r,
933933
})
934934
}

compiler/rustc_hir_analysis/src/outlives/utils.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,8 @@ fn is_free_region(region: Region<'_>) -> bool {
170170
// ignore it. We can't put it on the struct header anyway.
171171
ty::ReLateBound(..) => false,
172172

173+
ty::ReError => false,
174+
173175
// These regions don't appear in types from type declarations:
174176
ty::ReErased | ty::ReVar(..) | ty::RePlaceholder(..) | ty::ReFree(..) => {
175177
bug!("unexpected region in outlives inference: {:?}", region);

compiler/rustc_hir_analysis/src/variance/constraints.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,8 @@ impl<'a, 'tcx> ConstraintContext<'a, 'tcx> {
409409
// way early-bound regions do, so we skip them here.
410410
}
411411

412+
ty::ReError => {}
413+
412414
ty::ReFree(..) | ty::ReVar(..) | ty::RePlaceholder(..) | ty::ReErased => {
413415
// We don't expect to see anything but 'static or bound
414416
// regions when visiting member types or method types.

compiler/rustc_infer/src/errors/note_and_explain.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ impl<'a> DescriptionCtx<'a> {
3131

3232
ty::RePlaceholder(_) => return None,
3333

34+
ty::ReError => return None,
35+
3436
// FIXME(#13998) RePlaceholder should probably print like
3537
// ReFree rather than dumping Debug output on the user.
3638
//

compiler/rustc_infer/src/infer/canonical/canonicalizer.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,7 @@ impl<'cx, 'tcx> TypeFolder<'tcx> for Canonicalizer<'cx, 'tcx> {
371371

372372
ty::ReStatic
373373
| ty::ReEarlyBound(..)
374+
| ty::ReError
374375
| ty::ReFree(_)
375376
| ty::RePlaceholder(..)
376377
| ty::ReErased => self.canonicalize_mode.canonicalize_free_region(self, r),

0 commit comments

Comments
 (0)