@@ -484,22 +484,16 @@ impl<'a, 'gcx, 'tcx> ProbeContext<'a, 'gcx, 'tcx> {
484
484
485
485
debug ! ( "assemble_inherent_impl_probe {:?}" , impl_def_id) ;
486
486
487
- let items = self . impl_or_trait_item ( impl_def_id) ;
488
- if items. len ( ) < 1 {
489
- return // No method with correct name on this impl
490
- }
491
-
492
- if self . looking_for . is_method_name ( ) {
493
- let item = items[ 0 ] ;
494
-
487
+ for item in self . impl_or_trait_item ( impl_def_id) {
495
488
if !self . has_applicable_self ( & item) {
496
489
// No receiver declared. Not a candidate.
497
- return self . record_static_candidate ( ImplSource ( impl_def_id) ) ;
490
+ self . record_static_candidate ( ImplSource ( impl_def_id) ) ;
491
+ continue
498
492
}
499
493
500
494
if !item. vis . is_accessible_from ( self . body_id , & self . tcx . map ) {
501
495
self . private_candidate = Some ( item. def ( ) ) ;
502
- return ;
496
+ continue
503
497
}
504
498
505
499
let ( impl_ty, impl_substs) = self . impl_ty_and_substs ( impl_def_id) ;
@@ -523,41 +517,6 @@ impl<'a, 'gcx, 'tcx> ProbeContext<'a, 'gcx, 'tcx> {
523
517
kind : InherentImplCandidate ( impl_substs, obligations) ,
524
518
import_id : self . import_id ,
525
519
} ) ;
526
- } else {
527
- for item in items {
528
- if !self . has_applicable_self ( & item) {
529
- // No receiver declared. Not a candidate.
530
- self . record_static_candidate ( ImplSource ( impl_def_id) ) ;
531
- continue
532
- }
533
-
534
- if !item. vis . is_accessible_from ( self . body_id , & self . tcx . map ) {
535
- self . private_candidate = Some ( item. def ( ) ) ;
536
- continue
537
- }
538
-
539
- let ( impl_ty, impl_substs) = self . impl_ty_and_substs ( impl_def_id) ;
540
- let impl_ty = impl_ty. subst ( self . tcx , impl_substs) ;
541
-
542
- // Determine the receiver type that the method itself expects.
543
- let xform_self_ty = self . xform_self_ty ( & item, impl_ty, impl_substs) ;
544
-
545
- // We can't use normalize_associated_types_in as it will pollute the
546
- // fcx's fulfillment context after this probe is over.
547
- let cause = traits:: ObligationCause :: misc ( self . span , self . body_id ) ;
548
- let mut selcx = & mut traits:: SelectionContext :: new ( self . fcx ) ;
549
- let traits:: Normalized { value : xform_self_ty, obligations } =
550
- traits:: normalize ( selcx, cause, & xform_self_ty) ;
551
- debug ! ( "assemble_inherent_impl_probe: xform_self_ty = {:?}" ,
552
- xform_self_ty) ;
553
-
554
- self . inherent_candidates . push ( Candidate {
555
- xform_self_ty : xform_self_ty,
556
- item : item,
557
- kind : InherentImplCandidate ( impl_substs, obligations) ,
558
- import_id : self . import_id ,
559
- } ) ;
560
- }
561
520
}
562
521
}
563
522
@@ -651,16 +610,12 @@ impl<'a, 'gcx, 'tcx> ProbeContext<'a, 'gcx, 'tcx> {
651
610
652
611
let tcx = self . tcx ;
653
612
for bound_trait_ref in traits:: transitive_bounds ( tcx, bounds) {
654
- let items = self . impl_or_trait_item ( bound_trait_ref. def_id ( ) ) ;
655
- if items. len ( ) < 1 {
656
- continue
657
- }
658
- let item = items[ 0 ] ;
659
-
660
- if !self . has_applicable_self ( & item) {
661
- self . record_static_candidate ( TraitSource ( bound_trait_ref. def_id ( ) ) ) ;
662
- } else {
663
- mk_cand ( self , bound_trait_ref, item) ;
613
+ for item in self . impl_or_trait_item ( bound_trait_ref. def_id ( ) ) {
614
+ if !self . has_applicable_self ( & item) {
615
+ self . record_static_candidate ( TraitSource ( bound_trait_ref. def_id ( ) ) ) ;
616
+ } else {
617
+ mk_cand ( self , bound_trait_ref, item) ;
618
+ }
664
619
}
665
620
}
666
621
}
@@ -717,26 +672,22 @@ impl<'a, 'gcx, 'tcx> ProbeContext<'a, 'gcx, 'tcx> {
717
672
debug ! ( "assemble_extension_candidates_for_trait(trait_def_id={:?})" ,
718
673
trait_def_id) ;
719
674
720
- let items = self . impl_or_trait_item ( trait_def_id) ;
721
- if items. len ( ) < 1 {
722
- return Ok ( ( ) ) ;
723
- }
724
- let item = items[ 0 ] ;
725
-
726
- // Check whether `trait_def_id` defines a method with suitable name:
727
- if !self . has_applicable_self ( & item) {
728
- debug ! ( "method has inapplicable self" ) ;
729
- self . record_static_candidate ( TraitSource ( trait_def_id) ) ;
730
- return Ok ( ( ) ) ;
731
- }
675
+ for item in self . impl_or_trait_item ( trait_def_id) {
676
+ // Check whether `trait_def_id` defines a method with suitable name:
677
+ if !self . has_applicable_self ( & item) {
678
+ debug ! ( "method has inapplicable self" ) ;
679
+ self . record_static_candidate ( TraitSource ( trait_def_id) ) ;
680
+ continue ;
681
+ }
732
682
733
- self . assemble_extension_candidates_for_trait_impls ( trait_def_id, item. clone ( ) ) ;
683
+ self . assemble_extension_candidates_for_trait_impls ( trait_def_id, item. clone ( ) ) ;
734
684
735
- self . assemble_closure_candidates ( trait_def_id, item. clone ( ) ) ?;
685
+ self . assemble_closure_candidates ( trait_def_id, item. clone ( ) ) ?;
736
686
737
- self . assemble_projection_candidates ( trait_def_id, item. clone ( ) ) ;
687
+ self . assemble_projection_candidates ( trait_def_id, item. clone ( ) ) ;
738
688
739
- self . assemble_where_clause_candidates ( trait_def_id, item. clone ( ) ) ;
689
+ self . assemble_where_clause_candidates ( trait_def_id, item. clone ( ) ) ;
690
+ }
740
691
741
692
Ok ( ( ) )
742
693
}
0 commit comments