@@ -951,24 +951,38 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
951
951
let trait_ref = self . tcx . mk_trait_ref ( trait_def_id, trait_substs) ;
952
952
953
953
if self . tcx . is_trait_alias ( trait_def_id) {
954
- // For trait aliases, assume all supertraits are relevant.
955
- let bounds = iter:: once ( ty:: Binder :: dummy ( trait_ref) ) ;
956
- self . elaborate_bounds ( bounds, |this, new_trait_ref, item| {
957
- let new_trait_ref = this. erase_late_bound_regions ( new_trait_ref) ;
954
+ // For trait aliases, recursively assume all explicitly named traits are relevant
955
+ for expansion in traits:: expand_trait_aliases (
956
+ self . tcx ,
957
+ iter:: once ( ( ty:: Binder :: dummy ( trait_ref) , self . span ) ) ,
958
+ ) {
959
+ let bound_trait_ref = expansion. trait_ref ( ) ;
960
+ for item in self . impl_or_trait_item ( bound_trait_ref. def_id ( ) ) {
961
+ if !self . has_applicable_self ( & item) {
962
+ self . record_static_candidate ( CandidateSource :: Trait (
963
+ bound_trait_ref. def_id ( ) ,
964
+ ) ) ;
965
+ } else {
966
+ let new_trait_ref = self . erase_late_bound_regions ( bound_trait_ref) ;
958
967
959
- let ( xform_self_ty, xform_ret_ty) =
960
- this. xform_self_ty ( & item, new_trait_ref. self_ty ( ) , new_trait_ref. substs ) ;
961
- this. push_candidate (
962
- Candidate {
963
- xform_self_ty,
964
- xform_ret_ty,
965
- item,
966
- import_ids : import_ids. clone ( ) ,
967
- kind : TraitCandidate ( new_trait_ref) ,
968
- } ,
969
- false ,
970
- ) ;
971
- } ) ;
968
+ let ( xform_self_ty, xform_ret_ty) = self . xform_self_ty (
969
+ & item,
970
+ new_trait_ref. self_ty ( ) ,
971
+ new_trait_ref. substs ,
972
+ ) ;
973
+ self . push_candidate (
974
+ Candidate {
975
+ xform_self_ty,
976
+ xform_ret_ty,
977
+ item,
978
+ import_ids : import_ids. clone ( ) ,
979
+ kind : TraitCandidate ( new_trait_ref) ,
980
+ } ,
981
+ false ,
982
+ ) ;
983
+ }
984
+ }
985
+ }
972
986
} else {
973
987
debug_assert ! ( self . tcx. is_trait( trait_def_id) ) ;
974
988
if self . tcx . trait_is_auto ( trait_def_id) {
0 commit comments