@@ -117,7 +117,7 @@ impl<'tcx> TypeRelation<'tcx> for TypeRelating<'_, '_, 'tcx> {
117117 ty:: Invariant => {
118118 infcx. inner . borrow_mut ( ) . type_variables ( ) . equate ( a_id, b_id) ;
119119 }
120- ty:: Bivariant => {
120+ ty:: Errvariant ( _ ) | ty :: Bivariant => {
121121 unreachable ! ( "Expected bivariance to be handled in relate_with_variance" )
122122 }
123123 }
@@ -204,7 +204,7 @@ impl<'tcx> TypeRelation<'tcx> for TypeRelating<'_, '_, 'tcx> {
204204 . unwrap_region_constraints ( )
205205 . make_eqregion ( origin, a, b) ;
206206 }
207- ty:: Bivariant => {
207+ ty:: Errvariant ( _ ) | ty :: Bivariant => {
208208 unreachable ! ( "Expected bivariance to be handled in relate_with_variance" )
209209 }
210210 }
@@ -289,11 +289,15 @@ impl<'tcx> TypeRelation<'tcx> for TypeRelating<'_, '_, 'tcx> {
289289 self . relate ( a, b)
290290 } ) ?;
291291 }
292- ty:: Bivariant => {
292+ ty:: Errvariant ( _ ) | ty :: Bivariant => {
293293 unreachable ! ( "Expected bivariance to be handled in relate_with_variance" )
294294 }
295295 }
296- }
296+ ty:: Errvariant ( guar) => {
297+ infcx. set_tainted_by_errors ( guar) ;
298+ return self . relate ( a, b) ;
299+ }
300+ ty:: Bivariant => {
297301
298302 Ok ( a)
299303 }
@@ -341,9 +345,13 @@ impl<'tcx> ObligationEmittingRelation<'tcx> for TypeRelating<'_, '_, 'tcx> {
341345 b. into ( ) ,
342346 ty:: AliasRelationDirection :: Equate ,
343347 ) ,
344- ty:: Variance :: Bivariant => {
348+ ty:: Variance :: Errvariant ( _ ) | ty :: Variance :: Bivariant => {
345349 unreachable ! ( "Expected bivariance to be handled in relate_with_variance" )
346350 }
347351 } ) ] ) ;
348- }
352+ ty:: Variance :: Errvariant ( guar) => {
353+ self . fields . infcx . set_tainted_by_errors ( guar) ;
354+ ty:: PredicateKind :: Ambiguous
355+ }
356+ ty:: Variance :: Bivariant => {
349357}
0 commit comments