-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Open
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-enumArea: Enums (discriminated unions, or more generally ADTs (algebraic data types))Area: Enums (discriminated unions, or more generally ADTs (algebraic data types))A-reprArea: the `#[repr(stuff)]` attributeArea: the `#[repr(stuff)]` attributeT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
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
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-enumArea: Enums (discriminated unions, or more generally ADTs (algebraic data types))Area: Enums (discriminated unions, or more generally ADTs (algebraic data types))A-reprArea: the `#[repr(stuff)]` attributeArea: the `#[repr(stuff)]` attributeT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.