@@ -774,18 +774,23 @@ 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 ) ) ]
786793 fn assemble_inherent_candidates_from_param ( & mut self , param_ty : ty:: ParamTy ) {
787- // FIXME: do we want to commit to this behavior for param bounds?
788-
789794 let bounds = self . param_env . caller_bounds ( ) . iter ( ) . filter_map ( |predicate| {
790795 let bound_predicate = predicate. kind ( ) ;
791796 match bound_predicate. skip_binder ( ) {
@@ -806,7 +811,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
806811 }
807812 } ) ;
808813
809- self . elaborate_bounds ( bounds, |this, poly_trait_ref, item| {
814+ self . assemble_candidates_for_bounds ( bounds, |this, poly_trait_ref, item| {
810815 this. push_candidate (
811816 Candidate {
812817 item,
@@ -820,15 +825,14 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
820825
821826 // Do a search through a list of bounds, using a callback to actually
822827 // create the candidates.
823- fn elaborate_bounds < F > (
828+ fn assemble_candidates_for_bounds < F > (
824829 & mut self ,
825830 bounds : impl Iterator < Item = ty:: PolyTraitRef < ' tcx > > ,
826831 mut mk_cand : F ,
827832 ) where
828833 F : for < ' b > FnMut ( & mut ProbeContext < ' b , ' tcx > , ty:: PolyTraitRef < ' tcx > , ty:: AssocItem ) ,
829834 {
830- let tcx = self . tcx ;
831- for bound_trait_ref in traits:: transitive_bounds ( tcx, bounds) {
835+ for bound_trait_ref in bounds {
832836 debug ! ( "elaborate_bounds(bound_trait_ref={:?})" , bound_trait_ref) ;
833837 for item in self . impl_or_trait_item ( bound_trait_ref. def_id ( ) ) {
834838 if !self . has_applicable_self ( & item) {
0 commit comments