-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Lint against imports that are dead code #80443
Comments
|
That's just the default warning of an unused import, not the specific case I'm talking about. Here's a proper reproduction: use regex;
fn main() {
regex::Regex::new(r"^\d{4}-\d{2}-\d{2}$").unwrap();
} Here, the statement uses I've had multiple occurrences now where I had to teach beginners that this isn't necessary, because the compiler fails to point this out. |
I think I'll take a shot at this. @rustbot claim |
Should this be implemented as a new lint or just as an instance of |
We already have a lint for redundant imports (#58805), it's a part of |
This is also a duplicate of #61640. |
Triage: going to close this in favor of #61640. |
I'm very often seeing people write imports such as this one:
use regex;
Such an import is almost always dead code, because ever since Rust 2018 all external crates are already in scope. In fact pretty much any import that doesn't contain at least one of
pub
,as ...
or::
is very likely dead code. Rust does not currently emit any warning for such an import.The text was updated successfully, but these errors were encountered: