Forbid non-structural_match types in const generics

This commit is contained in:
varkor 2019-10-20 17:17:12 +01:00
parent 600607f45a
commit bbd53deaeb
4 changed files with 65 additions and 0 deletions

View file

@ -0,0 +1,13 @@
#![feature(const_generics)]
//~^ WARN the feature `const_generics` is incomplete and may cause the compiler to crash
#[derive(PartialEq, Eq)]
struct A;
struct B<const X: A>; // ok
struct C;
struct D<const X: C>; //~ ERROR the types of const generic parameters must derive
fn main() {}

View file

@ -0,0 +1,17 @@
warning: the feature `const_generics` is incomplete and may cause the compiler to crash
--> $DIR/forbid-non-structural_match-types.rs:1:12
|
LL | #![feature(const_generics)]
| ^^^^^^^^^^^^^^
|
= note: `#[warn(incomplete_features)]` on by default
error[E0739]: the types of const generic parameters must derive `PartialEq` and `Eq`
--> $DIR/forbid-non-structural_match-types.rs:11:19
|
LL | struct D<const X: C>;
| ^ `C` doesn't derive both `PartialEq` and `Eq`
error: aborting due to previous error
For more information about this error, try `rustc --explain E0739`.