-
Notifications
You must be signed in to change notification settings - Fork 13.4k
suggest crate::...
for "local" paths in 2018
#54230
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Comments
Some thoughts: Ideally, we would compare against two things: and offer appropriate suggestions. Not sure if there is code that tries to do either of those already. I'd have to look around. |
I'm mostly aware of the one speculative lookup I've introduced: rust/src/librustc_resolve/resolve_imports.rs Lines 169 to 196 in 052d24e
You need to set Not sure what you mean by "the names of crates in the prelude" - that's easy enough, |
Between starting to look at this and now, I've noticed that the error has changed to:
|
@davidtwco hmm, yeah, there is technically ambiguity here I guess, in that one could write with e.g., if one is doing something like this, then surely you want
|
Also, if we modify the test ever so slightly to be more realistic: mod foo {
type Bar = u32;
}
mod baz {
use foo::Bar;
fn baz() {
let x: Bar = 22;
}
}
fn main() { } then I assume you get no suggestion? |
suggest `crate::...` for "local" paths in 2018 Fixes rust-lang#54230. This commit adds suggestions for unresolved imports in the cases where there could be a missing `crate::`, `super::`, `self::` or a missing external crate name before an import. r? @nikomatsakis
suggest `crate::...` for "local" paths in 2018 Fixes #54230. This commit adds suggestions for unresolved imports in the cases where there could be a missing `crate::`, `super::`, `self::` or a missing external crate name before an import. r? @nikomatsakis
The following code, when compiled in Rust 2018, errors out (as expected). However, the error could be more helpful.
Error:
but I think we should suggest something like
The text was updated successfully, but these errors were encountered: