Closed
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
.