Skip to content

Const generics: T doesn't derive both PartialEq and Eq #70790

Closed
@Aloso

Description

@Aloso

I tried this code:

#![allow(incomplete_features)]
#![feature(const_generics)]

pub trait GT<T: Eq + PartialEq, const N: T> {}

This produces the following error on rustc 1.44.0-nightly:

error[E0741]: the types of const generic parameters must derive `PartialEq` and `Eq`
 --> src/lib.rs:4:42
  |
4 | pub trait GT<T: Eq + PartialEq, const N: T> {}
  |                                          ^ `T` doesn't derive both `PartialEq` and `Eq`

error: aborting due to previous error

I guess that const generics with a generic type isn't supported/allowed. If that's the case, this should be mentioned in the error message.

Meta

rustc --version --verbose:

rustc 1.44.0-nightly (74bd074ee 2020-04-03)
binary: rustc
commit-hash: 74bd074eefcf4915c73d1ab91bc90859664729e6
commit-date: 2020-04-03
host: x86_64-unknown-linux-gnu
release: 1.44.0-nightly
LLVM version: 9.0

Metadata

Metadata

Assignees

Labels

A-const-genericsArea: const generics (parameters and arguments)A-diagnosticsArea: Messages for errors, warnings, and lintsC-bugCategory: This is a bug.F-const_generics`#![feature(const_generics)]`T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.requires-nightlyThis issue requires a nightly compiler in some way.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions