Rollup merge of #119168 - petrochenkov:feedvis4, r=compiler-errors
resolve: Stop feeding visibilities for import list stems Fixes https://github.com/rust-lang/rust/issues/119126
This commit is contained in:
commit
c36bb5dbb1
@ -394,6 +394,7 @@ impl<'a, 'b, 'tcx> BuildReducedGraphVisitor<'a, 'b, 'tcx> {
|
|||||||
id: NodeId,
|
id: NodeId,
|
||||||
parent_prefix: &[Segment],
|
parent_prefix: &[Segment],
|
||||||
nested: bool,
|
nested: bool,
|
||||||
|
list_stem: bool,
|
||||||
// The whole `use` item
|
// The whole `use` item
|
||||||
item: &Item,
|
item: &Item,
|
||||||
vis: ty::Visibility,
|
vis: ty::Visibility,
|
||||||
@ -404,7 +405,9 @@ impl<'a, 'b, 'tcx> BuildReducedGraphVisitor<'a, 'b, 'tcx> {
|
|||||||
parent_prefix, use_tree, nested
|
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);
|
self.r.feed_visibility(self.r.local_def_id(id), vis);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -592,7 +595,7 @@ impl<'a, 'b, 'tcx> BuildReducedGraphVisitor<'a, 'b, 'tcx> {
|
|||||||
for &(ref tree, id) in items {
|
for &(ref tree, id) in items {
|
||||||
self.build_reduced_graph_for_use_tree(
|
self.build_reduced_graph_for_use_tree(
|
||||||
// This particular 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,
|
item, vis, root_span,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -613,6 +616,7 @@ impl<'a, 'b, 'tcx> BuildReducedGraphVisitor<'a, 'b, 'tcx> {
|
|||||||
id,
|
id,
|
||||||
&prefix,
|
&prefix,
|
||||||
true,
|
true,
|
||||||
|
true,
|
||||||
// The whole `use` item
|
// The whole `use` item
|
||||||
item,
|
item,
|
||||||
ty::Visibility::Restricted(
|
ty::Visibility::Restricted(
|
||||||
@ -648,6 +652,7 @@ impl<'a, 'b, 'tcx> BuildReducedGraphVisitor<'a, 'b, 'tcx> {
|
|||||||
item.id,
|
item.id,
|
||||||
&[],
|
&[],
|
||||||
false,
|
false,
|
||||||
|
false,
|
||||||
// The whole `use` item
|
// The whole `use` item
|
||||||
item,
|
item,
|
||||||
vis,
|
vis,
|
||||||
|
14
tests/ui/privacy/import-list-stem-visibility-issue-119126.rs
Normal file
14
tests/ui/privacy/import-list-stem-visibility-issue-119126.rs
Normal file
@ -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() {}
|
Loading…
x
Reference in New Issue
Block a user