Use ErrorGuaranteed
more in ReError
This commit is contained in:
parent
3222725538
commit
3689295a6b
5 changed files with 22 additions and 16 deletions
|
@ -1614,14 +1614,14 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
|||
"the lifetime bound for this object type cannot be deduced \
|
||||
from context; please supply an explicit bound"
|
||||
);
|
||||
if borrowed {
|
||||
let e = if borrowed {
|
||||
// We will have already emitted an error E0106 complaining about a
|
||||
// missing named lifetime in `&dyn Trait`, so we elide this one.
|
||||
err.delay_as_bug();
|
||||
err.delay_as_bug()
|
||||
} else {
|
||||
err.emit();
|
||||
}
|
||||
tcx.re_error()
|
||||
err.emit()
|
||||
};
|
||||
tcx.re_error(e)
|
||||
})
|
||||
}
|
||||
})
|
||||
|
|
|
@ -216,7 +216,7 @@ impl<'cx, 'tcx> LexicalResolver<'cx, 'tcx> {
|
|||
Ok(self.tcx().lifetimes.re_static)
|
||||
}
|
||||
|
||||
ReError(_) => Ok(self.tcx().re_error()),
|
||||
ReError(_) => Ok(a_region),
|
||||
|
||||
ReEarlyBound(_) | ReFree(_) => {
|
||||
// All empty regions are less than early-bound, free,
|
||||
|
@ -548,7 +548,9 @@ impl<'cx, 'tcx> LexicalResolver<'cx, 'tcx> {
|
|||
);
|
||||
}
|
||||
|
||||
(ReError(_), _) | (_, ReError(_)) => self.tcx().re_error(),
|
||||
(ReError(_), _) => a,
|
||||
|
||||
(_, ReError(_)) => b,
|
||||
|
||||
(ReStatic, _) | (_, ReStatic) => {
|
||||
// nothing lives longer than `'static`
|
||||
|
@ -1044,7 +1046,7 @@ impl<'tcx> LexicalRegionResolutions<'tcx> {
|
|||
ty::ReVar(rid) => match self.values[rid] {
|
||||
VarValue::Empty(_) => r,
|
||||
VarValue::Value(r) => r,
|
||||
VarValue::ErrorValue => tcx.re_error(),
|
||||
VarValue::ErrorValue => tcx.re_error_misc(),
|
||||
},
|
||||
_ => r,
|
||||
};
|
||||
|
|
|
@ -649,10 +649,16 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||
self.mk_ty(Error(reported))
|
||||
}
|
||||
|
||||
/// Constructs a `RegionKind::ReError` lifetime.
|
||||
#[track_caller]
|
||||
pub fn re_error(self, reported: ErrorGuaranteed) -> Region<'tcx> {
|
||||
self.mk_region(ty::ReError(reported))
|
||||
}
|
||||
|
||||
/// Constructs a `RegionKind::ReError` lifetime and registers a `delay_span_bug` to ensure it
|
||||
/// gets used.
|
||||
#[track_caller]
|
||||
pub fn re_error(self) -> Region<'tcx> {
|
||||
pub fn re_error_misc(self) -> Region<'tcx> {
|
||||
self.re_error_with_message(
|
||||
DUMMY_SP,
|
||||
"RegionKind::ReError constructed but no error reported",
|
||||
|
@ -664,10 +670,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||
#[track_caller]
|
||||
pub fn re_error_with_message<S: Into<MultiSpan>>(self, span: S, msg: &str) -> Region<'tcx> {
|
||||
let reported = self.sess.delay_span_bug(span, msg);
|
||||
let r = ty::ReError(reported);
|
||||
Region(Interned::new_unchecked(
|
||||
self.interners.region.intern(r, |r| InternedInSet(self.interners.arena.alloc(r))).0,
|
||||
))
|
||||
self.re_error(reported)
|
||||
}
|
||||
|
||||
/// Like [TyCtxt::ty_error] but for constants, with current `ErrorGuaranteed`
|
||||
|
|
|
@ -100,7 +100,7 @@ impl GenericParamDef {
|
|||
preceding_substs: &[ty::GenericArg<'tcx>],
|
||||
) -> ty::GenericArg<'tcx> {
|
||||
match &self.kind {
|
||||
ty::GenericParamDefKind::Lifetime => tcx.re_error().into(),
|
||||
ty::GenericParamDefKind::Lifetime => tcx.re_error_misc().into(),
|
||||
ty::GenericParamDefKind::Type { .. } => tcx.ty_error().into(),
|
||||
ty::GenericParamDefKind::Const { .. } => {
|
||||
tcx.const_error(tcx.bound_type_of(self.def_id).subst(tcx, preceding_substs)).into()
|
||||
|
|
|
@ -127,7 +127,8 @@ impl<'tcx> TypeFolder<'tcx> for ReverseMapper<'tcx> {
|
|||
Some(u) => panic!("region mapped to unexpected kind: {:?}", u),
|
||||
None if self.do_not_error => self.tcx.lifetimes.re_static,
|
||||
None => {
|
||||
self.tcx
|
||||
let e = self
|
||||
.tcx
|
||||
.sess
|
||||
.struct_span_err(self.span, "non-defining opaque type use in defining scope")
|
||||
.span_label(
|
||||
|
@ -140,7 +141,7 @@ impl<'tcx> TypeFolder<'tcx> for ReverseMapper<'tcx> {
|
|||
)
|
||||
.emit();
|
||||
|
||||
self.tcx().re_error()
|
||||
self.tcx().re_error(e)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue