diff options
| author | Nick Cameron <ncameron@mozilla.com> | 2018-10-29 21:06:27 +1300 |
|---|---|---|
| committer | Nick Cameron <ncameron@mozilla.com> | 2018-10-30 09:09:49 +1300 |
| commit | f586ac9ef9266f6e257c3ec41e126336a543025f (patch) | |
| tree | 460823eae452ff6ffe34fb7023cb240507a92726 | |
| parent | bcb05a0ab23291851d0a233547f2ad3cbb9cc222 (diff) | |
| download | rust-f586ac9ef9266f6e257c3ec41e126336a543025f.tar.gz rust-f586ac9ef9266f6e257c3ec41e126336a543025f.zip | |
Adjust Ids of path segments in visibility modifiers
Fixes #55376
| -rw-r--r-- | src/librustc/hir/lowering.rs | 8 | ||||
| -rw-r--r-- | src/librustc/hir/map/collector.rs | 2 | ||||
| -rw-r--r-- | src/test/run-pass/issue-55376.rs | 25 |
3 files changed, 33 insertions, 2 deletions
diff --git a/src/librustc/hir/lowering.rs b/src/librustc/hir/lowering.rs index 9795c0cba61..c3c65816b26 100644 --- a/src/librustc/hir/lowering.rs +++ b/src/librustc/hir/lowering.rs @@ -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, } diff --git a/src/librustc/hir/map/collector.rs b/src/librustc/hir/map/collector.rs index 8c701d9e418..4fbcd83adb5 100644 --- a/src/librustc/hir/map/collector.rs +++ b/src/librustc/hir/map/collector.rs @@ -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) diff --git a/src/test/run-pass/issue-55376.rs b/src/test/run-pass/issue-55376.rs new file mode 100644 index 00000000000..9c7256fd26f --- /dev/null +++ b/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() {} |
