diff options
| author | Bastian Kauschke <bastian_kauschke@hotmail.de> | 2020-08-06 22:57:09 +0200 |
|---|---|---|
| committer | Bastian Kauschke <bastian_kauschke@hotmail.de> | 2020-08-07 07:49:48 +0200 |
| commit | 644c8949121da0c16f65b772bf6e217748d94530 (patch) | |
| tree | 4e8d3d523dc92df516ed9c05d2ffda244dc73003 | |
| parent | 37c29adabc638f9c601daf5b78d0f6de63e35f99 (diff) | |
| download | rust-644c8949121da0c16f65b772bf6e217748d94530.tar.gz rust-644c8949121da0c16f65b772bf6e217748d94530.zip | |
test min_const_generics using revisions
24 files changed, 154 insertions, 52 deletions
diff --git a/src/test/ui/const-generics/defaults/wrong-order.stderr b/src/test/ui/const-generics/defaults/wrong-order.full.stderr index 283f6656121..c51028d5b20 100644 --- a/src/test/ui/const-generics/defaults/wrong-order.stderr +++ b/src/test/ui/const-generics/defaults/wrong-order.full.stderr @@ -1,5 +1,5 @@ error: type parameters with a default must be trailing - --> $DIR/wrong-order.rs:3:10 + --> $DIR/wrong-order.rs:5:10 | LL | struct A<T = u32, const N: usize> { | ^ @@ -7,10 +7,10 @@ LL | struct A<T = u32, const N: usize> { = note: using type defaults and const parameters in the same parameter list is currently not permitted warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/wrong-order.rs:1:12 + --> $DIR/wrong-order.rs:2:27 | -LL | #![feature(const_generics)] - | ^^^^^^^^^^^^^^ +LL | #![cfg_attr(full, feature(const_generics))] + | ^^^^^^^^^^^^^^ | = note: `#[warn(incomplete_features)]` on by default = note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information diff --git a/src/test/ui/const-generics/defaults/wrong-order.min.stderr b/src/test/ui/const-generics/defaults/wrong-order.min.stderr new file mode 100644 index 00000000000..29a46367004 --- /dev/null +++ b/src/test/ui/const-generics/defaults/wrong-order.min.stderr @@ -0,0 +1,10 @@ +error: type parameters with a default must be trailing + --> $DIR/wrong-order.rs:5:10 + | +LL | struct A<T = u32, const N: usize> { + | ^ + | + = note: using type defaults and const parameters in the same parameter list is currently not permitted + +error: aborting due to previous error + diff --git a/src/test/ui/const-generics/defaults/wrong-order.rs b/src/test/ui/const-generics/defaults/wrong-order.rs index 7f17c6358b7..cb36d456f38 100644 --- a/src/test/ui/const-generics/defaults/wrong-order.rs +++ b/src/test/ui/const-generics/defaults/wrong-order.rs @@ -1,4 +1,6 @@ -#![feature(const_generics)] //~ WARN the feature `const_generics` is incomplete +// revisions: full min +#![cfg_attr(full, feature(const_generics))] //[full]~WARN the feature `const_generics` is incomplete +#![cfg_attr(min, feature(min_const_generics))] struct A<T = u32, const N: usize> { //~^ ERROR type parameters with a default must be trailing diff --git a/src/test/ui/const-generics/issues/issue-56445.stderr b/src/test/ui/const-generics/issues/issue-56445.full.stderr index fba638b0b2b..d853ec5015e 100644 --- a/src/test/ui/const-generics/issues/issue-56445.stderr +++ b/src/test/ui/const-generics/issues/issue-56445.full.stderr @@ -1,8 +1,8 @@ warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/issue-56445.rs:3:12 + --> $DIR/issue-56445.rs:3:27 | -LL | #![feature(const_generics)] - | ^^^^^^^^^^^^^^ +LL | #![cfg_attr(full, feature(const_generics))] + | ^^^^^^^^^^^^^^ | = note: `#[warn(incomplete_features)]` on by default = note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information diff --git a/src/test/ui/const-generics/issues/issue-56445.min.stderr b/src/test/ui/const-generics/issues/issue-56445.min.stderr new file mode 100644 index 00000000000..ca35ee5b290 --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-56445.min.stderr @@ -0,0 +1,20 @@ +error[E0771]: use of non-static lifetime `'a` in const generic + --> $DIR/issue-56445.rs:9:26 + | +LL | struct Bug<'a, const S: &'a str>(PhantomData<&'a ()>); + | ^^ + | + = note: for more information, see issue #74052 <https://github.com/rust-lang/rust/issues/74052> + +error: using `&'static str` as const generic parameters is forbidden + --> $DIR/issue-56445.rs:9:25 + | +LL | struct Bug<'a, const S: &'a str>(PhantomData<&'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 2 previous errors + +For more information about this error, try `rustc --explain E0771`. diff --git a/src/test/ui/const-generics/issues/issue-56445.rs b/src/test/ui/const-generics/issues/issue-56445.rs index 26441512e3f..174eb16abfc 100644 --- a/src/test/ui/const-generics/issues/issue-56445.rs +++ b/src/test/ui/const-generics/issues/issue-56445.rs @@ -1,12 +1,13 @@ // Regression test for https://github.com/rust-lang/rust/issues/56445#issuecomment-518402995. - -#![feature(const_generics)] -//~^ WARN: the feature `const_generics` is incomplete +// revisions: full min +#![cfg_attr(full, feature(const_generics))] //[full]~WARN the feature `const_generics` is incomplete +#![cfg_attr(min, feature(min_const_generics))] #![crate_type = "lib"] use std::marker::PhantomData; struct Bug<'a, const S: &'a str>(PhantomData<&'a ()>); //~^ ERROR: use of non-static lifetime `'a` in const generic +//[min]~| ERROR: using `&'static str` as const impl Bug<'_, ""> {} diff --git a/src/test/ui/const-generics/issues/issue-61336-1.stderr b/src/test/ui/const-generics/issues/issue-60818-struct-constructors.full.stderr index b2c69d57c40..c03b7252a3c 100644 --- a/src/test/ui/const-generics/issues/issue-61336-1.stderr +++ b/src/test/ui/const-generics/issues/issue-60818-struct-constructors.full.stderr @@ -1,8 +1,8 @@ warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/issue-61336-1.rs:1:12 + --> $DIR/issue-60818-struct-constructors.rs:3:27 | -LL | #![feature(const_generics)] - | ^^^^^^^^^^^^^^ +LL | #![cfg_attr(full, feature(const_generics))] + | ^^^^^^^^^^^^^^ | = note: `#[warn(incomplete_features)]` on by default = note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information diff --git a/src/test/ui/const-generics/issues/issue-60818-struct-constructors.rs b/src/test/ui/const-generics/issues/issue-60818-struct-constructors.rs index 26d74ffb254..ae2b0520fb1 100644 --- a/src/test/ui/const-generics/issues/issue-60818-struct-constructors.rs +++ b/src/test/ui/const-generics/issues/issue-60818-struct-constructors.rs @@ -1,7 +1,7 @@ // check-pass - -#![feature(const_generics)] -//~^ WARN the feature `const_generics` is incomplete +// revisions: full min +#![cfg_attr(full, feature(const_generics))] //[full]~WARN the feature `const_generics` is incomplete +#![cfg_attr(min, feature(min_const_generics))] struct Generic<const V: usize>; diff --git a/src/test/ui/const-generics/issues/issue-60818-struct-constructors.stderr b/src/test/ui/const-generics/issues/issue-61336-1.full.stderr index 94a2b673a51..f18728eabbb 100644 --- a/src/test/ui/const-generics/issues/issue-60818-struct-constructors.stderr +++ b/src/test/ui/const-generics/issues/issue-61336-1.full.stderr @@ -1,8 +1,8 @@ warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/issue-60818-struct-constructors.rs:3:12 + --> $DIR/issue-61336-1.rs:3:27 | -LL | #![feature(const_generics)] - | ^^^^^^^^^^^^^^ +LL | #![cfg_attr(full, feature(const_generics))] + | ^^^^^^^^^^^^^^ | = note: `#[warn(incomplete_features)]` on by default = note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information diff --git a/src/test/ui/const-generics/issues/issue-61336-1.rs b/src/test/ui/const-generics/issues/issue-61336-1.rs index 2135c868bbc..201c0d039d9 100644 --- a/src/test/ui/const-generics/issues/issue-61336-1.rs +++ b/src/test/ui/const-generics/issues/issue-61336-1.rs @@ -1,7 +1,7 @@ -#![feature(const_generics)] -//~^ WARN the feature `const_generics` is incomplete - // build-pass +// revisions: full min +#![cfg_attr(full, feature(const_generics))] //[full]~WARN the feature `const_generics` is incomplete +#![cfg_attr(min, feature(min_const_generics))] fn f<T: Copy, const N: usize>(x: T) -> [T; N] { [x; N] diff --git a/src/test/ui/const-generics/issues/issue-61336-2.stderr b/src/test/ui/const-generics/issues/issue-61336-2.full.stderr index 5f3395223f9..d21cd9df054 100644 --- a/src/test/ui/const-generics/issues/issue-61336-2.stderr +++ b/src/test/ui/const-generics/issues/issue-61336-2.full.stderr @@ -1,14 +1,14 @@ warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/issue-61336-2.rs:1:12 + --> $DIR/issue-61336-2.rs:2:27 | -LL | #![feature(const_generics)] - | ^^^^^^^^^^^^^^ +LL | #![cfg_attr(full, feature(const_generics))] + | ^^^^^^^^^^^^^^ | = note: `#[warn(incomplete_features)]` on by default = note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information error[E0277]: the trait bound `T: std::marker::Copy` is not satisfied - --> $DIR/issue-61336-2.rs:9:5 + --> $DIR/issue-61336-2.rs:10:5 | LL | [x; { N }] | ^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `T` diff --git a/src/test/ui/const-generics/issues/issue-61336-2.min.stderr b/src/test/ui/const-generics/issues/issue-61336-2.min.stderr new file mode 100644 index 00000000000..29ab7b1305e --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-61336-2.min.stderr @@ -0,0 +1,15 @@ +error[E0277]: the trait bound `T: std::marker::Copy` is not satisfied + --> $DIR/issue-61336-2.rs:10:5 + | +LL | [x; { N }] + | ^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `T` + | + = note: the `Copy` trait is required because the repeated element will be copied +help: consider restricting type parameter `T` + | +LL | fn g<T: std::marker::Copy, const N: usize>(x: T) -> [T; N] { + | ^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/const-generics/issues/issue-61336-2.rs b/src/test/ui/const-generics/issues/issue-61336-2.rs index 52969056f00..25b9271105e 100644 --- a/src/test/ui/const-generics/issues/issue-61336-2.rs +++ b/src/test/ui/const-generics/issues/issue-61336-2.rs @@ -1,5 +1,6 @@ -#![feature(const_generics)] -//~^ WARN the feature `const_generics` is incomplete +// revisions: full min +#![cfg_attr(full, feature(const_generics))] //[full]~WARN the feature `const_generics` is incomplete +#![cfg_attr(min, feature(min_const_generics))] fn f<T: Copy, const N: usize>(x: T) -> [T; N] { [x; { N }] diff --git a/src/test/ui/const-generics/issues/issue-61336.full.stderr b/src/test/ui/const-generics/issues/issue-61336.full.stderr new file mode 100644 index 00000000000..d1b5d5eb941 --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-61336.full.stderr @@ -0,0 +1,24 @@ +warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/issue-61336.rs:2:27 + | +LL | #![cfg_attr(full, feature(const_generics))] + | ^^^^^^^^^^^^^^ + | + = note: `#[warn(incomplete_features)]` on by default + = note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information + +error[E0277]: the trait bound `T: std::marker::Copy` is not satisfied + --> $DIR/issue-61336.rs:10:5 + | +LL | [x; N] + | ^^^^^^ the trait `std::marker::Copy` is not implemented for `T` + | + = note: the `Copy` trait is required because the repeated element will be copied +help: consider restricting type parameter `T` + | +LL | fn g<T: std::marker::Copy, const N: usize>(x: T) -> [T; N] { + | ^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error; 1 warning emitted + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/const-generics/issues/issue-61336.min.stderr b/src/test/ui/const-generics/issues/issue-61336.min.stderr new file mode 100644 index 00000000000..bced8bbd82f --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-61336.min.stderr @@ -0,0 +1,15 @@ +error[E0277]: the trait bound `T: std::marker::Copy` is not satisfied + --> $DIR/issue-61336.rs:10:5 + | +LL | [x; N] + | ^^^^^^ the trait `std::marker::Copy` is not implemented for `T` + | + = note: the `Copy` trait is required because the repeated element will be copied +help: consider restricting type parameter `T` + | +LL | fn g<T: std::marker::Copy, const N: usize>(x: T) -> [T; N] { + | ^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/const-generics/issues/issue-61336.rs b/src/test/ui/const-generics/issues/issue-61336.rs index eb0f3097627..fb55542a1c9 100644 --- a/src/test/ui/const-generics/issues/issue-61336.rs +++ b/src/test/ui/const-generics/issues/issue-61336.rs @@ -1,5 +1,6 @@ -#![feature(const_generics)] -//~^ WARN the feature `const_generics` is incomplete +// revisions: full min +#![cfg_attr(full, feature(const_generics))] //[full]~WARN the feature `const_generics` is incomplete +#![cfg_attr(min, feature(min_const_generics))] fn f<T: Copy, const N: usize>(x: T) -> [T; N] { [x; N] diff --git a/src/test/ui/const-generics/issues/issue-61432.stderr b/src/test/ui/const-generics/issues/issue-61422.full.stderr index 1d547b1b6c9..ac6c378295d 100644 --- a/src/test/ui/const-generics/issues/issue-61432.stderr +++ b/src/test/ui/const-generics/issues/issue-61422.full.stderr @@ -1,8 +1,8 @@ warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/issue-61432.rs:3:12 + --> $DIR/issue-61422.rs:3:27 | -LL | #![feature(const_generics)] - | ^^^^^^^^^^^^^^ +LL | #![cfg_attr(full, feature(const_generics))] + | ^^^^^^^^^^^^^^ | = note: `#[warn(incomplete_features)]` on by default = note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information diff --git a/src/test/ui/const-generics/issues/issue-61422.rs b/src/test/ui/const-generics/issues/issue-61422.rs index 7e7ef6867ed..649f8b4255b 100644 --- a/src/test/ui/const-generics/issues/issue-61422.rs +++ b/src/test/ui/const-generics/issues/issue-61422.rs @@ -1,7 +1,7 @@ // check-pass - -#![feature(const_generics)] -//~^ WARN the feature `const_generics` is incomplete +// revisions: full min +#![cfg_attr(full, feature(const_generics))] //[full]~WARN the feature `const_generics` is incomplete +#![cfg_attr(min, feature(min_const_generics))] use std::mem; diff --git a/src/test/ui/const-generics/issues/issue-61422.stderr b/src/test/ui/const-generics/issues/issue-61432.full.stderr index 69bbaada691..82b36de45a2 100644 --- a/src/test/ui/const-generics/issues/issue-61422.stderr +++ b/src/test/ui/const-generics/issues/issue-61432.full.stderr @@ -1,8 +1,8 @@ warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/issue-61422.rs:3:12 + --> $DIR/issue-61432.rs:3:27 | -LL | #![feature(const_generics)] - | ^^^^^^^^^^^^^^ +LL | #![cfg_attr(full, feature(const_generics))] + | ^^^^^^^^^^^^^^ | = note: `#[warn(incomplete_features)]` on by default = note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information diff --git a/src/test/ui/const-generics/issues/issue-61432.rs b/src/test/ui/const-generics/issues/issue-61432.rs index 0440468e9e6..91a4794099c 100644 --- a/src/test/ui/const-generics/issues/issue-61432.rs +++ b/src/test/ui/const-generics/issues/issue-61432.rs @@ -1,7 +1,7 @@ // run-pass - -#![feature(const_generics)] -//~^ WARN the feature `const_generics` is incomplete +// revisions: full min +#![cfg_attr(full, feature(const_generics))] //[full]~WARN the feature `const_generics` is incomplete +#![cfg_attr(min, feature(min_const_generics))] fn promote<const N: i32>() { // works: diff --git a/src/test/ui/const-generics/issues/issue-61747.stderr b/src/test/ui/const-generics/issues/issue-61747.full.stderr index 2685d9fdf16..3ccce5675fc 100644 --- a/src/test/ui/const-generics/issues/issue-61747.stderr +++ b/src/test/ui/const-generics/issues/issue-61747.full.stderr @@ -1,14 +1,14 @@ warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/issue-61747.rs:1:12 + --> $DIR/issue-61747.rs:2:27 | -LL | #![feature(const_generics)] - | ^^^^^^^^^^^^^^ +LL | #![cfg_attr(full, feature(const_generics))] + | ^^^^^^^^^^^^^^ | = note: `#[warn(incomplete_features)]` on by default = note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information error: constant expression depends on a generic parameter - --> $DIR/issue-61747.rs:7:23 + --> $DIR/issue-61747.rs:8:23 | LL | fn successor() -> Const<{C + 1}> { | ^^^^^^^^^^^^^^ diff --git a/src/test/ui/const-generics/issues/issue-61747.min.stderr b/src/test/ui/const-generics/issues/issue-61747.min.stderr new file mode 100644 index 00000000000..2061b6c55bb --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-61747.min.stderr @@ -0,0 +1,10 @@ +error: generic parameters must not be used inside of non trivial constant values + --> $DIR/issue-61747.rs:8:30 + | +LL | fn successor() -> Const<{C + 1}> { + | ^ non-trivial anonymous constants must not depend on the parameter `C` + | + = help: it is currently only allowed to use either `C` or `{ C }` as generic constants + +error: aborting due to previous error + diff --git a/src/test/ui/const-generics/issues/issue-61747.rs b/src/test/ui/const-generics/issues/issue-61747.rs index cc671163e85..4e5cde17f39 100644 --- a/src/test/ui/const-generics/issues/issue-61747.rs +++ b/src/test/ui/const-generics/issues/issue-61747.rs @@ -1,11 +1,13 @@ -#![feature(const_generics)] -//~^ WARN the feature `const_generics` is incomplete +// revisions: full min +#![cfg_attr(full, feature(const_generics))] //[full]~WARN the feature `const_generics` is incomplete +#![cfg_attr(min, feature(min_const_generics))] struct Const<const N: usize>; impl<const C: usize> Const<{C}> { fn successor() -> Const<{C + 1}> { - //~^ ERROR constant expression depends on a generic parameter + //[full]~^ ERROR constant expression depends on a generic parameter + //[min]~^^ ERROR generic parameters must not be used Const } } diff --git a/src/test/ui/const-generics/type-dependent/const-arg-in-const-arg.rs b/src/test/ui/const-generics/type-dependent/const-arg-in-const-arg.rs index ae50252facd..3ccdd472613 100644 --- a/src/test/ui/const-generics/type-dependent/const-arg-in-const-arg.rs +++ b/src/test/ui/const-generics/type-dependent/const-arg-in-const-arg.rs @@ -1,7 +1,8 @@ // run-pass -#![feature(const_generics)] +// revisions: full min +#![cfg_attr(full, feature(const_generics))] +#![cfg_attr(min, feature(min_const_generics))] #![allow(incomplete_features)] -#![feature(const_fn)] struct Foo; |
