Change:
I tried this code: This produces the following error on rustc 1.44.0-nightly: 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. :
The type needs to derive , not just implement them. This is because only types can be used for const generics at the moment, but we don't expose that to the user. Maybe we could improve the diagnostic here by actually mentioning .
thanks for fixing this so quickly! Is there a chance that this restriction will be lifted, so the above code compiles?
We would like to lift the restriction, but probably not in the first stabilised version of const generics, as it's not easy to get right: we need to be very careful in making sure that we don't accidentally allow unsoundness to sneak in, and there are many subtleties.

Discussion:
if traits::search_for_structural_match_violation(param.hir_id, param.span, tcx, ty) .is_some() { <del> struct_span_err!( tcx.sess, hir_ty.span, E0741, "the types of const generic parameters must derive `PartialEq` and `Eq`", ) .span_label( hir_ty.span, format!("`{}` doesn't derive both `PartialEq` and `Eq`", ty), ) .emit(); </del> <ins> // We use the same error code in both branches, because this is really the same // issue: we just special-case the message for type parameters to make it // clearer. if let ty::Param(_) = ty.peel_refs().kind { // Const parameters may not have type parameters as their types, // because we cannot be sure that the type parameter derives `PartialEq` // and `Eq` (just implementing them is not enough for `structural_match`). struct_span_err!( tcx.sess, hir_ty.span, E0741, "`{}` is not guaranteed to `#[derive(PartialEq, Eq)]`, so may not be  used as the type of a const parameter", ty, ) .span_label( hir_ty.span, format!("`{}` may not derive both `PartialEq` and `Eq`", ty), ) .note( "it is not currently possible to use a type parameter as the type of a  const parameter", ) .emit(); } else { struct_span_err!( tcx.sess, hir_ty.span, E0741, "`{}` must be annotated with `#[derive(PartialEq, Eq)]` to be used as  the type of a const parameter", ty, ) .span_label( hir_ty.span, format!("`{}` doesn't derive both `PartialEq` and `Eq`", ty), ) .emit(); } </ins> } ty }

use std::marker::PhantomData; struct B<T, const N: T>(PhantomData<[T; N]>); //~ ERROR const generics are unstable <del> //~^ ERROR the types of const generic parameters must derive `PartialEq` and `Eq` </del> <ins> //~^ ERROR `T` is not guaranteed to `#[derive(PartialEq, Eq)]` </ins> fn main() {}

= note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information = help: add `#![feature(const_generics)]` to the crate attributes to enable <del> error[E0741]: the types of const generic parameters must derive `PartialEq` and `Eq` </del> <ins> error[E0741]: `T` is not guaranteed to `#[derive(PartialEq, Eq)]`, so may not be used as the type of a const parameter </ins> --> $DIR/const-param-type-depends-on-type-param-ungated.rs:3:22 | LL | struct B<T, const N: T>(PhantomData<[T; N]>); <del> |                      ^ `T` doesn't derive both `PartialEq` and `Eq` </del> <ins> |                      ^ `T` may not derive both `PartialEq` and `Eq` | = note: it is not currently possible to use a type parameter as the type of a const parameter </ins> error: aborting due to 2 previous errors

// details. pub struct Dependent<T, const X: T>([(); X]); <del> //~^ ERROR the types of const generic parameters must derive `PartialEq` and `Eq` </del> <ins> //~^ ERROR `T` is not guaranteed to `#[derive(PartialEq, Eq)]` </ins> fn main() {}

| = note: `#[warn(incomplete_features)]` on by default <del> error[E0741]: the types of const generic parameters must derive `PartialEq` and `Eq` </del> <ins> error[E0741]: `T` is not guaranteed to `#[derive(PartialEq, Eq)]`, so may not be used as the type of a const parameter </ins> --> $DIR/const-param-type-depends-on-type-param.rs:9:34 | LL | pub struct Dependent<T, const X: T>([(); X]); <del> |                                  ^ `T` doesn't derive both `PartialEq` and `Eq` </del> <ins> |                                  ^ `T` may not derive both `PartialEq` and `Eq` | = note: it is not currently possible to use a type parameter as the type of a const parameter </ins> error: aborting due to previous error; 1 warning emitted

struct C; <del> struct D<const X: C>; //~ ERROR the types of const generic parameters must derive </del> <ins> struct D<const X: C>; //~ ERROR `C` must be annotated with `#[derive(PartialEq, Eq)]` </ins> fn main() {}

| = note: `#[warn(incomplete_features)]` on by default <del> error[E0741]: the types of const generic parameters must derive `PartialEq` and `Eq` </del> <ins> error[E0741]: `C` must be annotated with `#[derive(PartialEq, Eq)]` to be used as the type of a const parameter </ins> --> $DIR/forbid-non-structural_match-types.rs:11:19 | LL | struct D<const X: C>;