From 80b2835dbfab7846db422282ae953b4bfb7ba9f2 Mon Sep 17 00:00:00 2001 From: Bastian Kauschke Date: Thu, 12 Nov 2020 16:16:37 +0100 Subject: [PATCH] extend min_const_generics param ty tests --- src/test/ui/const-generics/core-types.rs | 51 +++++++++++++++++++ .../min_const_generics/complex-types.rs | 11 ++++ .../min_const_generics/complex-types.stderr | 37 ++++++++++++-- 3 files changed, 94 insertions(+), 5 deletions(-) create mode 100644 src/test/ui/const-generics/core-types.rs diff --git a/src/test/ui/const-generics/core-types.rs b/src/test/ui/const-generics/core-types.rs new file mode 100644 index 0000000000000..c4351e059dec6 --- /dev/null +++ b/src/test/ui/const-generics/core-types.rs @@ -0,0 +1,51 @@ +// Check that all types allowed with `min_const_generics` work. +// run-pass +// revisions: full min + +#![cfg_attr(full, feature(const_generics))] +#![cfg_attr(full, allow(incomplete_features))] +#![cfg_attr(min, feature(min_const_generics))] + +struct A; +struct B; +struct C; +struct D; +struct E; +struct F; +struct G; +struct H; +struct I; +struct J; +struct K; +struct L; +struct M; +struct N; + +fn main() { + let _ = A::<{u8::MIN}>; + let _ = A::<{u8::MAX}>; + let _ = B::<{u16::MIN}>; + let _ = B::<{u16::MAX}>; + let _ = C::<{u32::MIN}>; + let _ = C::<{u32::MAX}>; + let _ = D::<{u64::MIN}>; + let _ = D::<{u64::MAX}>; + let _ = E::<{u128::MIN}>; + let _ = E::<{u128::MAX}>; + let _ = F::<{usize::MIN}>; + let _ = F::<{usize::MAX}>; + let _ = G::<{i8::MIN}>; + let _ = G::<{i8::MAX}>; + let _ = H::<{i16::MIN}>; + let _ = H::<{i16::MAX}>; + let _ = I::<{i32::MIN}>; + let _ = I::<{i32::MAX}>; + let _ = J::<{i64::MIN}>; + let _ = J::<{i64::MAX}>; + let _ = K::<{i128::MIN}>; + let _ = K::<{i128::MAX}>; + let _ = L::<{isize::MIN}>; + let _ = L::<{isize::MAX}>; + let _ = M::<'A'>; + let _ = N::; +} diff --git a/src/test/ui/const-generics/min_const_generics/complex-types.rs b/src/test/ui/const-generics/min_const_generics/complex-types.rs index 98bc99d019421..2aaf2c3987558 100644 --- a/src/test/ui/const-generics/min_const_generics/complex-types.rs +++ b/src/test/ui/const-generics/min_const_generics/complex-types.rs @@ -1,4 +1,5 @@ #![feature(min_const_generics)] +#![feature(never_type)] struct Foo; //~^ ERROR `[u8; 0]` is forbidden @@ -14,4 +15,14 @@ struct Fez; struct Faz; //~^ ERROR `&'static u8` is forbidden +struct Fiz; +//~^ ERROR `!` is forbidden + +enum Goo { A, B } +//~^ ERROR `()` is forbidden + +union Boo { a: () } +//~^ ERROR `()` is forbidden + + fn main() {} diff --git a/src/test/ui/const-generics/min_const_generics/complex-types.stderr b/src/test/ui/const-generics/min_const_generics/complex-types.stderr index 4772aaf1b3e0c..52ed3c1c6ee8c 100644 --- a/src/test/ui/const-generics/min_const_generics/complex-types.stderr +++ b/src/test/ui/const-generics/min_const_generics/complex-types.stderr @@ -1,5 +1,5 @@ error: `[u8; 0]` is forbidden as the type of a const generic parameter - --> $DIR/complex-types.rs:3:21 + --> $DIR/complex-types.rs:4:21 | LL | struct Foo; | ^^^^^^^ @@ -8,7 +8,7 @@ LL | struct Foo; = note: more complex types are supported with `#[feature(const_generics)]` error: `()` is forbidden as the type of a const generic parameter - --> $DIR/complex-types.rs:6:21 + --> $DIR/complex-types.rs:7:21 | LL | struct Bar; | ^^ @@ -17,7 +17,7 @@ LL | struct Bar; = note: more complex types are supported with `#[feature(const_generics)]` error: `No` is forbidden as the type of a const generic parameter - --> $DIR/complex-types.rs:11:21 + --> $DIR/complex-types.rs:12:21 | LL | struct Fez; | ^^ @@ -26,7 +26,7 @@ LL | struct Fez; = note: more complex types are supported with `#[feature(const_generics)]` error: `&'static u8` is forbidden as the type of a const generic parameter - --> $DIR/complex-types.rs:14:21 + --> $DIR/complex-types.rs:15:21 | LL | struct Faz; | ^^^^^^^^^^^ @@ -34,5 +34,32 @@ LL | struct Faz; = note: the only supported types are integers, `bool` and `char` = note: more complex types are supported with `#[feature(const_generics)]` -error: aborting due to 4 previous errors +error: `!` is forbidden as the type of a const generic parameter + --> $DIR/complex-types.rs:18:21 + | +LL | struct Fiz; + | ^ + | + = note: the only supported types are integers, `bool` and `char` + = note: more complex types are supported with `#[feature(const_generics)]` + +error: `()` is forbidden as the type of a const generic parameter + --> $DIR/complex-types.rs:21:19 + | +LL | enum Goo { A, B } + | ^^ + | + = note: the only supported types are integers, `bool` and `char` + = note: more complex types are supported with `#[feature(const_generics)]` + +error: `()` is forbidden as the type of a const generic parameter + --> $DIR/complex-types.rs:24:20 + | +LL | union Boo { a: () } + | ^^ + | + = note: the only supported types are integers, `bool` and `char` + = note: more complex types are supported with `#[feature(const_generics)]` + +error: aborting due to 7 previous errors