From bf2f62cb98de0b255db318a3d580ce0c2e1a976d Mon Sep 17 00:00:00 2001 From: varkor Date: Tue, 5 Feb 2019 17:55:25 +0100 Subject: Add test for const parameter before other generic parameters --- .../const-param-before-other-params.rs | 13 +++++++++++ .../const-param-before-other-params.stderr | 26 ++++++++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 src/test/ui/const-generics/const-param-before-other-params.rs create mode 100644 src/test/ui/const-generics/const-param-before-other-params.stderr diff --git a/src/test/ui/const-generics/const-param-before-other-params.rs b/src/test/ui/const-generics/const-param-before-other-params.rs new file mode 100644 index 00000000000..3f120cbc4d3 --- /dev/null +++ b/src/test/ui/const-generics/const-param-before-other-params.rs @@ -0,0 +1,13 @@ +#![feature(const_generics)] +//~^ WARN the feature `const_generics` is incomplete and may cause the compiler to crash + +fn foo(_: T) { + //~^ ERROR type parameters must be declared prior to const parameters + //~^^ ERROR const generics in any position are currently unsupported +} + +fn bar(_: &'a ()) { + //~^ ERROR lifetime parameters must be declared prior to const parameters +} + +fn main() {} diff --git a/src/test/ui/const-generics/const-param-before-other-params.stderr b/src/test/ui/const-generics/const-param-before-other-params.stderr new file mode 100644 index 00000000000..303ea16ca83 --- /dev/null +++ b/src/test/ui/const-generics/const-param-before-other-params.stderr @@ -0,0 +1,26 @@ +warning: the feature `const_generics` is incomplete and may cause the compiler to crash + --> $DIR/const-param-before-other-params.rs:1:12 + | +LL | #![feature(const_generics)] + | ^^^^^^^^^^^^^^ + +error: type parameters must be declared prior to const parameters + --> $DIR/const-param-before-other-params.rs:4:21 + | +LL | fn foo(_: T) { + | --------------^- help: reorder the parameters: lifetimes, then types, then consts: `` + +error: lifetime parameters must be declared prior to const parameters + --> $DIR/const-param-before-other-params.rs:9:21 + | +LL | fn bar(_: &'a ()) { + | --------------^^- help: reorder the parameters: lifetimes, then types, then consts: `<'a, X>` + +error: const generics in any position are currently unsupported + --> $DIR/const-param-before-other-params.rs:4:14 + | +LL | fn foo(_: T) { + | ^ + +error: aborting due to 3 previous errors + -- cgit 1.4.1-3-g733a5