Update fn_decl_by_hir_id
and fn_sig_by_hir_id
This commit is contained in:
parent
e1a9626bb3
commit
d3c73940b7
1 changed files with 51 additions and 49 deletions
|
@ -45,9 +45,10 @@ impl<'hir> Entry<'hir> {
|
|||
_ => Some(self.parent),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn fn_decl(&self) -> Option<&'hir FnDecl<'hir>> {
|
||||
match self.node {
|
||||
fn fn_decl<'hir>(node: Node<'hir>) -> Option<&'hir FnDecl<'hir>> {
|
||||
match node {
|
||||
Node::Item(ref item) => match item.kind {
|
||||
ItemKind::Fn(ref sig, _, _) => Some(&sig.decl),
|
||||
_ => None,
|
||||
|
@ -70,10 +71,10 @@ impl<'hir> Entry<'hir> {
|
|||
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn fn_sig(&self) -> Option<&'hir FnSig<'hir>> {
|
||||
match &self.node {
|
||||
fn fn_sig<'hir>(node: Node<'hir>) -> Option<&'hir FnSig<'hir>> {
|
||||
match &node {
|
||||
Node::Item(item) => match &item.kind {
|
||||
ItemKind::Fn(sig, _, _) => Some(sig),
|
||||
_ => None,
|
||||
|
@ -91,8 +92,9 @@ impl<'hir> Entry<'hir> {
|
|||
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'hir> Entry<'hir> {
|
||||
fn associated_body(self) -> Option<BodyId> {
|
||||
match self.node {
|
||||
Node::Item(item) => match item.kind {
|
||||
|
@ -433,18 +435,18 @@ impl<'hir> Map<'hir> {
|
|||
}
|
||||
|
||||
pub fn fn_decl_by_hir_id(&self, hir_id: HirId) -> Option<&'hir FnDecl<'hir>> {
|
||||
if let Some(entry) = self.find_entry(hir_id) {
|
||||
entry.fn_decl()
|
||||
if let Some(node) = self.find(hir_id) {
|
||||
fn_decl(node)
|
||||
} else {
|
||||
bug!("no entry for hir_id `{}`", hir_id)
|
||||
bug!("no node for hir_id `{}`", hir_id)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn fn_sig_by_hir_id(&self, hir_id: HirId) -> Option<&'hir FnSig<'hir>> {
|
||||
if let Some(entry) = self.find_entry(hir_id) {
|
||||
entry.fn_sig()
|
||||
if let Some(node) = self.find(hir_id) {
|
||||
fn_sig(node)
|
||||
} else {
|
||||
bug!("no entry for hir_id `{}`", hir_id)
|
||||
bug!("no node for hir_id `{}`", hir_id)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue