Rustc incorrectly suggests adding generic arguments to an enum that already has them when using enum-map-derive =1.0.0
Open
Nobody has claimed this yet.
A-diagnostics
A-macros
A-proc-macros
D-confusing
D-imprecise-spans
D-papercut
T-compiler
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
Code
#[derive(enum_map_derive::Enum)]
enum ExampleEnum<T> {
Variant(T),
}
Current output
Checking enum-generic-repro v0.1.0 (/Users/centdemeern1/Documents/RustProjects/enum-generic-repro)
error[E0425]: cannot find type `T` in this scope
--> src/lib.rs:3:13
|
3 | Variant(T),
| ^ not found in this scope
error[E0107]: missing generics for enum `ExampleEnum`
--> src/lib.rs:2:6
|
2 | enum ExampleEnum<T> {
| ^^^^^^^^^^^ expected 1 generic argument
|
note: enum defined here, with 1 generic parameter: `T`
--> src/lib.rs:2:6
|
2 | enum ExampleEnum<T> {
| ^^^^^^^^^^^ -
help: add missing generic argument
|
2 | enum ExampleEnum<T><T> {
| +++
Some errors have detailed explanations: E0107, E0425.
For more information about an error, try `rustc --explain E0107`.
error: could not compile `enum-generic-repro` (lib) due to 2 previous errors
Desired output
Rationale and extra context
rustc should probably not be suggesting invalid syntax. I don't know what this error should look like instead, though
Other cases
Rust Version
rustc 1.97.1 (8bab26f4f 2026-07-14)
binary: rustc
commit-hash: 8bab26f4f68e0e26f0bb7960be334d5b520ea452
commit-date: 2026-07-14
host: aarch64-apple-darwin
release: 1.97.1
LLVM version: 22.1.6
Anything else?
enum-map-derivedoes not actually support generic arguments. The latest version ofenum-map-deriveadds a manual check, which bypasses this bug. To reproduce this bug, use=1.0.0- I was told to report this by @estebank: https://hachyderm.io/@ekuber/117031928263200472
- Here's a repro project that uses the correct version of enum-map(-derive): enum-generic-repro.zip
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
Reproduce the diagnostic from the enum snippet in src/lib.rs using enum-map-derive =1.0.0 and the reported rustc version. Start by examining how rustc emits the E0107 missing-generics suggestion for this case. Done means the compiler no longer suggests invalid duplicated generic arguments, with the behavior covered by a regression test.
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
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100