@@ -235,7 +235,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
235
235
freshener : infcx. freshener ( ) ,
236
236
intercrate_ambiguity_causes : None ,
237
237
query_mode : TraitQueryMode :: Standard ,
238
- treat_inductive_cycle : TreatInductiveCycleAs :: Recur ,
238
+ treat_inductive_cycle : TreatInductiveCycleAs :: Ambig ,
239
239
}
240
240
}
241
241
@@ -1619,16 +1619,23 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
1619
1619
for bound in
1620
1620
self . tcx ( ) . item_bounds ( alias_ty. def_id ) . instantiate ( self . tcx ( ) , alias_ty. args )
1621
1621
{
1622
- // HACK: On subsequent recursions, we only care about bounds that don't
1622
+ // HACK: In the initial recursion, we only care about bounds for the
1623
+ // `self_ty`. On subsequent recursions, we care about bounds that don't
1623
1624
// share the same type as `self_ty`. This is because for truly rigid
1624
1625
// projections, we will never be able to equate, e.g. `<T as Tr>::A`
1625
1626
// with `<<T as Tr>::A as Tr>::A`.
1626
- if in_parent_alias_type {
1627
- match bound. kind ( ) . skip_binder ( ) {
1628
- ty:: ClauseKind :: Trait ( tr) if tr. self_ty ( ) == self_ty => continue ,
1629
- ty:: ClauseKind :: Projection ( p) if p. self_ty ( ) == self_ty => continue ,
1630
- _ => { }
1627
+ match bound. kind ( ) . skip_binder ( ) {
1628
+ ty:: ClauseKind :: Trait ( tr)
1629
+ if ( tr. self_ty ( ) == self_ty) ^ !in_parent_alias_type =>
1630
+ {
1631
+ continue ;
1632
+ }
1633
+ ty:: ClauseKind :: Projection ( p)
1634
+ if ( p. self_ty ( ) == self_ty) ^ !in_parent_alias_type =>
1635
+ {
1636
+ continue ;
1631
1637
}
1638
+ _ => { }
1632
1639
}
1633
1640
1634
1641
for_each ( self , bound, idx) ?;
0 commit comments