-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
uses in crate root shadow crates in inner modules #12612
Comments
Closing as working as intended. This is what the syntaxes |
Even across different modules? It's unintuitive that the use declarations in foo.rs would be affecting the use declarations in inner.rs. Although the problem would be quite apparent if name collisions resulted in an error. |
Oops sorry, misread! That's indeed a bug. |
I think it makes perfect sense to shadow if these were #7663 and #10884 are similar, but I think this case is a particularly bad consequence of our |
Nominating. This itself is not a backwards compatibility hazard (it's just a bug), but nearly every tweak I've made to resolve has broken many programs before. Thankfully, this program does not compile: use std::c_str;
mod foo {
use c_str;
} However, I think we should fix this before 1.0 to be sure that we don't accidentally break programs. |
Assigning 1.0, P-high. |
Resolve is currently erroneously allowing imports through private `use` statements in some circumstances, even across module boundaries. For example, this code compiles successfully today: use std::c_str; mod test { use c_str::CString; } This should not be allowed because it was explicitly decided that private `use` statements are purely bringing local names into scope, they are not participating further in name resolution. As a consequence of this patch, this code, while valid today, is now invalid: mod test { use std::c_str; unsafe fn foo() { ::test::c_str::CString::new(0 as *u8, false); } } While plausibly acceptable, I found it to be more consistent if private imports were only considered candidates to resolve the first component in a path, and no others. Closes rust-lang#12612
rustc errors:
foo.rs:4:17: 4:28 error: unresolved import: there is no
RWArc
instd::sync
(rustc 0.10-pre (6720977 2014-02-24 04:11:53 -0800))
The text was updated successfully, but these errors were encountered: