-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Compile error with ambiguous shortcut import resolving #1228
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
Comments
Wow. This is stunningly counter-intuitive behavior. Removing |
I run into this when I did "import rustc::driver::rustc;". Now I have something like "import rc = rustc::driver::rustc;", but figured that out took me some time. :) |
Maybe imports should have ordered scope? In that they can't see themselves or imports coming after them. That would solve this and remove the need for the (current) exception that imports ignore themselves when resolving. |
If wrote like: import foo::bar::foo;
import foo::baz; then it will still try to resolve the second import as |
I disagree. It is quite clear to me that if you explicitly import something named |
Yes, that makes more sense. Only it may not be that obvious when crate name is involved. import rustc::driver::rustc;
import ...;
...
...
import rustc::syntax::parse; I will be happy if full name is given in error:
|
I like both those ideas - resolve them in order and show what the compiler thought it was looking for. |
This broke no code at all, so I guess people were already writing imports in this style. Issue #1228
New Lint: `wildcard imports` Fixes rust-lang#1228 ### A few notes: - I put this lint in the pedantic group, even though in the issue restriction was mentioned. - Every fallout fix was automatically applied by `cargo fix` (This produced 3 `unused_imports` warnings) and are in commit 7e834c8. So reverting these changes wouldn't be a problem. ### A few ideas: - A configuration to specify the amount of imported Items, where a `*` might be better. - ~~A configuration to disable the lint for enums. Or just disable the lint for enums, since there is [`enum_glob_use`](https://rust-lang.github.io/rust-clippy/master/index.html#enum_glob_use)~~ I moved `enum_glob_use` into this lint in 12937f0 ### A few quotes from the issue: > Is there a way to ask the compiler about the modules or symbols that the current file is using? Yes there is. I found it, once I was nearly finished implementing it myself. See 321d64a > one hard optional feature would be to figure out what is currently used and add a suggestion to replace it with a full import list. Yeah that was pretty hard, until I found the query for this. Queries are cool, but too hard to find. > FWIW VS Code and Intellij IDEA both offer imports deglobbing which replace * with required imports. And now, Clippy can do this too! 🎉 --- Your thoughts on the notes/ideas? changelog: Add new lint [`wildcard imports`]. Add suggestion to [`enum_glob_use`]
* Implement `arith_offset` with `codegen_offset` * Extend `codegen_offset` args with `intrinsic` * Add tests for `arith_offset`/`wrapping_offset` * Improve documentation for `codegen_offset` * Link issue and extend comment
Co-authored-by: Yuki Okushi <[email protected]> Co-authored-by: nhamovitz <[email protected]>
Co-authored-by: Yuki Okushi <[email protected]> Co-authored-by: nhamovitz <[email protected]>
It would be nice to suggest using an alias instead of complaining an "unresolved" error.
The text was updated successfully, but these errors were encountered: