Skip to content

Commit 6642462

Browse files
committed
Make small modifications
1 parent e2a1cce commit 6642462

File tree

3 files changed

+7
-21
lines changed

3 files changed

+7
-21
lines changed

src/librustc/hir/map/collector.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ impl<'a, 'hir> NodeCollector<'a, 'hir> {
115115
hir_body_nodes,
116116
};
117117
collector.insert_entry(CRATE_NODE_ID, Entry {
118-
parent: ast::DUMMY_NODE_ID,
118+
parent: CRATE_NODE_ID,
119119
dep_node: root_mod_sig_dep_index,
120120
node: Node::Crate,
121121
});

src/librustc/hir/map/mod.rs

+6-18
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,6 @@ impl<'hir> Entry<'hir> {
5959
}
6060
}
6161

62-
fn to_node(self) -> Option<Node<'hir>> {
63-
match self.node {
64-
Node::Crate => None,
65-
_ => Some(self.node),
66-
}
67-
}
68-
6962
fn fn_decl(&self) -> Option<&FnDecl> {
7063
match self.node {
7164
Node::Item(ref item) => {
@@ -568,7 +561,7 @@ impl<'hir> Map<'hir> {
568561
/// Retrieve the Node corresponding to `id`, returning None if
569562
/// cannot be found.
570563
pub fn find(&self, id: NodeId) -> Option<Node<'hir>> {
571-
let result = self.find_entry(id).and_then(|x| x.to_node());
564+
let result = self.find_entry(id).map(|x| x.node);
572565
if result.is_some() {
573566
self.read(id);
574567
}
@@ -638,16 +631,11 @@ impl<'hir> Map<'hir> {
638631
return Err(id);
639632
}
640633

641-
if let Some(node) = self.find_entry(parent_node) {
642-
match node.to_node() {
643-
Some(ref node) => {
644-
if found(node) {
645-
return Ok(parent_node);
646-
} else if bail_early(node) {
647-
return Err(parent_node);
648-
}
649-
}
650-
None => return Err(parent_node),
634+
if let Some(entry) = self.find_entry(parent_node) {
635+
if found(&entry.node) {
636+
return Ok(parent_node);
637+
} else if bail_early(&entry.node) {
638+
return Err(parent_node);
651639
}
652640
id = parent_node;
653641
} else {

src/librustc/hir/mod.rs

-2
Original file line numberDiff line numberDiff line change
@@ -2397,7 +2397,5 @@ pub enum Node<'hir> {
23972397
GenericParam(&'hir GenericParam),
23982398
Visibility(&'hir Visibility),
23992399

2400-
/// Roots for node trees. Its DepNodeIndex when in `Entry`
2401-
/// is the dependency node of the crate's root module.
24022400
Crate,
24032401
}

0 commit comments

Comments
 (0)