`#[repr]` on zero-variant enums leaves the reader with questions
Open
Nobody has claimed this yet.
A-diagnostics
A-enum
A-repr
T-compiler
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
Code
#[repr(isize)]
enum Uninhabited {}
Current output
error[E0084]: unsupported representation for zero-variant enum
--> src/lib.rs:1:1
|
1 | #[repr(isize)]
| ^^^^^^^^^^^^^^
2 | enum Uninhabited {}
| ---------------- zero-variant enum
Desired output
error[E0084]: zero-variant enums do not support `#[repr]`
--> src/lib.rs:1:1
|
1 | #[repr(isize)]
| ^^^^^^^^^^^^^^
2 | enum Uninhabited {}
| ---------------- zero-variant enum
Rationale and extra context
The current output leaves the user questioning whether there may be some valid repr while not being told which ones are valid options. The diagnostic should probably be more clear about the fact that the attribute is generally not supported on zero-variant enums
Other cases
Rust Version
rustc 1.86.0 (05f9846f8 2025-03-31)
binary: rustc
commit-hash: 05f9846f893b09a1be1fc8560e33fc3c815cfecb
commit-date: 2025-03-31
host: x86_64-pc-windows-msvc
release: 1.86.0
LLVM version: 19.1.7
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
Reproduce the diagnostic with the issue's zero-variant enum and #[repr(isize)] snippet. Find the compiler diagnostic entry for E0084, update the wording so it states that zero-variant enums do not support #[repr], and update or add the corresponding expected diagnostic test. Confirm the revised output matches the desired example.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 55/100