Skip to content

Commit

Permalink
test min_const_generics using revisions
Browse files Browse the repository at this point in the history
  • Loading branch information
lcnr committed Aug 7, 2020
1 parent 37c29ad commit 644c894
Show file tree
Hide file tree
Showing 24 changed files with 154 additions and 52 deletions.
@@ -1,16 +1,16 @@
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> {
| ^
|
= 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
Expand Down
10 changes: 10 additions & 0 deletions 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

4 changes: 3 additions & 1 deletion 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
Expand Down
@@ -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
Expand Down
20 changes: 20 additions & 0 deletions 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`.
7 changes: 4 additions & 3 deletions 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<'_, ""> {}
@@ -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
Expand Down
@@ -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>;

Expand Down
@@ -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
Expand Down
6 changes: 3 additions & 3 deletions 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]
Expand Down
@@ -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`
Expand Down
15 changes: 15 additions & 0 deletions 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`.
5 changes: 3 additions & 2 deletions 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 }]
Expand Down
24 changes: 24 additions & 0 deletions 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`.
15 changes: 15 additions & 0 deletions 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`.
5 changes: 3 additions & 2 deletions 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]
Expand Down
@@ -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
Expand Down
6 changes: 3 additions & 3 deletions 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;

Expand Down
@@ -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
Expand Down
6 changes: 3 additions & 3 deletions 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:
Expand Down
@@ -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}> {
| ^^^^^^^^^^^^^^
Expand Down
10 changes: 10 additions & 0 deletions 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

8 changes: 5 additions & 3 deletions 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
}
}
Expand Down
@@ -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;

Expand Down

0 comments on commit 644c894

Please sign in to comment.