@@ -48,6 +48,10 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
48
48
instantiated_ty : Ty < ' tcx > ,
49
49
span : Span ,
50
50
) -> Ty < ' tcx > {
51
+ if self . is_tainted_by_errors ( ) {
52
+ return self . tcx . ty_error ( ) ;
53
+ }
54
+
51
55
let OpaqueTypeKey { def_id, substs } = opaque_type_key;
52
56
53
57
// 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> {
67
71
// after producing an error for each of them.
68
72
let definition_ty = instantiated_ty. fold_with ( & mut ReverseMapper :: new (
69
73
self . tcx ,
70
- self . is_tainted_by_errors ( ) ,
71
74
def_id,
72
75
map,
73
76
instantiated_ty,
@@ -82,10 +85,6 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
82
85
struct ReverseMapper < ' tcx > {
83
86
tcx : TyCtxt < ' tcx > ,
84
87
85
- /// If errors have already been reported in this fn, we suppress
86
- /// our own errors because they are sometimes derivative.
87
- tainted_by_errors : bool ,
88
-
89
88
opaque_type_def_id : DefId ,
90
89
map : FxHashMap < GenericArg < ' tcx > , GenericArg < ' tcx > > ,
91
90
map_missing_regions_to_empty : bool ,
@@ -100,15 +99,13 @@ struct ReverseMapper<'tcx> {
100
99
impl < ' tcx > ReverseMapper < ' tcx > {
101
100
fn new (
102
101
tcx : TyCtxt < ' tcx > ,
103
- tainted_by_errors : bool ,
104
102
opaque_type_def_id : DefId ,
105
103
map : FxHashMap < GenericArg < ' tcx > , GenericArg < ' tcx > > ,
106
104
hidden_ty : Ty < ' tcx > ,
107
105
span : Span ,
108
106
) -> Self {
109
107
Self {
110
108
tcx,
111
- tainted_by_errors,
112
109
opaque_type_def_id,
113
110
map,
114
111
map_missing_regions_to_empty : false ,
@@ -167,9 +164,7 @@ impl<'tcx> TypeFolder<'tcx> for ReverseMapper<'tcx> {
167
164
match self . map . get ( & r. into ( ) ) . map ( |k| k. unpack ( ) ) {
168
165
Some ( GenericArgKind :: Lifetime ( r1) ) => r1,
169
166
Some ( u) => panic ! ( "region mapped to unexpected kind: {:?}" , u) ,
170
- None if self . map_missing_regions_to_empty || self . tainted_by_errors => {
171
- self . tcx . lifetimes . re_root_empty
172
- }
167
+ None if self . map_missing_regions_to_empty => self . tcx . lifetimes . re_root_empty ,
173
168
None if generics. parent . is_some ( ) => {
174
169
if let Some ( hidden_ty) = self . hidden_ty . take ( ) {
175
170
unexpected_hidden_region_diagnostic (
0 commit comments