Skip to content

Commit 47dc349

Browse files
committed
adjust intravisit HirIdification
1 parent f5bba2c commit 47dc349

File tree

2 files changed

+12
-16
lines changed

2 files changed

+12
-16
lines changed

src/librustc/hir/map/collector.rs

+10-11
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ pub(super) struct NodeCollector<'a, 'hir> {
2727
/// The node map
2828
map: Vec<Option<Entry<'hir>>>,
2929
/// The parent of this node
30-
parent_hir: hir::HirId,
30+
parent_node: hir::HirId,
3131

3232
// These fields keep track of the currently relevant DepNodes during
3333
// the visitor's traversal.
@@ -147,7 +147,7 @@ impl<'a, 'hir> NodeCollector<'a, 'hir> {
147147
krate,
148148
source_map: sess.source_map(),
149149
map: repeat(None).take(sess.current_node_id_count()).collect(),
150-
parent_hir: hir::CRATE_HIR_ID,
150+
parent_node: hir::CRATE_HIR_ID,
151151
current_signature_dep_index: root_mod_sig_dep_index,
152152
current_full_dep_index: root_mod_full_dep_index,
153153
current_dep_node_owner: CRATE_DEF_INDEX,
@@ -230,8 +230,8 @@ impl<'a, 'hir> NodeCollector<'a, 'hir> {
230230

231231
fn insert(&mut self, span: Span, hir_id: HirId, node: Node<'hir>) {
232232
let entry = Entry {
233-
parent: self.hir_to_node_id[&self.parent_hir],
234-
parent_hir: self.parent_hir,
233+
parent: self.hir_to_node_id[&self.parent_node],
234+
parent_hir: self.parent_node,
235235
dep_node: if self.currently_in_body {
236236
self.current_full_dep_index
237237
} else {
@@ -283,13 +283,13 @@ impl<'a, 'hir> NodeCollector<'a, 'hir> {
283283

284284
fn with_parent<F: FnOnce(&mut Self)>(
285285
&mut self,
286-
parent_hir_id: HirId,
286+
parent_node_id: HirId,
287287
f: F,
288288
) {
289-
let parent_hir = self.parent_hir;
290-
self.parent_hir = parent_hir_id;
289+
let parent_node = self.parent_node;
290+
self.parent_node = parent_node_id;
291291
f(self);
292-
self.parent_hir = parent_hir;
292+
self.parent_node = parent_node;
293293
}
294294

295295
fn with_dep_node_owner<T: for<'b> HashStable<StableHashingContext<'b>>,
@@ -446,8 +446,7 @@ impl<'a, 'hir> Visitor<'hir> for NodeCollector<'a, 'hir> {
446446
}
447447

448448
fn visit_path_segment(&mut self, path_span: Span, path_segment: &'hir PathSegment) {
449-
if path_segment.id.is_some() {
450-
let hir_id = path_segment.hir_id.unwrap();
449+
if let Some(hir_id) = path_segment.hir_id {
451450
self.insert(path_span, hir_id, Node::PathSegment(path_segment));
452451
}
453452
intravisit::walk_path_segment(self, path_span, path_segment);
@@ -471,7 +470,7 @@ impl<'a, 'hir> Visitor<'hir> for NodeCollector<'a, 'hir> {
471470

472471
fn visit_fn(&mut self, fk: intravisit::FnKind<'hir>, fd: &'hir FnDecl,
473472
b: BodyId, s: Span, id: HirId) {
474-
assert_eq!(self.parent_hir, id);
473+
assert_eq!(self.parent_node, id);
475474
intravisit::walk_fn(self, fk, fd, b, s, id);
476475
}
477476

src/librustc/hir/map/hir_id_validator.rs

+2-5
Original file line numberDiff line numberDiff line change
@@ -98,11 +98,8 @@ impl<'a, 'hir: 'a> HirIdValidator<'a, 'hir> {
9898
if max != self.hir_ids_seen.len() - 1 {
9999
// Collect the missing ItemLocalIds
100100
let missing: Vec<_> = (0 ..= max as u32)
101-
.filter(|&i| !self.hir_ids_seen
102-
.iter()
103-
.find(|&local_id| local_id == &ItemLocalId::from_u32(i))
104-
.is_some()
105-
).collect();
101+
.filter(|&i| !self.hir_ids_seen.contains(&ItemLocalId::from_u32(i)))
102+
.collect();
106103

107104
// Try to map those to something more useful
108105
let mut missing_items = Vec::with_capacity(missing.len());

0 commit comments

Comments
 (0)