@@ -774,12 +774,19 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
774774 // instantiation that replaces `Self` with the object type itself. Hence,
775775 // a `&self` method will wind up with an argument type like `&dyn Trait`.
776776 let trait_ref = principal. with_self_ty ( self . tcx , self_ty) ;
777- self . elaborate_bounds ( iter:: once ( trait_ref) , |this, new_trait_ref, item| {
778- this. push_candidate (
779- Candidate { item, kind : ObjectCandidate ( new_trait_ref) , import_ids : smallvec ! [ ] } ,
780- true ,
781- ) ;
782- } ) ;
777+ self . assemble_candidates_for_bounds (
778+ traits:: supertraits ( self . tcx , trait_ref) ,
779+ |this, new_trait_ref, item| {
780+ this. push_candidate (
781+ Candidate {
782+ item,
783+ kind : ObjectCandidate ( new_trait_ref) ,
784+ import_ids : smallvec ! [ ] ,
785+ } ,
786+ true ,
787+ ) ;
788+ } ,
789+ ) ;
783790 }
784791
785792 #[ instrument( level = "debug" , skip( self ) ) ]
@@ -806,7 +813,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
806813 }
807814 } ) ;
808815
809- self . elaborate_bounds ( bounds, |this, poly_trait_ref, item| {
816+ self . assemble_candidates_for_bounds ( bounds, |this, poly_trait_ref, item| {
810817 this. push_candidate (
811818 Candidate {
812819 item,
@@ -820,15 +827,14 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
820827
821828 // Do a search through a list of bounds, using a callback to actually
822829 // create the candidates.
823- fn elaborate_bounds < F > (
830+ fn assemble_candidates_for_bounds < F > (
824831 & mut self ,
825832 bounds : impl Iterator < Item = ty:: PolyTraitRef < ' tcx > > ,
826833 mut mk_cand : F ,
827834 ) where
828835 F : for < ' b > FnMut ( & mut ProbeContext < ' b , ' tcx > , ty:: PolyTraitRef < ' tcx > , ty:: AssocItem ) ,
829836 {
830- let tcx = self . tcx ;
831- for bound_trait_ref in traits:: transitive_bounds ( tcx, bounds) {
837+ for bound_trait_ref in bounds {
832838 debug ! ( "elaborate_bounds(bound_trait_ref={:?})" , bound_trait_ref) ;
833839 for item in self . impl_or_trait_item ( bound_trait_ref. def_id ( ) ) {
834840 if !self . has_applicable_self ( & item) {
0 commit comments