rust-lang / rust-lang/rust-clippy
Possible enum_glob_use false positive
Open
Nobody has claimed this yet.
C-bug
I-false-positive
- Dominant language
- Rust
- Stars
- 13.5k
- Forks
- 2.2k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 32
Description
Summary
This code:
#![warn(clippy::pedantic)]
fn main() {
enum Ops {Add, Sub, Mul, Div};
use Ops::*;
let op = Add;
let s = match op {
Add => "+",
Sub => "-",
Mul => "*",
Div => "/",
};
println!("{}", s);
}
Gives:
warning: usage of wildcard import for enum variants
--> src/main.rs:5:9
|
5 | use Ops::*;
| ^^^^^^ help: try: `Ops::{Add, Div, Mul, Sub}`
|
note: the lint level is defined here
--> src/main.rs:1:9
|
1 | #![warn(clippy::pedantic)]
| ^^^^^^^^^^^^^^^^
= note: `#[warn(clippy::enum_glob_use)]` implied by `#[warn(clippy::pedantic)]`
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#enum_glob_use
In this case glob use seems OK to me...
Lint Name
No response
Reproducer
I tried this code:
<code>
I saw this happen:
<output>
I expected to see this happen:
Version
No response
Additional Labels
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 by reproducing the supplied Rust example with the enum_glob_use lint enabled, then inspect the lint's implementation and existing tests. Determine whether this enum-wide import should be treated as a false positive and add or update coverage so the intended diagnostic behavior is verified.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100