Clippy already wans when importing all the variants of an enum. But this is still allowed:
use crate::*;
This kind of global import makes the code more difficult to read since we don't know where symbols come from. It may also confuse IDEs. Could we add a lint to prevent this?
Link to the relevant reddit discussion
this should be a restriction lint.
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.
Note that prelude modules such as
use iron::prelude::*;
may use a different lint ID, so one could allow glob-import of the preludes but warn against other glob imports.
I do not know the syntax by memory, so I have to ask: is this still an issue after the module changes made for Rust 2018 Edition?
Yep. Glob imports weren't changed.
FWIW VS Code and Intellij IDEA both offer imports deglobbing which replace * with required imports.
FWIW VS Code and Intellij IDEA both offer imports deglobbing which replace
*with required imports.
That's super awesome :D
Is there a way to ask the compiler about the modules or symbols that the current file is using? If so, I think I know how to write this lint:
The fixit for this lint (something like what VS Code and Intellij IDEA do) would require a bit more work to make, but I don't think it's that far from the lint itself.
Most helpful comment
FWIW VS Code and Intellij IDEA both offer imports deglobbing which replace
*with required imports.