@@ -1084,15 +1084,42 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
10841084 where
10851085 I : Iterator < Item = ty:: PolyTraitRef < ' tcx > > ,
10861086 {
1087- let mut matching_candidates = all_candidates ( ) . filter ( |r| {
1088- self . trait_defines_associated_item_named ( r. def_id ( ) , ty:: AssocKind :: Type , assoc_name)
1089- } ) ;
1090- let mut const_candidates = all_candidates ( ) . filter ( |r| {
1091- self . trait_defines_associated_item_named ( r. def_id ( ) , ty:: AssocKind :: Const , assoc_name)
1092- } ) ;
1087+ let mut matching_candidates = all_candidates ( )
1088+ . filter ( |r| {
1089+ self . trait_defines_associated_item_named (
1090+ r. def_id ( ) ,
1091+ ty:: AssocKind :: Type ,
1092+ assoc_name,
1093+ )
1094+ } )
1095+ // For the purposes of an associated type, we only care
1096+ // about supertraits where the host effect is set to true.
1097+ . filter ( |trait_ref| {
1098+ let tcx = self . tcx ( ) ;
1099+ let generics = tcx. generics_of ( trait_ref. def_id ( ) ) ;
1100+ generics. host_effect_index . map_or ( true , |idx| {
1101+ trait_ref. skip_binder ( ) . args . const_at ( idx) == tcx. consts . true_
1102+ } )
1103+ } ) ;
1104+ let mut const_candidates = all_candidates ( )
1105+ . filter ( |r| {
1106+ self . trait_defines_associated_item_named (
1107+ r. def_id ( ) ,
1108+ ty:: AssocKind :: Const ,
1109+ assoc_name,
1110+ )
1111+ } )
1112+ // For the purposes of an associated const, we only care
1113+ // about supertraits where the host effect is set to true.
1114+ . filter ( |trait_ref| {
1115+ let tcx = self . tcx ( ) ;
1116+ let generics = tcx. generics_of ( trait_ref. def_id ( ) ) ;
1117+ generics. host_effect_index . map_or ( true , |idx| {
1118+ trait_ref. skip_binder ( ) . args . const_at ( idx) == tcx. consts . true_
1119+ } )
1120+ } ) ;
10931121
1094- let ( mut bound, mut next_cand) = match ( matching_candidates. next ( ) , const_candidates. next ( ) )
1095- {
1122+ let ( bound, next_cand) = match ( matching_candidates. next ( ) , const_candidates. next ( ) ) {
10961123 ( Some ( bound) , _) => ( bound, matching_candidates. next ( ) ) ,
10971124 ( None , Some ( bound) ) => ( bound, const_candidates. next ( ) ) ,
10981125 ( None , None ) => {
@@ -1108,37 +1135,6 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
11081135 } ;
11091136 debug ! ( ?bound) ;
11101137
1111- // look for a candidate that is not the same as our first bound, disregarding
1112- // whether the bound is const.
1113- while let Some ( mut bound2) = next_cand {
1114- debug ! ( ?bound2) ;
1115- let tcx = self . tcx ( ) ;
1116- if bound2. bound_vars ( ) != bound. bound_vars ( ) {
1117- break ;
1118- }
1119-
1120- let generics = tcx. generics_of ( bound. def_id ( ) ) ;
1121- let Some ( host_index) = generics. host_effect_index else { break } ;
1122-
1123- // always return the bound that contains the host param.
1124- if let ty:: ConstKind :: Param ( _) = bound2. skip_binder ( ) . args . const_at ( host_index) . kind ( ) {
1125- ( bound, bound2) = ( bound2, bound) ;
1126- }
1127-
1128- let unconsted_args = bound
1129- . skip_binder ( )
1130- . args
1131- . iter ( )
1132- . enumerate ( )
1133- . map ( |( n, arg) | if host_index == n { tcx. consts . true_ . into ( ) } else { arg } ) ;
1134-
1135- if unconsted_args. eq ( bound2. skip_binder ( ) . args . iter ( ) ) {
1136- next_cand = matching_candidates. next ( ) . or_else ( || const_candidates. next ( ) ) ;
1137- } else {
1138- break ;
1139- }
1140- }
1141-
11421138 if let Some ( bound2) = next_cand {
11431139 debug ! ( ?bound2) ;
11441140
@@ -1226,9 +1222,19 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
12261222 assoc_name : Ident ,
12271223 span : Span ,
12281224 ) -> Result < ty:: PolyTraitRef < ' tcx > , ErrorGuaranteed > {
1229- let mut matching_candidates = all_candidates. filter ( |r| {
1230- self . trait_defines_associated_item_named ( r. def_id ( ) , ty:: AssocKind :: Fn , assoc_name)
1231- } ) ;
1225+ let mut matching_candidates = all_candidates
1226+ . filter ( |r| {
1227+ self . trait_defines_associated_item_named ( r. def_id ( ) , ty:: AssocKind :: Fn , assoc_name)
1228+ } )
1229+ // For the purposes of an RTN bound, we only care
1230+ // about supertraits where the host effect is set to true.
1231+ . filter ( |trait_ref| {
1232+ let tcx = self . tcx ( ) ;
1233+ let generics = tcx. generics_of ( trait_ref. def_id ( ) ) ;
1234+ generics. host_effect_index . map_or ( true , |idx| {
1235+ trait_ref. skip_binder ( ) . args . const_at ( idx) == tcx. consts . true_
1236+ } )
1237+ } ) ;
12321238
12331239 let candidate = match matching_candidates. next ( ) {
12341240 Some ( candidate) => candidate,
0 commit comments