Skip to content

Commit

Permalink
Rollup merge of rust-lang#119168 - petrochenkov:feedvis4, r=compiler-…
Browse files Browse the repository at this point in the history
…errors

resolve: Stop feeding visibilities for import list stems

Fixes rust-lang#119126
  • Loading branch information
matthiaskrgr authored Dec 20, 2023
2 parents 906606d + 006e0ef commit c36bb5d
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
9 changes: 7 additions & 2 deletions compiler/rustc_resolve/src/build_reduced_graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,7 @@ impl<'a, 'b, 'tcx> BuildReducedGraphVisitor<'a, 'b, 'tcx> {
id: NodeId,
parent_prefix: &[Segment],
nested: bool,
list_stem: bool,
// The whole `use` item
item: &Item,
vis: ty::Visibility,
Expand All @@ -404,7 +405,9 @@ impl<'a, 'b, 'tcx> BuildReducedGraphVisitor<'a, 'b, 'tcx> {
parent_prefix, use_tree, nested
);

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

Expand Down Expand Up @@ -592,7 +595,7 @@ impl<'a, 'b, 'tcx> BuildReducedGraphVisitor<'a, 'b, 'tcx> {
for &(ref tree, id) in items {
self.build_reduced_graph_for_use_tree(
// This particular use tree
tree, id, &prefix, true, // The whole `use` item
tree, id, &prefix, true, false, // The whole `use` item
item, vis, root_span,
);
}
Expand All @@ -613,6 +616,7 @@ impl<'a, 'b, 'tcx> BuildReducedGraphVisitor<'a, 'b, 'tcx> {
id,
&prefix,
true,
true,
// The whole `use` item
item,
ty::Visibility::Restricted(
Expand Down Expand Up @@ -648,6 +652,7 @@ impl<'a, 'b, 'tcx> BuildReducedGraphVisitor<'a, 'b, 'tcx> {
item.id,
&[],
false,
false,
// The whole `use` item
item,
vis,
Expand Down
14 changes: 14 additions & 0 deletions tests/ui/privacy/import-list-stem-visibility-issue-119126.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// check-pass
// edition: 2018

mod outer {
mod inner {
pub mod inner2 {}
}
pub(crate) use inner::{};
pub(crate) use inner::{{}};
pub(crate) use inner::{inner2::{}};
pub(crate) use inner::{inner2::{{}}};
}

fn main() {}

0 comments on commit c36bb5d

Please sign in to comment.