})
}
+ fn fn_decl(&self) -> Option<&FnDecl> {
+ match self {
+ EntryItem(_, _, ref item) => {
+ match item.node {
+ ItemFn(ref fn_decl, _, _, _, _, _) => Some(&fn_decl),
+ _ => None,
+ }
+ }
+
+ EntryTraitItem(_, _, ref item) => {
+ match item.node {
+ TraitItemKind::Method(ref method_sig, _) => Some(&method_sig.decl),
+ _ => None
+ }
+ }
+
+ EntryImplItem(_, _, ref item) => {
+ match item.node {
+ ImplItemKind::Method(ref method_sig, _) => Some(&method_sig.decl),
+ _ => None,
+ }
+ }
+
+ EntryExpr(_, _, ref expr) => {
+ match expr.node {
+ ExprClosure(_, ref fn_decl, ..) => Some(&fn_decl),
+ _ => None,
+ }
+ }
+
+ _ => None
+ }
+ }
+
fn associated_body(self) -> Option<BodyId> {
match self {
EntryItem(_, _, item) => {
self.forest.krate.body(id)
}
+ pub fn fn_decl(&self, node_id: ast::NodeId) -> Option<FnDecl> {
+ if let Some(entry) = self.find_entry(node_id) {
+ entry.fn_decl().map(|fd| fd.clone())
+ } else {
+ bug!("no entry for node_id `{}`", node_id)
+ }
+ }
+
/// Returns the `NodeId` that corresponds to the definition of
/// which this is the body of, i.e. a `fn`, `const` or `static`
/// item (possibly associated), a closure, or a `hir::AnonConst`.