@@ -117,7 +117,7 @@ impl<'tcx> TypeRelation<'tcx> for TypeRelating<'_, '_, 'tcx> {
117
117
ty:: Invariant => {
118
118
infcx. inner . borrow_mut ( ) . type_variables ( ) . equate ( a_id, b_id) ;
119
119
}
120
- ty:: Bivariant => {
120
+ ty:: Errvariant ( _ ) | ty :: Bivariant => {
121
121
unreachable ! ( "Expected bivariance to be handled in relate_with_variance" )
122
122
}
123
123
}
@@ -204,7 +204,7 @@ impl<'tcx> TypeRelation<'tcx> for TypeRelating<'_, '_, 'tcx> {
204
204
. unwrap_region_constraints ( )
205
205
. make_eqregion ( origin, a, b) ;
206
206
}
207
- ty:: Bivariant => {
207
+ ty:: Errvariant ( _ ) | ty :: Bivariant => {
208
208
unreachable ! ( "Expected bivariance to be handled in relate_with_variance" )
209
209
}
210
210
}
@@ -289,11 +289,15 @@ impl<'tcx> TypeRelation<'tcx> for TypeRelating<'_, '_, 'tcx> {
289
289
self . relate ( a, b)
290
290
} ) ?;
291
291
}
292
- ty:: Bivariant => {
292
+ ty:: Errvariant ( _ ) | ty :: Bivariant => {
293
293
unreachable ! ( "Expected bivariance to be handled in relate_with_variance" )
294
294
}
295
295
}
296
- }
296
+ ty:: Errvariant ( guar) => {
297
+ infcx. set_tainted_by_errors ( guar) ;
298
+ return self . relate ( a, b) ;
299
+ }
300
+ ty:: Bivariant => {
297
301
298
302
Ok ( a)
299
303
}
@@ -341,9 +345,13 @@ impl<'tcx> ObligationEmittingRelation<'tcx> for TypeRelating<'_, '_, 'tcx> {
341
345
b. into ( ) ,
342
346
ty:: AliasRelationDirection :: Equate ,
343
347
) ,
344
- ty:: Variance :: Bivariant => {
348
+ ty:: Variance :: Errvariant ( _ ) | ty :: Variance :: Bivariant => {
345
349
unreachable ! ( "Expected bivariance to be handled in relate_with_variance" )
346
350
}
347
351
} ) ] ) ;
348
- }
352
+ ty:: Variance :: Errvariant ( guar) => {
353
+ self . fields . infcx . set_tainted_by_errors ( guar) ;
354
+ ty:: PredicateKind :: Ambiguous
355
+ }
356
+ ty:: Variance :: Bivariant => {
349
357
}
0 commit comments