about summary refs log tree commit diff
diff options
context:
space:
mode:
authorvarkor <github@varkor.com>2019-04-25 21:12:03 +0100
committervarkor <github@varkor.com>2019-04-25 21:12:03 +0100
commit102f7a8b26a549f095f7d075eae37189be2bdd5a (patch)
treecd9a96fc57a23aba0ef6db1aea77e4fc14c57745
parent976b3d1d9ebde26f32a3a58731d68e8edcc01962 (diff)
downloadrust-102f7a8b26a549f095f7d075eae37189be2bdd5a.tar.gz
rust-102f7a8b26a549f095f7d075eae37189be2bdd5a.zip
Make sure const params with type params don't cause errors without a feature gate
-rw-r--r--src/test/ui/const-generics/const-param-type-depends-on-type-param-ungated.rs6
-rw-r--r--src/test/ui/const-generics/const-param-type-depends-on-type-param-ungated.stderr19
2 files changed, 25 insertions, 0 deletions
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 00000000000..af5e8f49754
--- /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<T, const N: T>(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 00000000000..e3adbcfe602
--- /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<T, const N: T>(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<T, const N: T>(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`.