Could `unused_imports` be suppressed when there are name resolution failures?
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
Code
use std::ops::ControlFlow::{self, Continue, Break};
use std::cmp::Ordering::*;
#[inline]
fn chain_less(a: &u32, other: &u32) -> ControlFlow<bool> {
match a.partial_cmp(other) {
None => Break(false),
Some(Less) => Break(true),
Some(Equal) => Contine(()),
Some(Greater) => Break(false),
}
}
Current output
warning: unused import: `Continue`
--> src/lib.rs:1:35
|
1 | use std::ops::ControlFlow::{self, Continue, Break};
| ^^^^^^^^
|
= note: `#[warn(unused_imports)]` on by default
error[E0425]: cannot find function, tuple struct or tuple variant `Contine` in this scope
--> src/lib.rs:9:24
|
9 | Some(Equal) => Contine(()),
| ^^^^^^^ help: a tuple variant with a similar name exists: `Continue`
--> /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library/core/src/ops/control_flow.rs:89:5
|
= note: similarly named tuple variant `Continue` defined here
For more information about this error, try `rustc --explain E0425`.
Desired output
error[E0425]: cannot find function, tuple struct or tuple variant `Contine` in this scope
--> src/lib.rs:9:24
|
9 | Some(Equal) => Contine(()),
| ^^^^^^^ help: a tuple variant with a similar name exists: `Continue`
--> /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library/core/src/ops/control_flow.rs:89:5
|
= note: similarly named tuple variant `Continue` defined here
Rationale and extra context
When I got the import correct, but typo'd it in the use, it would be nice if the compiler didn't complain about the unused import.
(From a layman's perspective, it also feels weird that it's reported as unused before the errors in the code that are looking up names, even though I guess from an implementation perspective it's reasonable that a token that doesn't appear again and isn't a trait is of course unused without needing to do lookup.)
Other cases
No response
Anything else?
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the reproducer in src/lib.rs, using the Rust Playground link to confirm the current warning and name-resolution error. Trace how unused_imports is emitted alongside the unresolved Contine error; done means the unused-import warning is suppressed when name resolution fails, while the error remains.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100