@@ -947,65 +947,59 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
947
947
// this isn't perfect (that is, there are cases when
948
948
// implementing a trait would be legal but is rejected
949
949
// here).
950
- !unsatisfied_predicates. iter ( ) . any ( |( p, _) | match p {
951
- // Hide traits if they are present in predicates as they can be fixed without
952
- // having to implement them.
953
- ty:: Predicate :: Trait ( t, _) => t. def_id ( ) != info. def_id ,
954
- ty:: Predicate :: Projection ( p) => p. item_def_id ( ) != info. def_id ,
955
- _ => true ,
956
- } ) && ( type_is_local || info. def_id . is_local ( ) )
957
- && self
958
- . associated_item ( info. def_id , item_name, Namespace :: ValueNS )
959
- . filter ( |item| {
960
- if let ty:: AssocKind :: Fn = item. kind {
961
- let id = item. def_id . as_local ( ) . map ( |def_id| {
962
- self . tcx . hir ( ) . as_local_hir_id ( def_id)
963
- } ) ;
964
- if let Some ( hir:: Node :: TraitItem ( hir:: TraitItem {
965
- kind : hir:: TraitItemKind :: Fn ( fn_sig, method) ,
966
- ..
967
- } ) ) = id. map ( |id| self . tcx . hir ( ) . get ( id) )
950
+ unsatisfied_predicates. iter ( ) . all ( |( p, _) | match p {
951
+ // Hide traits if they are present in predicates as they can be fixed without
952
+ // having to implement them.
953
+ ty:: Predicate :: Trait ( t, _) => t. def_id ( ) == info. def_id ,
954
+ ty:: Predicate :: Projection ( p) => p. item_def_id ( ) == info. def_id ,
955
+ _ => false ,
956
+ } ) && ( type_is_local || info. def_id . is_local ( ) )
957
+ && self
958
+ . associated_item ( info. def_id , item_name, Namespace :: ValueNS )
959
+ . filter ( |item| {
960
+ if let ty:: AssocKind :: Fn = item. kind {
961
+ let id = item
962
+ . def_id
963
+ . as_local ( )
964
+ . map ( |def_id| self . tcx . hir ( ) . as_local_hir_id ( def_id) ) ;
965
+ if let Some ( hir:: Node :: TraitItem ( hir:: TraitItem {
966
+ kind : hir:: TraitItemKind :: Fn ( fn_sig, method) ,
967
+ ..
968
+ } ) ) = id. map ( |id| self . tcx . hir ( ) . get ( id) )
969
+ {
970
+ let self_first_arg = match method {
971
+ hir:: TraitFn :: Required ( [ ident, ..] ) => {
972
+ ident. name == kw:: SelfLower
973
+ }
974
+ hir:: TraitFn :: Provided ( body_id) => {
975
+ self . tcx . hir ( ) . body ( * body_id) . params . first ( ) . map_or (
976
+ false ,
977
+ |param| {
978
+ matches ! (
979
+ param. pat. kind,
980
+ hir:: PatKind :: Binding ( _, _, ident, _)
981
+ if ident. name == kw:: SelfLower
982
+ )
983
+ } ,
984
+ )
985
+ }
986
+ _ => false ,
987
+ } ;
988
+
989
+ if !fn_sig. decl . implicit_self . has_implicit_self ( )
990
+ && self_first_arg
968
991
{
969
- let self_first_arg = match method {
970
- hir:: TraitFn :: Required ( [ ident, ..] ) => {
971
- ident. name == kw:: SelfLower
972
- }
973
- hir:: TraitFn :: Provided ( body_id) => {
974
- match & self . tcx . hir ( ) . body ( * body_id) . params [ ..] {
975
- [ hir:: Param {
976
- pat :
977
- hir:: Pat {
978
- kind :
979
- hir:: PatKind :: Binding (
980
- _,
981
- _,
982
- ident,
983
- ..,
984
- ) ,
985
- ..
986
- } ,
987
- ..
988
- } , ..] => ident. name == kw:: SelfLower ,
989
- _ => false ,
990
- }
991
- }
992
- _ => false ,
993
- } ;
994
-
995
- if !fn_sig. decl . implicit_self . has_implicit_self ( )
996
- && self_first_arg
997
- {
998
- if let Some ( ty) = fn_sig. decl . inputs . get ( 0 ) {
999
- arbitrary_rcvr. push ( ty. span ) ;
1000
- }
1001
- return false ;
992
+ if let Some ( ty) = fn_sig. decl . inputs . get ( 0 ) {
993
+ arbitrary_rcvr. push ( ty. span ) ;
1002
994
}
995
+ return false ;
1003
996
}
1004
997
}
1005
- // We only want to suggest public or local traits (#45781).
1006
- item. vis == ty:: Visibility :: Public || info. def_id . is_local ( )
1007
- } )
1008
- . is_some ( )
998
+ }
999
+ // We only want to suggest public or local traits (#45781).
1000
+ item. vis == ty:: Visibility :: Public || info. def_id . is_local ( )
1001
+ } )
1002
+ . is_some ( )
1009
1003
} )
1010
1004
. collect :: < Vec < _ > > ( ) ;
1011
1005
for span in & arbitrary_rcvr {
0 commit comments