Skip to content

Document behaviour of wildcard imports with respect to private members #30954

Closed
@jFransham

Description

@jFransham

This hit me earlier, and although I eventually worked it out it definitely violates the principle of least surprise (although, don't get me wrong, I am 100% in favour of the current behaviour). Currently wildcard imports do not import private members, even if the importer can see the private members (i.e. due to being a submodule, I don't believe there are other cases where a module can see another's private members). The section in the book about crates and modules does not mention this, nor rustc --explain E0425, and it's easy to see how this could cause problems, especially since test modules importing private members of their parent is an extremely common idiom in Rust.

Ideally, this would come up as a hint on the name resolution errors, failing that it would be in the entry for rustc --explain E0425, failing that it would be in the book.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-resolveArea: Name/path resolution done by `rustc_resolve` specifically

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions