@@ -45,54 +45,56 @@ impl<'hir> Entry<'hir> {
4545 _ => Some ( self . parent ) ,
4646 }
4747 }
48+ }
4849
49- fn fn_decl ( & self ) -> Option < & ' hir FnDecl < ' hir > > {
50- match self . node {
51- Node :: Item ( ref item) => match item. kind {
52- ItemKind :: Fn ( ref sig, _, _) => Some ( & sig. decl ) ,
53- _ => None ,
54- } ,
55-
56- Node :: TraitItem ( ref item) => match item. kind {
57- TraitItemKind :: Method ( ref sig, _) => Some ( & sig. decl ) ,
58- _ => None ,
59- } ,
50+ fn fn_decl < ' hir > ( node : Node < ' hir > ) -> Option < & ' hir FnDecl < ' hir > > {
51+ match node {
52+ Node :: Item ( ref item) => match item. kind {
53+ ItemKind :: Fn ( ref sig, _, _) => Some ( & sig. decl ) ,
54+ _ => None ,
55+ } ,
6056
61- Node :: ImplItem ( ref item) => match item. kind {
62- ImplItemKind :: Method ( ref sig, _) => Some ( & sig. decl ) ,
63- _ => None ,
64- } ,
57+ Node :: TraitItem ( ref item) => match item. kind {
58+ TraitItemKind :: Method ( ref sig, _) => Some ( & sig. decl ) ,
59+ _ => None ,
60+ } ,
6561
66- Node :: Expr ( ref expr ) => match expr . kind {
67- ExprKind :: Closure ( _ , ref fn_decl , .. ) => Some ( fn_decl ) ,
68- _ => None ,
69- } ,
62+ Node :: ImplItem ( ref item ) => match item . kind {
63+ ImplItemKind :: Method ( ref sig , _ ) => Some ( & sig . decl ) ,
64+ _ => None ,
65+ } ,
7066
67+ Node :: Expr ( ref expr) => match expr. kind {
68+ ExprKind :: Closure ( _, ref fn_decl, ..) => Some ( fn_decl) ,
7169 _ => None ,
72- }
73- }
70+ } ,
7471
75- fn fn_sig ( & self ) -> Option < & ' hir FnSig < ' hir > > {
76- match & self . node {
77- Node :: Item ( item) => match & item. kind {
78- ItemKind :: Fn ( sig, _, _) => Some ( sig) ,
79- _ => None ,
80- } ,
72+ _ => None ,
73+ }
74+ }
8175
82- Node :: TraitItem ( item) => match & item. kind {
83- TraitItemKind :: Method ( sig, _) => Some ( sig) ,
84- _ => None ,
85- } ,
76+ fn fn_sig < ' hir > ( node : Node < ' hir > ) -> Option < & ' hir FnSig < ' hir > > {
77+ match & node {
78+ Node :: Item ( item) => match & item. kind {
79+ ItemKind :: Fn ( sig, _, _) => Some ( sig) ,
80+ _ => None ,
81+ } ,
8682
87- Node :: ImplItem ( item) => match & item. kind {
88- ImplItemKind :: Method ( sig, _) => Some ( sig) ,
89- _ => None ,
90- } ,
83+ Node :: TraitItem ( item) => match & item. kind {
84+ TraitItemKind :: Method ( sig, _) => Some ( sig) ,
85+ _ => None ,
86+ } ,
9187
88+ Node :: ImplItem ( item) => match & item. kind {
89+ ImplItemKind :: Method ( sig, _) => Some ( sig) ,
9290 _ => None ,
93- }
91+ } ,
92+
93+ _ => None ,
9494 }
95+ }
9596
97+ impl < ' hir > Entry < ' hir > {
9698 fn associated_body ( self ) -> Option < BodyId > {
9799 match self . node {
98100 Node :: Item ( item) => match item. kind {
@@ -438,18 +440,18 @@ impl<'hir> Map<'hir> {
438440 }
439441
440442 pub fn fn_decl_by_hir_id ( & self , hir_id : HirId ) -> Option < & ' hir FnDecl < ' hir > > {
441- if let Some ( entry ) = self . find_entry ( hir_id) {
442- entry . fn_decl ( )
443+ if let Some ( node ) = self . find ( hir_id) {
444+ fn_decl ( node )
443445 } else {
444- bug ! ( "no entry for hir_id `{}`" , hir_id)
446+ bug ! ( "no node for hir_id `{}`" , hir_id)
445447 }
446448 }
447449
448450 pub fn fn_sig_by_hir_id ( & self , hir_id : HirId ) -> Option < & ' hir FnSig < ' hir > > {
449- if let Some ( entry ) = self . find_entry ( hir_id) {
450- entry . fn_sig ( )
451+ if let Some ( node ) = self . find ( hir_id) {
452+ fn_sig ( node )
451453 } else {
452- bug ! ( "no entry for hir_id `{}`" , hir_id)
454+ bug ! ( "no node for hir_id `{}`" , hir_id)
453455 }
454456 }
455457
0 commit comments