Skip to content

rustc should warn about private types in re-exported interfaces #35005

Closed
@nwin

Description

@nwin

If one does not re-export a public type of a private module no warning is emitted. This is something that which is described in #34537 als a “workaround” and thus apparently intended as a feature.

This is actually pretty bad because it effectively renders the whole private_in_public-checker useless as it becomes unreliable. Why do we need a lint, if one can accidentally circumvent it? It hit use here: image-rs/image#562

mod outer {
    mod inner {
        pub struct Private;
        pub fn interface() -> Private {
            Private
        }
    }
    // This line should cause an error/warning
    pub use self::inner::{interface};
}

use outer::{interface};

fn main() {
    let _ = interface();
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    T-langRelevant to the language team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions