@@ -45,54 +45,56 @@ impl<'hir> Entry<'hir> {
45
45
_ => Some ( self . parent ) ,
46
46
}
47
47
}
48
+ }
48
49
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 :: Fn ( 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
+ } ,
60
56
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 :: Fn ( ref sig, _) => Some ( & sig. decl ) ,
59
+ _ => None ,
60
+ } ,
65
61
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
+ } ,
70
66
67
+ Node :: Expr ( ref expr) => match expr. kind {
68
+ ExprKind :: Closure ( _, ref fn_decl, ..) => Some ( fn_decl) ,
71
69
_ => None ,
72
- }
73
- }
70
+ } ,
74
71
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
+ }
81
75
82
- Node :: TraitItem ( item) => match & item. kind {
83
- TraitItemKind :: Fn ( 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
+ } ,
86
82
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 :: Fn ( sig, _) => Some ( sig) ,
85
+ _ => None ,
86
+ } ,
91
87
88
+ Node :: ImplItem ( item) => match & item. kind {
89
+ ImplItemKind :: Method ( sig, _) => Some ( sig) ,
92
90
_ => None ,
93
- }
91
+ } ,
92
+
93
+ _ => None ,
94
94
}
95
+ }
95
96
97
+ impl < ' hir > Entry < ' hir > {
96
98
fn associated_body ( self ) -> Option < BodyId > {
97
99
match self . node {
98
100
Node :: Item ( item) => match item. kind {
@@ -433,18 +435,18 @@ impl<'hir> Map<'hir> {
433
435
}
434
436
435
437
pub fn fn_decl_by_hir_id ( & self , hir_id : HirId ) -> Option < & ' hir FnDecl < ' hir > > {
436
- if let Some ( entry ) = self . find_entry ( hir_id) {
437
- entry . fn_decl ( )
438
+ if let Some ( node ) = self . find ( hir_id) {
439
+ fn_decl ( node )
438
440
} else {
439
- bug ! ( "no entry for hir_id `{}`" , hir_id)
441
+ bug ! ( "no node for hir_id `{}`" , hir_id)
440
442
}
441
443
}
442
444
443
445
pub fn fn_sig_by_hir_id ( & self , hir_id : HirId ) -> Option < & ' hir FnSig < ' hir > > {
444
- if let Some ( entry ) = self . find_entry ( hir_id) {
445
- entry . fn_sig ( )
446
+ if let Some ( node ) = self . find ( hir_id) {
447
+ fn_sig ( node )
446
448
} else {
447
- bug ! ( "no entry for hir_id `{}`" , hir_id)
449
+ bug ! ( "no node for hir_id `{}`" , hir_id)
448
450
}
449
451
}
450
452
0 commit comments