rust-lang / rust-analyzer

A Rust compiler front-end for IDEs
https://rust-analyzer.github.io/
Apache License 2.0
14.3k stars 1.61k forks source link

pub use wildcard expansion adds pub(crate) items too #14394

Open santhosh-tekuri opened 1 year ago

santhosh-tekuri commented 1 year ago
pub use inner:*;

mod inner {
    pub(crate) struct S1;
    pub struct S2;
}

on expanding alias in pub use inner::* it becomes pub use inner::{S1, S2) resulting in compilation error. it is expected to expand as pub use inner::S2

roife commented 7 months ago

We cannot directly expand it to pub use inner::S2.

Considering the following program:

pub use inner::*;

mod inner {
    pub(crate) struct S1;
    pub struct S2;
}

fn main() {
    let _ = S1;
    let _ = S2;
}

If directly expanded to pub use inner::S2, then S1 would not be accessible. So it is more complicated to correctly handle pub(crate).