@@ -31,6 +31,7 @@ use rustc::middle::stability;
31
31
use syntax:: ast;
32
32
use syntax:: util:: lev_distance:: { lev_distance, find_best_match_for_name} ;
33
33
use syntax_pos:: { Span , symbol:: Symbol } ;
34
+ use std:: iter;
34
35
use std:: mem;
35
36
use std:: ops:: Deref ;
36
37
use std:: rc:: Rc ;
@@ -627,7 +628,7 @@ impl<'a, 'gcx, 'tcx> ProbeContext<'a, 'gcx, 'tcx> {
627
628
// itself. Hence, a `&self` method will wind up with an
628
629
// argument type like `&Trait`.
629
630
let trait_ref = principal. with_self_ty ( self . tcx , self_ty) ;
630
- self . elaborate_bounds ( & [ trait_ref] , |this, new_trait_ref, item| {
631
+ self . elaborate_bounds ( iter :: once ( trait_ref) , |this, new_trait_ref, item| {
631
632
let new_trait_ref = this. erase_late_bound_regions ( & new_trait_ref) ;
632
633
633
634
let ( xform_self_ty, xform_ret_ty) =
@@ -645,7 +646,7 @@ impl<'a, 'gcx, 'tcx> ProbeContext<'a, 'gcx, 'tcx> {
645
646
param_ty : ty:: ParamTy ) {
646
647
// FIXME -- Do we want to commit to this behavior for param bounds?
647
648
648
- let bounds: Vec < _ > = self . param_env
649
+ let bounds = self . param_env
649
650
. caller_bounds
650
651
. iter ( )
651
652
. filter_map ( |predicate| {
@@ -667,10 +668,9 @@ impl<'a, 'gcx, 'tcx> ProbeContext<'a, 'gcx, 'tcx> {
667
668
ty:: Predicate :: TypeOutlives ( ..) |
668
669
ty:: Predicate :: ConstEvaluatable ( ..) => None ,
669
670
}
670
- } )
671
- . collect ( ) ;
671
+ } ) ;
672
672
673
- self . elaborate_bounds ( & bounds, |this, poly_trait_ref, item| {
673
+ self . elaborate_bounds ( bounds, |this, poly_trait_ref, item| {
674
674
let trait_ref = this. erase_late_bound_regions ( & poly_trait_ref) ;
675
675
676
676
let ( xform_self_ty, xform_ret_ty) =
@@ -693,15 +693,16 @@ impl<'a, 'gcx, 'tcx> ProbeContext<'a, 'gcx, 'tcx> {
693
693
694
694
// Do a search through a list of bounds, using a callback to actually
695
695
// create the candidates.
696
- fn elaborate_bounds < F > ( & mut self , bounds : & [ ty:: PolyTraitRef < ' tcx > ] , mut mk_cand : F )
696
+ fn elaborate_bounds < F > ( & mut self ,
697
+ bounds : impl Iterator < Item = ty:: PolyTraitRef < ' tcx > > ,
698
+ mut mk_cand : F )
697
699
where F : for < ' b > FnMut ( & mut ProbeContext < ' b , ' gcx , ' tcx > ,
698
700
ty:: PolyTraitRef < ' tcx > ,
699
701
ty:: AssociatedItem )
700
702
{
701
- debug ! ( "elaborate_bounds(bounds={:?})" , bounds) ;
702
-
703
703
let tcx = self . tcx ;
704
704
for bound_trait_ref in traits:: transitive_bounds ( tcx, bounds) {
705
+ debug ! ( "elaborate_bounds(bound_trait_ref={:?})" , bound_trait_ref) ;
705
706
for item in self . impl_or_trait_item ( bound_trait_ref. def_id ( ) ) {
706
707
if !self . has_applicable_self ( & item) {
707
708
self . record_static_candidate ( TraitSource ( bound_trait_ref. def_id ( ) ) ) ;
0 commit comments