renumber segment ids for visibilities whenever we clone them
This commit is contained in:
parent
40f8094003
commit
a0a47904d6
1 changed files with 17 additions and 7 deletions
|
|
@ -3029,12 +3029,7 @@ impl<'a> LoweringContext<'a> {
|
|||
hir::VisibilityKind::Inherited => hir::VisibilityKind::Inherited,
|
||||
hir::VisibilityKind::Restricted { ref path, id: _, hir_id: _ } => {
|
||||
let id = this.next_id();
|
||||
let mut path = path.clone();
|
||||
for seg in path.segments.iter_mut() {
|
||||
if seg.id.is_some() {
|
||||
seg.id = Some(this.next_id().node_id);
|
||||
}
|
||||
}
|
||||
let path = this.renumber_segment_ids(path);
|
||||
hir::VisibilityKind::Restricted {
|
||||
path,
|
||||
id: id.node_id,
|
||||
|
|
@ -3119,8 +3114,9 @@ impl<'a> LoweringContext<'a> {
|
|||
hir::VisibilityKind::Inherited => hir::VisibilityKind::Inherited,
|
||||
hir::VisibilityKind::Restricted { ref path, id: _, hir_id: _ } => {
|
||||
let id = this.next_id();
|
||||
let path = this.renumber_segment_ids(path);
|
||||
hir::VisibilityKind::Restricted {
|
||||
path: path.clone(),
|
||||
path: path,
|
||||
id: id.node_id,
|
||||
hir_id: id.hir_id,
|
||||
}
|
||||
|
|
@ -3154,6 +3150,20 @@ impl<'a> LoweringContext<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
/// Paths like the visibility path in `pub(super) use foo::{bar, baz}` are repeated
|
||||
/// many times in the HIR tree; for each occurrence, we need to assign distinct
|
||||
/// node-ids. (See e.g. #56128.)
|
||||
fn renumber_segment_ids(&mut self, path: &P<hir::Path>) -> P<hir::Path> {
|
||||
debug!("renumber_segment_ids(path = {:?})", path);
|
||||
let mut path = path.clone();
|
||||
for seg in path.segments.iter_mut() {
|
||||
if seg.id.is_some() {
|
||||
seg.id = Some(self.next_id().node_id);
|
||||
}
|
||||
}
|
||||
path
|
||||
}
|
||||
|
||||
fn lower_trait_item(&mut self, i: &TraitItem) -> hir::TraitItem {
|
||||
let LoweredNodeId { node_id, hir_id } = self.lower_node_id(i.id);
|
||||
let trait_item_def_id = self.resolver.definitions().local_def_id(node_id);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue