@@ -774,12 +774,19 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
774
774
// instantiation that replaces `Self` with the object type itself. Hence,
775
775
// a `&self` method will wind up with an argument type like `&dyn Trait`.
776
776
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
+ ) ;
783
790
}
784
791
785
792
#[ instrument( level = "debug" , skip( self ) ) ]
@@ -806,7 +813,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
806
813
}
807
814
} ) ;
808
815
809
- self . elaborate_bounds ( bounds, |this, poly_trait_ref, item| {
816
+ self . assemble_candidates_for_bounds ( bounds, |this, poly_trait_ref, item| {
810
817
this. push_candidate (
811
818
Candidate {
812
819
item,
@@ -820,15 +827,14 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
820
827
821
828
// Do a search through a list of bounds, using a callback to actually
822
829
// create the candidates.
823
- fn elaborate_bounds < F > (
830
+ fn assemble_candidates_for_bounds < F > (
824
831
& mut self ,
825
832
bounds : impl Iterator < Item = ty:: PolyTraitRef < ' tcx > > ,
826
833
mut mk_cand : F ,
827
834
) where
828
835
F : for < ' b > FnMut ( & mut ProbeContext < ' b , ' tcx > , ty:: PolyTraitRef < ' tcx > , ty:: AssocItem ) ,
829
836
{
830
- let tcx = self . tcx ;
831
- for bound_trait_ref in traits:: transitive_bounds ( tcx, bounds) {
837
+ for bound_trait_ref in bounds {
832
838
debug ! ( "elaborate_bounds(bound_trait_ref={:?})" , bound_trait_ref) ;
833
839
for item in self . impl_or_trait_item ( bound_trait_ref. def_id ( ) ) {
834
840
if !self . has_applicable_self ( & item) {
0 commit comments