mirror of
https://github.com/rust-lang/rust.git
synced 2025-06-04 19:29:07 +00:00
adjust intravisit HirIdification
This commit is contained in:
parent
f5bba2c6d7
commit
47dc349491
@ -27,7 +27,7 @@ pub(super) struct NodeCollector<'a, 'hir> {
|
|||||||
/// The node map
|
/// The node map
|
||||||
map: Vec<Option<Entry<'hir>>>,
|
map: Vec<Option<Entry<'hir>>>,
|
||||||
/// The parent of this node
|
/// The parent of this node
|
||||||
parent_hir: hir::HirId,
|
parent_node: hir::HirId,
|
||||||
|
|
||||||
// These fields keep track of the currently relevant DepNodes during
|
// These fields keep track of the currently relevant DepNodes during
|
||||||
// the visitor's traversal.
|
// the visitor's traversal.
|
||||||
@ -147,7 +147,7 @@ impl<'a, 'hir> NodeCollector<'a, 'hir> {
|
|||||||
krate,
|
krate,
|
||||||
source_map: sess.source_map(),
|
source_map: sess.source_map(),
|
||||||
map: repeat(None).take(sess.current_node_id_count()).collect(),
|
map: repeat(None).take(sess.current_node_id_count()).collect(),
|
||||||
parent_hir: hir::CRATE_HIR_ID,
|
parent_node: hir::CRATE_HIR_ID,
|
||||||
current_signature_dep_index: root_mod_sig_dep_index,
|
current_signature_dep_index: root_mod_sig_dep_index,
|
||||||
current_full_dep_index: root_mod_full_dep_index,
|
current_full_dep_index: root_mod_full_dep_index,
|
||||||
current_dep_node_owner: CRATE_DEF_INDEX,
|
current_dep_node_owner: CRATE_DEF_INDEX,
|
||||||
@ -230,8 +230,8 @@ impl<'a, 'hir> NodeCollector<'a, 'hir> {
|
|||||||
|
|
||||||
fn insert(&mut self, span: Span, hir_id: HirId, node: Node<'hir>) {
|
fn insert(&mut self, span: Span, hir_id: HirId, node: Node<'hir>) {
|
||||||
let entry = Entry {
|
let entry = Entry {
|
||||||
parent: self.hir_to_node_id[&self.parent_hir],
|
parent: self.hir_to_node_id[&self.parent_node],
|
||||||
parent_hir: self.parent_hir,
|
parent_hir: self.parent_node,
|
||||||
dep_node: if self.currently_in_body {
|
dep_node: if self.currently_in_body {
|
||||||
self.current_full_dep_index
|
self.current_full_dep_index
|
||||||
} else {
|
} else {
|
||||||
@ -283,13 +283,13 @@ impl<'a, 'hir> NodeCollector<'a, 'hir> {
|
|||||||
|
|
||||||
fn with_parent<F: FnOnce(&mut Self)>(
|
fn with_parent<F: FnOnce(&mut Self)>(
|
||||||
&mut self,
|
&mut self,
|
||||||
parent_hir_id: HirId,
|
parent_node_id: HirId,
|
||||||
f: F,
|
f: F,
|
||||||
) {
|
) {
|
||||||
let parent_hir = self.parent_hir;
|
let parent_node = self.parent_node;
|
||||||
self.parent_hir = parent_hir_id;
|
self.parent_node = parent_node_id;
|
||||||
f(self);
|
f(self);
|
||||||
self.parent_hir = parent_hir;
|
self.parent_node = parent_node;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn with_dep_node_owner<T: for<'b> HashStable<StableHashingContext<'b>>,
|
fn with_dep_node_owner<T: for<'b> HashStable<StableHashingContext<'b>>,
|
||||||
@ -446,8 +446,7 @@ impl<'a, 'hir> Visitor<'hir> for NodeCollector<'a, 'hir> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn visit_path_segment(&mut self, path_span: Span, path_segment: &'hir PathSegment) {
|
fn visit_path_segment(&mut self, path_span: Span, path_segment: &'hir PathSegment) {
|
||||||
if path_segment.id.is_some() {
|
if let Some(hir_id) = path_segment.hir_id {
|
||||||
let hir_id = path_segment.hir_id.unwrap();
|
|
||||||
self.insert(path_span, hir_id, Node::PathSegment(path_segment));
|
self.insert(path_span, hir_id, Node::PathSegment(path_segment));
|
||||||
}
|
}
|
||||||
intravisit::walk_path_segment(self, path_span, path_segment);
|
intravisit::walk_path_segment(self, path_span, path_segment);
|
||||||
@ -471,7 +470,7 @@ impl<'a, 'hir> Visitor<'hir> for NodeCollector<'a, 'hir> {
|
|||||||
|
|
||||||
fn visit_fn(&mut self, fk: intravisit::FnKind<'hir>, fd: &'hir FnDecl,
|
fn visit_fn(&mut self, fk: intravisit::FnKind<'hir>, fd: &'hir FnDecl,
|
||||||
b: BodyId, s: Span, id: HirId) {
|
b: BodyId, s: Span, id: HirId) {
|
||||||
assert_eq!(self.parent_hir, id);
|
assert_eq!(self.parent_node, id);
|
||||||
intravisit::walk_fn(self, fk, fd, b, s, id);
|
intravisit::walk_fn(self, fk, fd, b, s, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,11 +98,8 @@ impl<'a, 'hir: 'a> HirIdValidator<'a, 'hir> {
|
|||||||
if max != self.hir_ids_seen.len() - 1 {
|
if max != self.hir_ids_seen.len() - 1 {
|
||||||
// Collect the missing ItemLocalIds
|
// Collect the missing ItemLocalIds
|
||||||
let missing: Vec<_> = (0 ..= max as u32)
|
let missing: Vec<_> = (0 ..= max as u32)
|
||||||
.filter(|&i| !self.hir_ids_seen
|
.filter(|&i| !self.hir_ids_seen.contains(&ItemLocalId::from_u32(i)))
|
||||||
.iter()
|
.collect();
|
||||||
.find(|&local_id| local_id == &ItemLocalId::from_u32(i))
|
|
||||||
.is_some()
|
|
||||||
).collect();
|
|
||||||
|
|
||||||
// Try to map those to something more useful
|
// Try to map those to something more useful
|
||||||
let mut missing_items = Vec::with_capacity(missing.len());
|
let mut missing_items = Vec::with_capacity(missing.len());
|
||||||
|
Loading…
Reference in New Issue
Block a user