@@ -1971,7 +1971,8 @@ fn named_associated_type_shorthand_candidates<'db, R>(
19711971 let mut search = |t : TraitRef < ' db > | -> Option < R > {
19721972 let trait_id = t. def_id . 0 ;
19731973 let mut checked_traits = FxHashSet :: default ( ) ;
1974- let mut check_trait = |trait_id : TraitId | {
1974+ let mut check_trait = |trait_ref : TraitRef < ' db > | {
1975+ let trait_id = trait_ref. def_id . 0 ;
19751976 let name = & db. trait_signature ( trait_id) . name ;
19761977 tracing:: debug!( ?trait_id, ?name) ;
19771978 if !checked_traits. insert ( trait_id) {
@@ -1982,37 +1983,39 @@ fn named_associated_type_shorthand_candidates<'db, R>(
19821983 tracing:: debug!( ?data. items) ;
19831984 for ( name, assoc_id) in & data. items {
19841985 if let & AssocItemId :: TypeAliasId ( alias) = assoc_id
1985- && let Some ( ty) = check_alias ( name, t , alias)
1986+ && let Some ( ty) = check_alias ( name, trait_ref , alias)
19861987 {
19871988 return Some ( ty) ;
19881989 }
19891990 }
19901991 None
19911992 } ;
1992- let mut stack: SmallVec < [ _ ; 4 ] > = smallvec ! [ trait_id ] ;
1993- while let Some ( trait_def_id ) = stack. pop ( ) {
1994- if let Some ( alias) = check_trait ( trait_def_id ) {
1993+ let mut stack: SmallVec < [ _ ; 4 ] > = smallvec ! [ t ] ;
1994+ while let Some ( trait_ref ) = stack. pop ( ) {
1995+ if let Some ( alias) = check_trait ( trait_ref ) {
19951996 return Some ( alias) ;
19961997 }
19971998 for pred in generic_predicates_filtered_by (
19981999 db,
1999- GenericDefId :: TraitId ( trait_def_id ) ,
2000+ GenericDefId :: TraitId ( trait_ref . def_id . 0 ) ,
20002001 PredicateFilter :: SelfTrait ,
20012002 // We are likely in the midst of lowering generic predicates of `def`.
20022003 // So, if we allow `pred == def` we might fall into an infinite recursion.
20032004 // Actually, we have already checked for the case `pred == def` above as we started
20042005 // with a stack including `trait_id`
2005- |pred| pred != def && pred == GenericDefId :: TraitId ( trait_def_id ) ,
2006+ |pred| pred != def && pred == GenericDefId :: TraitId ( trait_ref . def_id . 0 ) ,
20062007 )
20072008 . 0
20082009 . deref ( )
20092010 {
20102011 tracing:: debug!( ?pred) ;
2011- let trait_id = match pred. kind ( ) . skip_binder ( ) {
2012- rustc_type_ir:: ClauseKind :: Trait ( pred) => pred. def_id ( ) ,
2012+ let sup_trait_ref = match pred. kind ( ) . skip_binder ( ) {
2013+ rustc_type_ir:: ClauseKind :: Trait ( pred) => pred. trait_ref ,
20132014 _ => continue ,
20142015 } ;
2015- stack. push ( trait_id. 0 ) ;
2016+ let sup_trait_ref =
2017+ EarlyBinder :: bind ( sup_trait_ref) . instantiate ( interner, trait_ref. args ) ;
2018+ stack. push ( sup_trait_ref) ;
20162019 }
20172020 tracing:: debug!( ?stack) ;
20182021 }
0 commit comments