From 9abc6bd28df390279b9f477538a778edf38ffd80 Mon Sep 17 00:00:00 2001 From: Hameer Abbasi Date: Fri, 11 Sep 2020 11:42:32 +0200 Subject: [PATCH] Add revisions to const generic const_evaluatable_checked tests. --- ...feature-gate-const_evaluatable_checked.full.stderr} | 2 +- .../feature-gate-const_evaluatable_checked.min.stderr | 10 ++++++++++ .../feature-gate-const_evaluatable_checked.rs | 9 ++++++--- .../const_evaluatable_checked/simple.min.stderr | 10 ++++++++++ .../const-generics/const_evaluatable_checked/simple.rs | 8 ++++++-- .../{simple_fail.stderr => simple_fail.full.stderr} | 2 +- .../const_evaluatable_checked/simple_fail.min.stderr | 10 ++++++++++ .../const_evaluatable_checked/simple_fail.rs | 8 ++++++-- 8 files changed, 50 insertions(+), 9 deletions(-) rename src/test/ui/const-generics/const_evaluatable_checked/{feature-gate-const_evaluatable_checked.stderr => feature-gate-const_evaluatable_checked.full.stderr} (82%) create mode 100644 src/test/ui/const-generics/const_evaluatable_checked/feature-gate-const_evaluatable_checked.min.stderr create mode 100644 src/test/ui/const-generics/const_evaluatable_checked/simple.min.stderr rename src/test/ui/const-generics/const_evaluatable_checked/{simple_fail.stderr => simple_fail.full.stderr} (90%) create mode 100644 src/test/ui/const-generics/const_evaluatable_checked/simple_fail.min.stderr diff --git a/src/test/ui/const-generics/const_evaluatable_checked/feature-gate-const_evaluatable_checked.stderr b/src/test/ui/const-generics/const_evaluatable_checked/feature-gate-const_evaluatable_checked.full.stderr similarity index 82% rename from src/test/ui/const-generics/const_evaluatable_checked/feature-gate-const_evaluatable_checked.stderr rename to src/test/ui/const-generics/const_evaluatable_checked/feature-gate-const_evaluatable_checked.full.stderr index 6e4a22a38b17c..b2816367ea107 100644 --- a/src/test/ui/const-generics/const_evaluatable_checked/feature-gate-const_evaluatable_checked.stderr +++ b/src/test/ui/const-generics/const_evaluatable_checked/feature-gate-const_evaluatable_checked.full.stderr @@ -1,5 +1,5 @@ error: constant expression depends on a generic parameter - --> $DIR/feature-gate-const_evaluatable_checked.rs:6:30 + --> $DIR/feature-gate-const_evaluatable_checked.rs:9:30 | LL | fn test() -> Arr where Arr: Default { | ^^^^^^ diff --git a/src/test/ui/const-generics/const_evaluatable_checked/feature-gate-const_evaluatable_checked.min.stderr b/src/test/ui/const-generics/const_evaluatable_checked/feature-gate-const_evaluatable_checked.min.stderr new file mode 100644 index 0000000000000..269710db164b1 --- /dev/null +++ b/src/test/ui/const-generics/const_evaluatable_checked/feature-gate-const_evaluatable_checked.min.stderr @@ -0,0 +1,10 @@ +error: generic parameters must not be used inside of non trivial constant values + --> $DIR/feature-gate-const_evaluatable_checked.rs:6:33 + | +LL | type Arr = [u8; N - 1]; + | ^ non-trivial anonymous constants must not depend on the parameter `N` + | + = help: it is currently only allowed to use either `N` or `{ N }` as generic constants + +error: aborting due to previous error + diff --git a/src/test/ui/const-generics/const_evaluatable_checked/feature-gate-const_evaluatable_checked.rs b/src/test/ui/const-generics/const_evaluatable_checked/feature-gate-const_evaluatable_checked.rs index 941bd5e9e5d0a..af3090115f24a 100644 --- a/src/test/ui/const-generics/const_evaluatable_checked/feature-gate-const_evaluatable_checked.rs +++ b/src/test/ui/const-generics/const_evaluatable_checked/feature-gate-const_evaluatable_checked.rs @@ -1,10 +1,13 @@ -#![feature(const_generics)] -#![allow(incomplete_features)] +// revisions: full min +#![cfg_attr(full, feature(const_generics))] +#![cfg_attr(full, allow(incomplete_features))] +#![cfg_attr(min, feature(min_const_generics))] type Arr = [u8; N - 1]; +//[min]~^ ERROR generic parameters must not be used inside of non trivial constant values fn test() -> Arr where Arr: Default { - //~^ ERROR constant expression depends + //[full]~^ ERROR constant expression depends Default::default() } diff --git a/src/test/ui/const-generics/const_evaluatable_checked/simple.min.stderr b/src/test/ui/const-generics/const_evaluatable_checked/simple.min.stderr new file mode 100644 index 0000000000000..da8ccdaee4146 --- /dev/null +++ b/src/test/ui/const-generics/const_evaluatable_checked/simple.min.stderr @@ -0,0 +1,10 @@ +error: generic parameters must not be used inside of non trivial constant values + --> $DIR/simple.rs:8:33 + | +LL | type Arr = [u8; N - 1]; + | ^ non-trivial anonymous constants must not depend on the parameter `N` + | + = help: it is currently only allowed to use either `N` or `{ N }` as generic constants + +error: aborting due to previous error + diff --git a/src/test/ui/const-generics/const_evaluatable_checked/simple.rs b/src/test/ui/const-generics/const_evaluatable_checked/simple.rs index a7ead78b97bae..27dc6b103200d 100644 --- a/src/test/ui/const-generics/const_evaluatable_checked/simple.rs +++ b/src/test/ui/const-generics/const_evaluatable_checked/simple.rs @@ -1,8 +1,12 @@ -// run-pass -#![feature(const_generics, const_evaluatable_checked)] +// [full] run-pass +// revisions: full min +#![cfg_attr(full, feature(const_generics))] +#![cfg_attr(min, feature(min_const_generics))] +#![feature(const_evaluatable_checked)] #![allow(incomplete_features)] type Arr = [u8; N - 1]; +//[min]~^ ERROR generic parameters must not be used inside of non trivial constant values fn test() -> Arr where Arr: Default { Default::default() diff --git a/src/test/ui/const-generics/const_evaluatable_checked/simple_fail.stderr b/src/test/ui/const-generics/const_evaluatable_checked/simple_fail.full.stderr similarity index 90% rename from src/test/ui/const-generics/const_evaluatable_checked/simple_fail.stderr rename to src/test/ui/const-generics/const_evaluatable_checked/simple_fail.full.stderr index 1ac5e1d95537a..104cab8667c70 100644 --- a/src/test/ui/const-generics/const_evaluatable_checked/simple_fail.stderr +++ b/src/test/ui/const-generics/const_evaluatable_checked/simple_fail.full.stderr @@ -1,5 +1,5 @@ error[E0080]: evaluation of constant value failed - --> $DIR/simple_fail.rs:4:33 + --> $DIR/simple_fail.rs:7:33 | LL | type Arr = [u8; N - 1]; | ^^^^^ attempt to compute `0_usize - 1_usize` which would overflow diff --git a/src/test/ui/const-generics/const_evaluatable_checked/simple_fail.min.stderr b/src/test/ui/const-generics/const_evaluatable_checked/simple_fail.min.stderr new file mode 100644 index 0000000000000..042710f13273e --- /dev/null +++ b/src/test/ui/const-generics/const_evaluatable_checked/simple_fail.min.stderr @@ -0,0 +1,10 @@ +error: generic parameters must not be used inside of non trivial constant values + --> $DIR/simple_fail.rs:7:33 + | +LL | type Arr = [u8; N - 1]; + | ^ non-trivial anonymous constants must not depend on the parameter `N` + | + = help: it is currently only allowed to use either `N` or `{ N }` as generic constants + +error: aborting due to previous error + diff --git a/src/test/ui/const-generics/const_evaluatable_checked/simple_fail.rs b/src/test/ui/const-generics/const_evaluatable_checked/simple_fail.rs index 1edf1885dd281..b15e0ff183954 100644 --- a/src/test/ui/const-generics/const_evaluatable_checked/simple_fail.rs +++ b/src/test/ui/const-generics/const_evaluatable_checked/simple_fail.rs @@ -1,7 +1,11 @@ -#![feature(const_generics, const_evaluatable_checked)] +// revisions: full min +#![cfg_attr(full, feature(const_generics))] +#![cfg_attr(min, feature(min_const_generics))] +#![feature(const_evaluatable_checked)] #![allow(incomplete_features)] -type Arr = [u8; N - 1]; //~ ERROR evaluation of constant +type Arr = [u8; N - 1]; //[full]~ ERROR evaluation of constant +//[min]~^ ERROR generic parameters must not be used inside of non trivial constant values fn test() -> Arr where Arr: Sized { todo!()