提交 6642462e 编写于 作者: V varkor

Make small modifications

上级 e2a1cce9
......@@ -115,7 +115,7 @@ pub(super) fn root(krate: &'hir Crate,
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 @@ fn parent_node(self) -> Option<NodeId> {
}
}
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 @@ pub fn get_generics_span(&self, id: DefId) -> Option<Span> {
/// 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 @@ fn walk_parent_nodes<F, F2>(&self,
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,
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册