-
Notifications
You must be signed in to change notification settings - Fork 1.9k
fix: Prevent public re-export of private item #18390
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| mod bar { | ||
| mod foo { pub(super) struct S; } | ||
| mod foo { pub(crate) struct S; } | ||
| pub(crate) use foo::S as U; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test case was wrong. It emits E0364 on rustc
mod bar {
mod foo { pub(super) struct S; }
pub(crate) use foo::S as U;
}
fn main() {}error[E0364]: `S` is private, and cannot be re-exported
--> src/main.rs:3:20
|
3 | pub(crate) use foo::S as U;
| ^^^^^^^^^^^
|
note: consider marking `S` as `pub` in the imported module
--> src/main.rs:3:20
|
3 | pub(crate) use foo::S as U;
| ^^^^^^^^^^^
|
BTW I spent most time on making a MCVE, as the original issue was quite hard to reproduce outside the |
|
Great work! Sorry for the large reproduction, I tried a bit to make it minimal but wasn't successful 😓. |
No worries 😅 The root causes were quite interwoven with each other and I just managed to made a MVCE with custom r-a build with extra tracings. |
Oh, I'll check about this |
|
I ran rust-analyzer/crates/hir/src/lib.rs Line 1432 in f446671
|
|
MCVE: //- /main.rs crate:main deps:test_crate
use test_crate::foo; // not resolving this!
use foo::Foo;
//- /lib.rs crate:test_crate deps:test_crate2
extern crate test_crate2;
pub use test_crate2 as foo;
//- /lib2.rs crate:test_crate2
pub struct Foo;It seems that I should exempt min visibility for |
When a glob import overriding the visibility of a previous glob import was not properly resolved when the items are only available in the next fixpoint iteration. The bug was hidden until rust-lang#18390.


Fixes #18308
The original issue is quite complicated.
polar-rsmonorepo has the following structure;pub use super::*insidemod hash_joinreexports the visibility of the glob importuse polars_core::prelude::*inside themod joinas "public", which was previously "module(join)"pub use hash_join::*insidemod joinoverrides visibility of the previous visibility of the glob importuse polars_core::prelude::*with "public" in 1., which was previously "module(join)"The problematic step is 1., as rustc doesn't allow such re-export with E0603.
This PR prevent such "more visible" re-export by taking minimum of resolved item visibility and the re-export visibility