-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-const-genericsArea: const generics (parameters and arguments)Area: const generics (parameters and arguments)A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsE-mentorCall for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.T-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
Given the following code (playground link):
enum E {
V1,
V2,
}
struct S<const X: E>;
Rust gives a diagnostic suggesting deriving PartialEq, Eq
:
error: `E` is forbidden as the type of a const generic parameter
--> src/lib.rs:6:19
|
6 | struct S<const X: E>;
| ^
|
= note: the only supported types are integers, `bool` and `char`
error[E0741]: `E` must be annotated with `#[derive(PartialEq, Eq)]` to be used as the type of a const parameter
--> src/lib.rs:6:19
|
6 | struct S<const X: E>;
| ^ `E` doesn't derive both `PartialEq` and `Eq`
For more information about this error, try `rustc --explain E0741`.
However, adding #[derive(PartialEq, Eq)]
leads the compiler to still give an error about not supporting this.
A non-nightly compiler should not give the second error at all; it should only give the first, saying that the only supported types are integers, bool
and char
.
schneiderfelipe
Metadata
Metadata
Assignees
Labels
A-const-genericsArea: const generics (parameters and arguments)Area: const generics (parameters and arguments)A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsE-mentorCall for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.T-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.