Auto merge of #107652 - estebank:re_error, r=oli-obk
Introduce `ReError` CC #69314 r? `@nagisa`
This commit is contained in:
commit
d1ac43a9b9
50 changed files with 248 additions and 227 deletions
|
@ -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.
|
||||
//
|
||||
|
|
|
@ -369,6 +369,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),
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
@ -216,6 +216,8 @@ impl<'cx, 'tcx> LexicalResolver<'cx, 'tcx> {
|
|||
Ok(self.tcx().lifetimes.re_static)
|
||||
}
|
||||
|
||||
ReError(_) => Ok(a_region),
|
||||
|
||||
ReEarlyBound(_) | ReFree(_) => {
|
||||
// All empty regions are less than early-bound, free,
|
||||
// and scope regions.
|
||||
|
@ -436,7 +438,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 +467,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 +548,10 @@ impl<'cx, 'tcx> LexicalResolver<'cx, 'tcx> {
|
|||
);
|
||||
}
|
||||
|
||||
(ReError(_), _) => a,
|
||||
|
||||
(_, ReError(_)) => b,
|
||||
|
||||
(ReStatic, _) | (_, ReStatic) => {
|
||||
// nothing lives longer than `'static`
|
||||
self.tcx().lifetimes.re_static
|
||||
|
@ -1040,7 +1046,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.re_error_misc(),
|
||||
},
|
||||
_ => r,
|
||||
};
|
||||
|
|
|
@ -696,9 +696,11 @@ impl<'tcx> RegionConstraintCollector<'_, 'tcx> {
|
|||
|
||||
pub fn universe(&self, region: Region<'tcx>) -> ty::UniverseIndex {
|
||||
match *region {
|
||||
ty::ReStatic | ty::ReErased | ty::ReFree(..) | ty::ReEarlyBound(..) => {
|
||||
ty::UniverseIndex::ROOT
|
||||
}
|
||||
ty::ReStatic
|
||||
| ty::ReErased
|
||||
| ty::ReFree(..)
|
||||
| ty::ReEarlyBound(..)
|
||||
| ty::ReError(_) => ty::UniverseIndex::ROOT,
|
||||
ty::RePlaceholder(placeholder) => placeholder.universe,
|
||||
ty::ReVar(vid) => self.var_universe(vid),
|
||||
ty::ReLateBound(..) => bug!("universe(): encountered bound region {:?}", region),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue