You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
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.
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.The text was updated successfully, but these errors were encountered: