@@ -794,48 +794,56 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
794
794
}
795
795
796
796
fn get_fn_like_arguments ( & self , node : hir:: map:: Node ) -> ( Span , Vec < ArgKind > ) {
797
- if let hir:: map:: NodeExpr ( & hir:: Expr {
798
- node : hir:: ExprClosure ( _, ref _decl, id, span, _) ,
799
- ..
800
- } ) = node {
801
- ( self . tcx . sess . codemap ( ) . def_span ( span) , self . tcx . hir . body ( id) . arguments . iter ( )
802
- . map ( |arg| {
803
- if let hir:: Pat {
804
- node : hir:: PatKind :: Tuple ( args, _) ,
805
- span,
806
- ..
807
- } = arg. pat . clone ( ) . into_inner ( ) {
808
- ArgKind :: Tuple (
797
+ match node {
798
+ hir:: map:: NodeExpr ( & hir:: Expr {
799
+ node : hir:: ExprClosure ( _, ref _decl, id, span, _) ,
800
+ ..
801
+ } ) => {
802
+ ( self . tcx . sess . codemap ( ) . def_span ( span) , self . tcx . hir . body ( id) . arguments . iter ( )
803
+ . map ( |arg| {
804
+ if let hir:: Pat {
805
+ node : hir:: PatKind :: Tuple ( args, _) ,
809
806
span,
810
- args. iter ( ) . map ( |pat| {
811
- let snippet = self . tcx . sess . codemap ( )
812
- . span_to_snippet ( pat. span ) . unwrap ( ) ;
813
- ( snippet, "_" . to_owned ( ) )
814
- } ) . collect :: < Vec < _ > > ( ) ,
815
- )
816
- } else {
817
- let name = self . tcx . sess . codemap ( ) . span_to_snippet ( arg. pat . span ) . unwrap ( ) ;
818
- ArgKind :: Arg ( name, "_" . to_owned ( ) )
819
- }
820
- } )
821
- . collect :: < Vec < ArgKind > > ( ) )
822
- } else if let hir:: map:: NodeItem ( & hir:: Item {
823
- span,
824
- node : hir:: ItemFn ( ref decl, ..) ,
825
- ..
826
- } ) = node {
827
- ( self . tcx . sess . codemap ( ) . def_span ( span) , decl. inputs . iter ( )
828
- . map ( |arg| match arg. clone ( ) . into_inner ( ) . node {
829
- hir:: TyTup ( ref tys) => ArgKind :: Tuple (
830
- arg. span ,
831
- tys. iter ( )
832
- . map ( |_| ( "_" . to_owned ( ) , "_" . to_owned ( ) ) )
833
- . collect :: < Vec < _ > > ( ) ,
834
- ) ,
835
- _ => ArgKind :: Arg ( "_" . to_owned ( ) , "_" . to_owned ( ) )
836
- } ) . collect :: < Vec < ArgKind > > ( ) )
837
- } else {
838
- panic ! ( "non-FnLike node found: {:?}" , node) ;
807
+ ..
808
+ } = arg. pat . clone ( ) . into_inner ( ) {
809
+ ArgKind :: Tuple (
810
+ span,
811
+ args. iter ( ) . map ( |pat| {
812
+ let snippet = self . tcx . sess . codemap ( )
813
+ . span_to_snippet ( pat. span ) . unwrap ( ) ;
814
+ ( snippet, "_" . to_owned ( ) )
815
+ } ) . collect :: < Vec < _ > > ( ) ,
816
+ )
817
+ } else {
818
+ let name = self . tcx . sess . codemap ( )
819
+ . span_to_snippet ( arg. pat . span ) . unwrap ( ) ;
820
+ ArgKind :: Arg ( name, "_" . to_owned ( ) )
821
+ }
822
+ } )
823
+ . collect :: < Vec < ArgKind > > ( ) )
824
+ }
825
+ hir:: map:: NodeItem ( & hir:: Item {
826
+ span,
827
+ node : hir:: ItemFn ( ref decl, ..) ,
828
+ ..
829
+ } ) |
830
+ hir:: map:: NodeImplItem ( & hir:: ImplItem {
831
+ span,
832
+ node : hir:: ImplItemKind :: Method ( hir:: MethodSig { ref decl, .. } , _) ,
833
+ ..
834
+ } ) => {
835
+ ( self . tcx . sess . codemap ( ) . def_span ( span) , decl. inputs . iter ( )
836
+ . map ( |arg| match arg. clone ( ) . into_inner ( ) . node {
837
+ hir:: TyTup ( ref tys) => ArgKind :: Tuple (
838
+ arg. span ,
839
+ tys. iter ( )
840
+ . map ( |_| ( "_" . to_owned ( ) , "_" . to_owned ( ) ) )
841
+ . collect :: < Vec < _ > > ( ) ,
842
+ ) ,
843
+ _ => ArgKind :: Arg ( "_" . to_owned ( ) , "_" . to_owned ( ) )
844
+ } ) . collect :: < Vec < ArgKind > > ( ) )
845
+ }
846
+ _ => panic ! ( "non-FnLike node found: {:?}" , node) ,
839
847
}
840
848
}
841
849
0 commit comments