-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Warn about useless imports #68177
Comments
Can you provide better example? use rand;
pub fn foo() {} Warning:
|
Yours is the warning about rand not being used at all, which is different from using rand, but importing it anyway when you don't need to. Here's an example with std on the playground use std;
fn main() {
std::iter::once(5);
} The |
Here is where I most recently encountered this in the wild: wasmerio/wasmer#1140 There they have code that roughly looks like this: use blake3;
fn main() {
let mut hasher = blake3::Hasher::new();
...
} They I've seen people make this mistake quite often by now, as this used to be required in Rust 2015 but is now completely redundant in Rust 2018. |
I'm seeing quite a lot of people do the following:
However due to uniform paths, this doesn't do anything, as the crate is already accessible like that in the current module. This neither disambiguates nor does it have any meaningful effect, yet Rust does not emit a warning.
All of this only applies to uniform paths. So in Rust 2015 this actually is a meaningful import.
The text was updated successfully, but these errors were encountered: