From 102f7a8b26a549f095f7d075eae37189be2bdd5a Mon Sep 17 00:00:00 2001 From: varkor Date: Thu, 25 Apr 2019 21:12:03 +0100 Subject: [PATCH] Make sure const params with type params don't cause errors without a feature gate --- ...aram-type-depends-on-type-param-ungated.rs | 6 ++++++ ...-type-depends-on-type-param-ungated.stderr | 19 +++++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 src/test/ui/const-generics/const-param-type-depends-on-type-param-ungated.rs create mode 100644 src/test/ui/const-generics/const-param-type-depends-on-type-param-ungated.stderr diff --git a/src/test/ui/const-generics/const-param-type-depends-on-type-param-ungated.rs b/src/test/ui/const-generics/const-param-type-depends-on-type-param-ungated.rs new file mode 100644 index 000000000000..af5e8f49754e --- /dev/null +++ b/src/test/ui/const-generics/const-param-type-depends-on-type-param-ungated.rs @@ -0,0 +1,6 @@ +use std::marker::PhantomData; + +struct B(PhantomData<[T; N]>); //~ ERROR const generics are unstable +//~^ ERROR const parameters cannot depend on type parameters + +fn main() {} diff --git a/src/test/ui/const-generics/const-param-type-depends-on-type-param-ungated.stderr b/src/test/ui/const-generics/const-param-type-depends-on-type-param-ungated.stderr new file mode 100644 index 000000000000..e3adbcfe6020 --- /dev/null +++ b/src/test/ui/const-generics/const-param-type-depends-on-type-param-ungated.stderr @@ -0,0 +1,19 @@ +error[E0671]: const parameters cannot depend on type parameters + --> $DIR/const-param-type-depends-on-type-param-ungated.rs:3:22 + | +LL | struct B(PhantomData<[T; N]>); + | ^ const parameter depends on type parameter + +error[E0658]: const generics are unstable + --> $DIR/const-param-type-depends-on-type-param-ungated.rs:3:19 + | +LL | struct B(PhantomData<[T; N]>); + | ^ + | + = note: for more information, see https://github.com/rust-lang/rust/issues/44580 + = help: add #![feature(const_generics)] to the crate attributes to enable + +error: aborting due to 2 previous errors + +Some errors have detailed explanations: E0658, E0671. +For more information about an error, try `rustc --explain E0658`.