Skip to content

Commit

Permalink
Adjust Ids of path segments in visibility modifiers
Browse files Browse the repository at this point in the history
Fixes #55376
  • Loading branch information
nrc committed Oct 29, 2018
1 parent bcb05a0 commit f586ac9
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 2 deletions.
8 changes: 7 additions & 1 deletion src/librustc/hir/lowering.rs
Expand Up @@ -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,
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/hir/map/collector.rs
Expand Up @@ -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)
Expand Down
25 changes: 25 additions & 0 deletions src/test/run-pass/issue-55376.rs
@@ -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() {}

0 comments on commit f586ac9

Please sign in to comment.