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
|
@ -661,6 +661,30 @@ 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_misc(self) -> Region<'tcx> {
|
||||
self.re_error_with_message(
|
||||
DUMMY_SP,
|
||||
"RegionKind::ReError constructed but no error reported",
|
||||
)
|
||||
}
|
||||
|
||||
/// Constructs a `RegionKind::ReError` lifetime and registers a `delay_span_bug` with the given
|
||||
/// `msg` to ensure it gets used.
|
||||
#[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);
|
||||
self.re_error(reported)
|
||||
}
|
||||
|
||||
/// Like [TyCtxt::ty_error] but for constants, with current `ErrorGuaranteed`
|
||||
#[track_caller]
|
||||
pub fn const_error_with_guaranteed(
|
||||
|
|
|
@ -100,7 +100,7 @@ impl GenericParamDef {
|
|||
preceding_substs: &[ty::GenericArg<'tcx>],
|
||||
) -> ty::GenericArg<'tcx> {
|
||||
match &self.kind {
|
||||
ty::GenericParamDefKind::Lifetime => tcx.lifetimes.re_static.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()
|
||||
|
|
|
@ -109,6 +109,8 @@ impl<'tcx> TypeFolder<'tcx> for ReverseMapper<'tcx> {
|
|||
// them.
|
||||
ty::ReErased => return r,
|
||||
|
||||
ty::ReError(_) => return r,
|
||||
|
||||
// The regions that we expect from borrow checking.
|
||||
ty::ReEarlyBound(_) | ty::ReFree(_) => {}
|
||||
|
||||
|
@ -125,20 +127,21 @@ 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(
|
||||
self.span,
|
||||
format!(
|
||||
"lifetime `{}` is part of concrete type but not used in \
|
||||
parameter list of the `impl Trait` type alias",
|
||||
parameter list of the `impl Trait` type alias",
|
||||
r
|
||||
),
|
||||
)
|
||||
.emit();
|
||||
|
||||
self.tcx().lifetimes.re_static
|
||||
self.tcx().re_error(e)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2114,7 +2114,7 @@ impl<'tcx> PrettyPrinter<'tcx> for FmtPrinter<'_, 'tcx> {
|
|||
|
||||
ty::ReVar(_) if identify_regions => true,
|
||||
|
||||
ty::ReVar(_) | ty::ReErased => false,
|
||||
ty::ReVar(_) | ty::ReErased | ty::ReError(_) => false,
|
||||
|
||||
ty::ReStatic => true,
|
||||
}
|
||||
|
@ -2194,6 +2194,7 @@ impl<'tcx> FmtPrinter<'_, 'tcx> {
|
|||
}
|
||||
ty::ReVar(_) => {}
|
||||
ty::ReErased => {}
|
||||
ty::ReError(_) => {}
|
||||
ty::ReStatic => {
|
||||
p!("'static");
|
||||
return Ok(self);
|
||||
|
|
|
@ -1623,9 +1623,15 @@ impl<'tcx> Region<'tcx> {
|
|||
ty::ReVar(..) => false,
|
||||
ty::RePlaceholder(placeholder) => placeholder.name.is_named(),
|
||||
ty::ReErased => false,
|
||||
ty::ReError(_) => false,
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn is_error(self) -> bool {
|
||||
matches!(*self, ty::ReError(_))
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn is_static(self) -> bool {
|
||||
matches!(*self, ty::ReStatic)
|
||||
|
@ -1686,6 +1692,7 @@ impl<'tcx> Region<'tcx> {
|
|||
ty::ReErased => {
|
||||
flags = flags | TypeFlags::HAS_RE_ERASED;
|
||||
}
|
||||
ty::ReError(_) => {}
|
||||
}
|
||||
|
||||
debug!("type_flags({:?}) = {:?}", self, flags);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue