Open
Description
I tried this code:
#![feature(const_generics)]
#[derive(PartialEq, Eq)]
enum Nat {
Z,
S(Box<Nat>)
}
fn foo<const N: Nat>() {}
And got this error:
error[E0741]: `Nat` must be annotated with `#[derive(PartialEq, Eq)]` to be used as the type of a const parameter
--> src/lib.rs:9:17
|
9 | fn foo<const N: Nat>() {}
| ^^^ `Nat` doesn't derive both `PartialEq` and `Eq`
The code without the const parameter compiles, though:
#![feature(const_generics)]
#[derive(PartialEq, Eq)]
enum Nat {
Z,
S(Box<Nat>)
}
// fn foo<const N: Nat>() {}
Meta
rustc +nightly --version --verbose
:
rustc 1.50.0-nightly (0edce6f4b 2020-12-24)
binary: rustc
commit-hash: 0edce6f4bbb4514482537f569f0b8ef48e71e0a0
commit-date: 2020-12-24
host: x86_64-apple-darwin
release: 1.50.0-nightly
Metadata
Metadata
Assignees
Labels
Area: const generics (parameters and arguments)Area: Messages for errors, warnings, and lintsCategory: This is a bug.Diagnostics: A diagnostic that is giving misleading or incorrect information.Relevant to the compiler team, which will review and decide on the PR/issue.This issue requires a nightly compiler in some way.