Make small modifications
This commit is contained in:
parent
e2a1cce9c5
commit
6642462ef6
3 changed files with 7 additions and 21 deletions
|
@ -115,7 +115,7 @@ impl<'a, 'hir> NodeCollector<'a, 'hir> {
|
|||
hir_body_nodes,
|
||||
};
|
||||
collector.insert_entry(CRATE_NODE_ID, Entry {
|
||||
parent: ast::DUMMY_NODE_ID,
|
||||
parent: CRATE_NODE_ID,
|
||||
dep_node: root_mod_sig_dep_index,
|
||||
node: Node::Crate,
|
||||
});
|
||||
|
|
|
@ -59,13 +59,6 @@ impl<'hir> Entry<'hir> {
|
|||
}
|
||||
}
|
||||
|
||||
fn to_node(self) -> Option<Node<'hir>> {
|
||||
match self.node {
|
||||
Node::Crate => None,
|
||||
_ => Some(self.node),
|
||||
}
|
||||
}
|
||||
|
||||
fn fn_decl(&self) -> Option<&FnDecl> {
|
||||
match self.node {
|
||||
Node::Item(ref item) => {
|
||||
|
@ -568,7 +561,7 @@ impl<'hir> Map<'hir> {
|
|||
/// Retrieve the Node corresponding to `id`, returning None if
|
||||
/// cannot be found.
|
||||
pub fn find(&self, id: NodeId) -> Option<Node<'hir>> {
|
||||
let result = self.find_entry(id).and_then(|x| x.to_node());
|
||||
let result = self.find_entry(id).map(|x| x.node);
|
||||
if result.is_some() {
|
||||
self.read(id);
|
||||
}
|
||||
|
@ -638,16 +631,11 @@ impl<'hir> Map<'hir> {
|
|||
return Err(id);
|
||||
}
|
||||
|
||||
if let Some(node) = self.find_entry(parent_node) {
|
||||
match node.to_node() {
|
||||
Some(ref node) => {
|
||||
if found(node) {
|
||||
return Ok(parent_node);
|
||||
} else if bail_early(node) {
|
||||
return Err(parent_node);
|
||||
}
|
||||
}
|
||||
None => return Err(parent_node),
|
||||
if let Some(entry) = self.find_entry(parent_node) {
|
||||
if found(&entry.node) {
|
||||
return Ok(parent_node);
|
||||
} else if bail_early(&entry.node) {
|
||||
return Err(parent_node);
|
||||
}
|
||||
id = parent_node;
|
||||
} else {
|
||||
|
|
|
@ -2397,7 +2397,5 @@ pub enum Node<'hir> {
|
|||
GenericParam(&'hir GenericParam),
|
||||
Visibility(&'hir Visibility),
|
||||
|
||||
/// Roots for node trees. Its DepNodeIndex when in `Entry`
|
||||
/// is the dependency node of the crate's root module.
|
||||
Crate,
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue