@@ -442,7 +442,7 @@ impl<'a,'tcx> ProbeContext<'a,'tcx> {
442
442
443
443
fn assemble_extension_candidates_for_trait ( & mut self ,
444
444
trait_def_id : ast:: DefId ) {
445
- debug ! ( "assemble_extension_candidates_for_trait: trait_def_id={}" ,
445
+ debug ! ( "assemble_extension_candidates_for_trait( trait_def_id={}) " ,
446
446
trait_def_id. repr( self . tcx( ) ) ) ;
447
447
448
448
// Check whether `trait_def_id` defines a method with suitable name:
@@ -471,8 +471,12 @@ impl<'a,'tcx> ProbeContext<'a,'tcx> {
471
471
matching_index) ;
472
472
473
473
self . assemble_unboxed_closure_candidates ( trait_def_id,
474
- method,
474
+ method. clone ( ) ,
475
475
matching_index) ;
476
+
477
+ self . assemble_where_clause_candidates ( trait_def_id,
478
+ method,
479
+ matching_index) ;
476
480
}
477
481
478
482
fn assemble_extension_candidates_for_trait_impls ( & mut self ,
@@ -599,6 +603,35 @@ impl<'a,'tcx> ProbeContext<'a,'tcx> {
599
603
}
600
604
}
601
605
606
+ fn assemble_where_clause_candidates ( & mut self ,
607
+ trait_def_id : ast:: DefId ,
608
+ method_ty : Rc < ty:: Method < ' tcx > > ,
609
+ method_index : uint )
610
+ {
611
+ debug ! ( "assemble_where_clause_candidates(trait_def_id={})" ,
612
+ trait_def_id. repr( self . tcx( ) ) ) ;
613
+
614
+ // Check whether there are any where-clauses pertaining to this trait.
615
+ let caller_predicates =
616
+ self . fcx . inh . param_env . caller_bounds . predicates . as_slice ( ) . to_vec ( ) ;
617
+ for bound in traits:: elaborate_predicates ( self . tcx ( ) , caller_predicates)
618
+ . filter_map ( |p| p. to_opt_poly_trait_ref ( ) )
619
+ . filter ( |b| b. def_id ( ) == trait_def_id)
620
+ {
621
+ let xform_self_ty = self . xform_self_ty ( & method_ty, bound. substs ( ) ) ;
622
+
623
+ debug ! ( "assemble_where_clause_candidates: bound={} xform_self_ty={}" ,
624
+ bound. repr( self . tcx( ) ) ,
625
+ xform_self_ty. repr( self . tcx( ) ) ) ;
626
+
627
+ self . extension_candidates . push ( Candidate {
628
+ xform_self_ty : xform_self_ty,
629
+ method_ty : method_ty. clone ( ) ,
630
+ kind : WhereClauseCandidate ( bound, method_index)
631
+ } ) ;
632
+ }
633
+ }
634
+
602
635
///////////////////////////////////////////////////////////////////////////
603
636
// THE ACTUAL SEARCH
604
637
0 commit comments