@@ -235,7 +235,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
235235 freshener : infcx. freshener ( ) ,
236236 intercrate_ambiguity_causes : None ,
237237 query_mode : TraitQueryMode :: Standard ,
238- treat_inductive_cycle : TreatInductiveCycleAs :: Recur ,
238+ treat_inductive_cycle : TreatInductiveCycleAs :: Ambig ,
239239 }
240240 }
241241
@@ -1619,16 +1619,23 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
16191619 for bound in
16201620 self . tcx ( ) . item_bounds ( alias_ty. def_id ) . instantiate ( self . tcx ( ) , alias_ty. args )
16211621 {
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
16231624 // share the same type as `self_ty`. This is because for truly rigid
16241625 // projections, we will never be able to equate, e.g. `<T as Tr>::A`
16251626 // 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 ;
16311637 }
1638+ _ => { }
16321639 }
16331640
16341641 for_each ( self , bound, idx) ?;
0 commit comments