File tree Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Original file line number Diff line number Diff line change @@ -79,6 +79,33 @@ impl<'hir> Entry<'hir> {
79
79
}
80
80
}
81
81
82
+ fn fn_sig ( & self ) -> Option < & ' hir FnSig > {
83
+ match & self . node {
84
+ Node :: Item ( item) => {
85
+ match & item. kind {
86
+ ItemKind :: Fn ( sig, _, _) => Some ( sig) ,
87
+ _ => None ,
88
+ }
89
+ }
90
+
91
+ Node :: TraitItem ( item) => {
92
+ match & item. kind {
93
+ TraitItemKind :: Method ( sig, _) => Some ( sig) ,
94
+ _ => None
95
+ }
96
+ }
97
+
98
+ Node :: ImplItem ( item) => {
99
+ match & item. kind {
100
+ ImplItemKind :: Method ( sig, _) => Some ( sig) ,
101
+ _ => None ,
102
+ }
103
+ }
104
+
105
+ _ => None ,
106
+ }
107
+ }
108
+
82
109
fn associated_body ( self ) -> Option < BodyId > {
83
110
match self . node {
84
111
Node :: Item ( item) => {
@@ -450,6 +477,14 @@ impl<'hir> Map<'hir> {
450
477
}
451
478
}
452
479
480
+ pub fn fn_sig_by_hir_id ( & self , hir_id : HirId ) -> Option < & ' hir FnSig > {
481
+ if let Some ( entry) = self . find_entry ( hir_id) {
482
+ entry. fn_sig ( )
483
+ } else {
484
+ bug ! ( "no entry for hir_id `{}`" , hir_id)
485
+ }
486
+ }
487
+
453
488
/// Returns the `HirId` that corresponds to the definition of
454
489
/// which this is the body of, i.e., a `fn`, `const` or `static`
455
490
/// item (possibly associated), a closure, or a `hir::AnonConst`.
You can’t perform that action at this time.
0 commit comments