Bail out early if there already were errors
This commit is contained in:
parent
29c8732436
commit
6560d77a53
@ -48,6 +48,10 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
||||
instantiated_ty: Ty<'tcx>,
|
||||
span: Span,
|
||||
) -> Ty<'tcx> {
|
||||
if self.is_tainted_by_errors() {
|
||||
return self.tcx.ty_error();
|
||||
}
|
||||
|
||||
let OpaqueTypeKey { def_id, substs } = opaque_type_key;
|
||||
|
||||
// Use substs to build up a reverse map from regions to their
|
||||
@ -67,7 +71,6 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
||||
// after producing an error for each of them.
|
||||
let definition_ty = instantiated_ty.fold_with(&mut ReverseMapper::new(
|
||||
self.tcx,
|
||||
self.is_tainted_by_errors(),
|
||||
def_id,
|
||||
map,
|
||||
instantiated_ty,
|
||||
@ -82,10 +85,6 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
||||
struct ReverseMapper<'tcx> {
|
||||
tcx: TyCtxt<'tcx>,
|
||||
|
||||
/// If errors have already been reported in this fn, we suppress
|
||||
/// our own errors because they are sometimes derivative.
|
||||
tainted_by_errors: bool,
|
||||
|
||||
opaque_type_def_id: DefId,
|
||||
map: FxHashMap<GenericArg<'tcx>, GenericArg<'tcx>>,
|
||||
map_missing_regions_to_empty: bool,
|
||||
@ -100,7 +99,6 @@ struct ReverseMapper<'tcx> {
|
||||
impl<'tcx> ReverseMapper<'tcx> {
|
||||
fn new(
|
||||
tcx: TyCtxt<'tcx>,
|
||||
tainted_by_errors: bool,
|
||||
opaque_type_def_id: DefId,
|
||||
map: FxHashMap<GenericArg<'tcx>, GenericArg<'tcx>>,
|
||||
hidden_ty: Ty<'tcx>,
|
||||
@ -108,7 +106,6 @@ impl<'tcx> ReverseMapper<'tcx> {
|
||||
) -> Self {
|
||||
Self {
|
||||
tcx,
|
||||
tainted_by_errors,
|
||||
opaque_type_def_id,
|
||||
map,
|
||||
map_missing_regions_to_empty: false,
|
||||
@ -167,9 +164,7 @@ impl<'tcx> TypeFolder<'tcx> for ReverseMapper<'tcx> {
|
||||
match self.map.get(&r.into()).map(|k| k.unpack()) {
|
||||
Some(GenericArgKind::Lifetime(r1)) => r1,
|
||||
Some(u) => panic!("region mapped to unexpected kind: {:?}", u),
|
||||
None if self.map_missing_regions_to_empty || self.tainted_by_errors => {
|
||||
self.tcx.lifetimes.re_root_empty
|
||||
}
|
||||
None if self.map_missing_regions_to_empty => self.tcx.lifetimes.re_root_empty,
|
||||
None if generics.parent.is_some() => {
|
||||
if let Some(hidden_ty) = self.hidden_ty.take() {
|
||||
unexpected_hidden_region_diagnostic(
|
||||
|
@ -24,15 +24,6 @@ LL | t
|
||||
|
|
||||
= help: consider adding an explicit lifetime bound `T: 'static`...
|
||||
|
||||
error[E0310]: the parameter type `T` may not live long enough
|
||||
--> $DIR/generic_type_does_not_live_long_enough.rs:10:24
|
||||
|
|
||||
LL | type WrongGeneric<T> = impl 'static;
|
||||
| ^^^^^^^^^^^^
|
||||
|
|
||||
= help: consider adding an explicit lifetime bound `T: 'static`...
|
||||
= note: ...so that the type `T` will meet its required lifetime bounds
|
||||
|
||||
error: aborting due to 4 previous errors
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0310`.
|
||||
|
@ -10,29 +10,5 @@ error: higher-ranked subtype error
|
||||
LL | |x| x
|
||||
| ^^^^^
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/issue-57611-trait-alias.rs:17:16
|
||||
|
|
||||
LL | type Bar = impl Baz<Self, Self>;
|
||||
| ^^^^^^^^^^^^^^^^^^^^ one type is more general than the other
|
||||
|
|
||||
= note: expected type `for<'r> Fn<(&'r X,)>`
|
||||
found type `Fn<(&'static X,)>`
|
||||
note: this closure does not fulfill the lifetime requirements
|
||||
--> $DIR/issue-57611-trait-alias.rs:20:9
|
||||
|
|
||||
LL | |x| x
|
||||
| ^^^^^
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
error: implementation of `FnOnce` is not general enough
|
||||
--> $DIR/issue-57611-trait-alias.rs:17:16
|
||||
|
|
||||
LL | type Bar = impl Baz<Self, Self>;
|
||||
| ^^^^^^^^^^^^^^^^^^^^ implementation of `FnOnce` is not general enough
|
||||
|
|
||||
= note: closure with signature `fn(&'static X) -> &'static X` must implement `FnOnce<(&'0 X,)>`, for any lifetime `'0`...
|
||||
= note: ...but it actually implements `FnOnce<(&'static X,)>`
|
||||
|
||||
error: aborting due to 4 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0308`.
|
||||
|
Loading…
x
Reference in New Issue
Block a user