1
Fork 0

Introduce ReError

CC #69314
This commit is contained in:
Esteban Küber 2023-02-03 23:21:56 +00:00
parent c40919b7a7
commit 30cf7a3f51
51 changed files with 208 additions and 211 deletions

View file

@ -31,6 +31,8 @@ impl<'a> DescriptionCtx<'a> {
ty::RePlaceholder(_) => return None,
ty::ReError => return None,
// FIXME(#13998) RePlaceholder should probably print like
// ReFree rather than dumping Debug output on the user.
//

View file

@ -371,6 +371,7 @@ impl<'cx, 'tcx> TypeFolder<'tcx> for Canonicalizer<'cx, 'tcx> {
ty::ReStatic
| ty::ReEarlyBound(..)
| ty::ReError
| ty::ReFree(_)
| ty::RePlaceholder(..)
| ty::ReErased => self.canonicalize_mode.canonicalize_free_region(self, r),

View file

@ -705,6 +705,10 @@ impl<'tcx> TypeRelation<'tcx> for Generalizer<'_, 'tcx> {
return Ok(r);
}
ty::ReError => {
return Ok(r);
}
ty::RePlaceholder(..)
| ty::ReVar(..)
| ty::ReStatic
@ -861,7 +865,7 @@ impl<'tcx> FallibleTypeFolder<'tcx> for ConstInferUnifier<'_, 'tcx> {
match *r {
// Never make variables for regions bound within the type itself,
// nor for erased regions.
ty::ReLateBound(..) | ty::ReErased => {
ty::ReLateBound(..) | ty::ReErased | ty::ReError => {
return Ok(r);
}

View file

@ -134,6 +134,8 @@ pub(super) fn note_and_explain_region<'tcx>(
ty::RePlaceholder(_) => return,
ty::ReError => return,
// FIXME(#13998) RePlaceholder should probably print like
// ReFree rather than dumping Debug output on the user.
//
@ -313,6 +315,9 @@ pub fn unexpected_hidden_region_diagnostic<'tcx>(
)
}
}
ty::ReError => {
err.delay_as_bug();
}
_ => {
// Ugh. This is a painful case: the hidden region is not one
// that we can easily summarize or explain. This can happen
@ -2546,7 +2551,11 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
);
err.note_expected_found(&"", sup_expected, &"", sup_found);
err.emit();
if sub_region.is_error() | sup_region.is_error() {
err.delay_as_bug();
} else {
err.emit();
}
return;
}
@ -2562,7 +2571,11 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
);
self.note_region_origin(&mut err, &sub_origin);
err.emit();
if sub_region.is_error() | sup_region.is_error() {
err.delay_as_bug();
} else {
err.emit();
}
}
/// Determine whether an error associated with the given span and definition

View file

@ -78,7 +78,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
sub: Region<'tcx>,
sup: Region<'tcx>,
) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
match origin {
let mut err = match origin {
infer::Subtype(box trace) => {
let terr = TypeError::RegionsDoesNotOutlive(sup, sub);
let mut err = self.report_and_explain_type_error(trace, terr);
@ -299,7 +299,11 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
);
err
}
};
if sub.is_error() || sup.is_error() {
err.delay_as_bug();
}
err
}
pub fn suggest_copy_trait_method_bounds(

View file

@ -126,6 +126,7 @@ impl<'a, 'tcx> TypeFolder<'tcx> for TypeFreshener<'a, 'tcx> {
| ty::ReFree(_)
| ty::ReVar(_)
| ty::RePlaceholder(..)
| ty::ReError
| ty::ReErased => {
// replace all free regions with 'erased
self.tcx().lifetimes.re_erased

View file

@ -17,7 +17,7 @@ use rustc_index::vec::{Idx, IndexVec};
use rustc_middle::ty::fold::TypeFoldable;
use rustc_middle::ty::PlaceholderRegion;
use rustc_middle::ty::{self, Ty, TyCtxt};
use rustc_middle::ty::{ReEarlyBound, ReErased, ReFree, ReStatic};
use rustc_middle::ty::{ReEarlyBound, ReErased, ReError, ReFree, ReStatic};
use rustc_middle::ty::{ReLateBound, RePlaceholder, ReVar};
use rustc_middle::ty::{Region, RegionVid};
use rustc_span::Span;
@ -211,7 +211,7 @@ impl<'cx, 'tcx> LexicalResolver<'cx, 'tcx> {
);
}
ReStatic => {
ReStatic | ReError => {
// nothing lives longer than `'static`
Ok(self.tcx().lifetimes.re_static)
}
@ -436,7 +436,7 @@ impl<'cx, 'tcx> LexicalResolver<'cx, 'tcx> {
}
(VarValue::Value(a), VarValue::Empty(_)) => {
match *a {
ReLateBound(..) | ReErased => {
ReLateBound(..) | ReErased | ReError => {
bug!("cannot relate region: {:?}", a);
}
@ -465,7 +465,7 @@ impl<'cx, 'tcx> LexicalResolver<'cx, 'tcx> {
}
(VarValue::Empty(a_ui), VarValue::Value(b)) => {
match *b {
ReLateBound(..) | ReErased => {
ReLateBound(..) | ReErased | ReError => {
bug!("cannot relate region: {:?}", b);
}
@ -546,6 +546,8 @@ impl<'cx, 'tcx> LexicalResolver<'cx, 'tcx> {
);
}
(ReError, _) | (_, ReError) => self.tcx().lifetimes.re_error,
(ReStatic, _) | (_, ReStatic) => {
// nothing lives longer than `'static`
self.tcx().lifetimes.re_static
@ -1040,7 +1042,7 @@ impl<'tcx> LexicalRegionResolutions<'tcx> {
ty::ReVar(rid) => match self.values[rid] {
VarValue::Empty(_) => r,
VarValue::Value(r) => r,
VarValue::ErrorValue => tcx.lifetimes.re_static,
VarValue::ErrorValue => tcx.lifetimes.re_error,
},
_ => r,
};

View file

@ -696,7 +696,7 @@ impl<'tcx> RegionConstraintCollector<'_, 'tcx> {
pub fn universe(&self, region: Region<'tcx>) -> ty::UniverseIndex {
match *region {
ty::ReStatic | ty::ReErased | ty::ReFree(..) | ty::ReEarlyBound(..) => {
ty::ReStatic | ty::ReErased | ty::ReFree(..) | ty::ReEarlyBound(..) | ty::ReError => {
ty::UniverseIndex::ROOT
}
ty::RePlaceholder(placeholder) => placeholder.universe,