Skip to content
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

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

Closed
jFransham opened this issue Jan 16, 2016 · 2 comments
Closed
Labels
A-resolve Area: Name resolution

Comments

@jFransham
Copy link
Contributor

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.

@steveklabnik steveklabnik added the A-resolve Area: Name resolution label Jan 26, 2016
@steveklabnik
Copy link
Member

/cc @rust-lang/lang

@nrc nrc added A-docs and removed A-lang labels Jan 26, 2016
@nrc
Copy link
Member

nrc commented Jan 26, 2016

Yeah, this should be in the book. It is annoying, it is possible this might change - if we relax our rules on overlapping imports (i.e., give simple imports priority over globs) then we could change this behaviour, I think. But that is a long way off.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-resolve Area: Name resolution
Projects
None yet
Development

No branches or pull requests

3 participants