@@ -896,20 +896,36 @@ impl<'a, 'gcx, 'tcx> ProbeContext<'a, 'gcx, 'tcx> {
896896 let trait_substs = self . fresh_item_substs ( trait_def_id) ;
897897 let trait_ref = ty:: TraitRef :: new ( trait_def_id, trait_substs) ;
898898
899- for item in self . impl_or_trait_item ( trait_def_id) {
900- // Check whether `trait_def_id` defines a method with suitable name:
901- if !self . has_applicable_self ( & item) {
902- debug ! ( "method has inapplicable self" ) ;
903- self . record_static_candidate ( TraitSource ( trait_def_id) ) ;
904- continue ;
905- }
899+ if self . tcx . is_trait_alias ( trait_def_id) {
900+ // For trait aliases, assume all super-traits are relevant.
901+ let bounds = iter:: once ( trait_ref. to_poly_trait_ref ( ) ) ;
902+ self . elaborate_bounds ( bounds, |this, new_trait_ref, item| {
903+ let new_trait_ref = this. erase_late_bound_regions ( & new_trait_ref) ;
904+
905+ let ( xform_self_ty, xform_ret_ty) =
906+ this. xform_self_ty ( & item, new_trait_ref. self_ty ( ) , new_trait_ref. substs ) ;
907+ this. push_candidate ( Candidate {
908+ xform_self_ty, xform_ret_ty, item, import_id,
909+ kind : TraitCandidate ( new_trait_ref) ,
910+ } , true ) ;
911+ } ) ;
912+ } else {
913+ debug_assert ! ( self . tcx. is_trait( trait_def_id) ) ;
914+ for item in self . impl_or_trait_item ( trait_def_id) {
915+ // Check whether `trait_def_id` defines a method with suitable name.
916+ if !self . has_applicable_self ( & item) {
917+ debug ! ( "method has inapplicable self" ) ;
918+ self . record_static_candidate ( TraitSource ( trait_def_id) ) ;
919+ continue ;
920+ }
906921
907- let ( xform_self_ty, xform_ret_ty) =
908- self . xform_self_ty ( & item, trait_ref. self_ty ( ) , trait_substs) ;
909- self . push_candidate ( Candidate {
910- xform_self_ty, xform_ret_ty, item, import_id,
911- kind : TraitCandidate ( trait_ref) ,
912- } , false ) ;
922+ let ( xform_self_ty, xform_ret_ty) =
923+ self . xform_self_ty ( & item, trait_ref. self_ty ( ) , trait_substs) ;
924+ self . push_candidate ( Candidate {
925+ xform_self_ty, xform_ret_ty, item, import_id,
926+ kind : TraitCandidate ( trait_ref) ,
927+ } , false ) ;
928+ }
913929 }
914930 Ok ( ( ) )
915931 }
@@ -930,7 +946,7 @@ impl<'a, 'gcx, 'tcx> ProbeContext<'a, 'gcx, 'tcx> {
930946 . filter ( |& name| set. insert ( name) )
931947 . collect ( ) ;
932948
933- // sort them by the name so we have a stable result
949+ // Sort them by the name so we have a stable result.
934950 names. sort_by_cached_key ( |n| n. as_str ( ) ) ;
935951 names
936952 }
@@ -945,6 +961,8 @@ impl<'a, 'gcx, 'tcx> ProbeContext<'a, 'gcx, 'tcx> {
945961 return r;
946962 }
947963
964+ debug ! ( "pick: actual search failed, assemble diagnotics" ) ;
965+
948966 let static_candidates = mem:: replace ( & mut self . static_candidates , vec ! [ ] ) ;
949967 let private_candidate = self . private_candidate . take ( ) ;
950968 let unsatisfied_predicates = mem:: replace ( & mut self . unsatisfied_predicates , vec ! [ ] ) ;
0 commit comments