From 2f73245ca460e1658b988092f5050afcbbf04501 Mon Sep 17 00:00:00 2001 From: varkor Date: Tue, 5 Feb 2019 17:54:23 +0100 Subject: [PATCH] Add test forbidding const parameters in const fn --- .../const-fn-with-const-param.rs | 12 ++++++++++ .../const-fn-with-const-param.stderr | 24 +++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 src/test/ui/const-generics/const-fn-with-const-param.rs create mode 100644 src/test/ui/const-generics/const-fn-with-const-param.stderr diff --git a/src/test/ui/const-generics/const-fn-with-const-param.rs b/src/test/ui/const-generics/const-fn-with-const-param.rs new file mode 100644 index 000000000000..052d723d96ed --- /dev/null +++ b/src/test/ui/const-generics/const-fn-with-const-param.rs @@ -0,0 +1,12 @@ +#![feature(const_generics)] +//~^ WARN the feature `const_generics` is incomplete and may cause the compiler to crash + +const fn const_u32_identity() -> u32 { + //~^ ERROR const parameters are not permitted in `const fn` + //~^^ ERROR const generics in any position are currently unsupported + X +} + +fn main() { + println!("{:?}", const_u32_identity::<18>()); +} diff --git a/src/test/ui/const-generics/const-fn-with-const-param.stderr b/src/test/ui/const-generics/const-fn-with-const-param.stderr new file mode 100644 index 000000000000..a08ebfb0d976 --- /dev/null +++ b/src/test/ui/const-generics/const-fn-with-const-param.stderr @@ -0,0 +1,24 @@ +warning: the feature `const_generics` is incomplete and may cause the compiler to crash + --> $DIR/const-fn-with-const-param.rs:1:12 + | +LL | #![feature(const_generics)] + | ^^^^^^^^^^^^^^ + +error: const parameters are not permitted in `const fn` + --> $DIR/const-fn-with-const-param.rs:4:1 + | +LL | / const fn const_u32_identity() -> u32 { +LL | | //~^ ERROR const parameters are not permitted in `const fn` +LL | | //~^^ ERROR const generics in any position are currently unsupported +LL | | X +LL | | } + | |_^ + +error: const generics in any position are currently unsupported + --> $DIR/const-fn-with-const-param.rs:4:35 + | +LL | const fn const_u32_identity() -> u32 { + | ^ + +error: aborting due to 2 previous errors +