Skip to content

Commit c36bb5d

Browse files
authored
Rollup merge of #119168 - petrochenkov:feedvis4, r=compiler-errors
resolve: Stop feeding visibilities for import list stems Fixes #119126
2 parents 906606d + 006e0ef commit c36bb5d

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

compiler/rustc_resolve/src/build_reduced_graph.rs

+7-2
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,7 @@ impl<'a, 'b, 'tcx> BuildReducedGraphVisitor<'a, 'b, 'tcx> {
394394
id: NodeId,
395395
parent_prefix: &[Segment],
396396
nested: bool,
397+
list_stem: bool,
397398
// The whole `use` item
398399
item: &Item,
399400
vis: ty::Visibility,
@@ -404,7 +405,9 @@ impl<'a, 'b, 'tcx> BuildReducedGraphVisitor<'a, 'b, 'tcx> {
404405
parent_prefix, use_tree, nested
405406
);
406407

407-
if nested {
408+
// Top level use tree reuses the item's id and list stems reuse their parent
409+
// use tree's ids, so in both cases their visibilities are already filled.
410+
if nested && !list_stem {
408411
self.r.feed_visibility(self.r.local_def_id(id), vis);
409412
}
410413

@@ -592,7 +595,7 @@ impl<'a, 'b, 'tcx> BuildReducedGraphVisitor<'a, 'b, 'tcx> {
592595
for &(ref tree, id) in items {
593596
self.build_reduced_graph_for_use_tree(
594597
// This particular use tree
595-
tree, id, &prefix, true, // The whole `use` item
598+
tree, id, &prefix, true, false, // The whole `use` item
596599
item, vis, root_span,
597600
);
598601
}
@@ -613,6 +616,7 @@ impl<'a, 'b, 'tcx> BuildReducedGraphVisitor<'a, 'b, 'tcx> {
613616
id,
614617
&prefix,
615618
true,
619+
true,
616620
// The whole `use` item
617621
item,
618622
ty::Visibility::Restricted(
@@ -648,6 +652,7 @@ impl<'a, 'b, 'tcx> BuildReducedGraphVisitor<'a, 'b, 'tcx> {
648652
item.id,
649653
&[],
650654
false,
655+
false,
651656
// The whole `use` item
652657
item,
653658
vis,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// check-pass
2+
// edition: 2018
3+
4+
mod outer {
5+
mod inner {
6+
pub mod inner2 {}
7+
}
8+
pub(crate) use inner::{};
9+
pub(crate) use inner::{{}};
10+
pub(crate) use inner::{inner2::{}};
11+
pub(crate) use inner::{inner2::{{}}};
12+
}
13+
14+
fn main() {}

0 commit comments

Comments
 (0)