Adjust Ids of path segments in visibility modifiers

Fixes #55376
This commit is contained in:
Nick Cameron 2018-10-29 21:06:27 +13:00
parent bcb05a0ab2
commit f586ac9ef9
3 changed files with 33 additions and 2 deletions

View file

@ -3022,8 +3022,14 @@ 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);
}
}
hir::VisibilityKind::Restricted {
path: path.clone(),
path,
id: id.node_id,
hir_id: id.hir_id,
}

View file

@ -217,7 +217,7 @@ impl<'a, 'hir> NodeCollector<'a, 'hir> {
};
bug!("inconsistent DepNode for `{}`: \
current_dep_node_owner={} ({:?}), hir_id.owner={} ({:?}) {}",
current_dep_node_owner={} ({:?}), hir_id.owner={} ({:?}){}",
node_str,
self.definitions
.def_path(self.current_dep_node_owner)

View file

@ -0,0 +1,25 @@
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// Tests that paths in `pub(...)` don't fail HIR verification.
#![allow(unused_imports)]
#![allow(dead_code)]
pub(self) use self::my_mod::Foo;
mod my_mod {
pub(super) use self::Foo as Bar;
pub(in super::my_mod) use self::Foo as Baz;
pub struct Foo;
}
fn main() {}