Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add revisions to const generic issue UI tests. #76514

Merged
merged 4 commits into from
Sep 10, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#![feature(const_generics)]
#![cfg_attr(full, feature(const_generics))]
#![cfg_attr(full, allow(incomplete_features))]
#![cfg_attr(min, feature(min_const_generics))]
lcnr marked this conversation as resolved.
Show resolved Hide resolved

// All of these three items must be in `lib2` to reproduce the error

Expand Down
10 changes: 10 additions & 0 deletions src/test/ui/const-generics/issues/issue-61935.full.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
error: constant expression depends on a generic parameter
--> $DIR/issue-61935.rs:10:14
|
LL | Self:FooImpl<{N==0}>
| ^^^^^^^^^^^^^^^
|
= note: this may fail depending on what value the parameter takes

error: aborting due to previous error

10 changes: 10 additions & 0 deletions src/test/ui/const-generics/issues/issue-61935.min.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
error: generic parameters must not be used inside of non trivial constant values
--> $DIR/issue-61935.rs:10:23
|
LL | Self:FooImpl<{N==0}>
| ^ 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

9 changes: 6 additions & 3 deletions src/test/ui/const-generics/issues/issue-61935.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
#![feature(const_generics)]
//~^ WARN the feature `const_generics` is incomplete
// revisions: full min
#![cfg_attr(full, feature(const_generics))]
#![cfg_attr(full, allow(incomplete_features))]
#![cfg_attr(min, feature(min_const_generics))]

trait Foo {}

impl<const N: usize> Foo for [(); N]
where
Self:FooImpl<{N==0}>
//~^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 inside of non trivial constant values
{}

trait FooImpl<const IS_ZERO: bool>{}
Expand Down
19 changes: 0 additions & 19 deletions src/test/ui/const-generics/issues/issue-61935.stderr

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
warning: unused variable: `foo`
--> $DIR/issue-62187-encountered-polymorphic-const.rs:17:9
|
LL | let foo = <[u8; 2]>::BIT_LEN;
| ^^^ help: if this is intentional, prefix it with an underscore: `_foo`
|
= note: `#[warn(unused_variables)]` on by default

warning: 1 warning emitted

Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
warning: unused variable: `foo`
--> $DIR/issue-62187-encountered-polymorphic-const.rs:17:9
|
LL | let foo = <[u8; 2]>::BIT_LEN;
hameerabbasi marked this conversation as resolved.
Show resolved Hide resolved
| ^^^ help: if this is intentional, prefix it with an underscore: `_foo`
|
= note: `#[warn(unused_variables)]` on by default

warning: 1 warning emitted

Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
// run-pass

#![feature(const_generics)]
//~^ WARN the feature `const_generics` is incomplete
// revisions: full min
#![cfg_attr(full, feature(const_generics))]
#![cfg_attr(full, allow(incomplete_features))]
#![cfg_attr(min, feature(min_const_generics))]

pub trait BitLen: Sized {
const BIT_LEN: usize;
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error: constant expression depends on a generic parameter
--> $DIR/issue-62220.rs:10:27
--> $DIR/issue-62220.rs:13:27
|
LL | pub fn trunc(self) -> (TruncatedVector<T, { N }>, T) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down
10 changes: 10 additions & 0 deletions src/test/ui/const-generics/issues/issue-62220.min.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
error: generic parameters must not be used inside of non trivial constant values
--> $DIR/issue-62220.rs:8:59
|
LL | pub type TruncatedVector<T, const N: usize> = Vector<T, { 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

9 changes: 6 additions & 3 deletions src/test/ui/const-generics/issues/issue-62220.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
#![allow(incomplete_features)]
#![feature(const_generics)]
// revisions: full min
#![cfg_attr(full, feature(const_generics))]
#![cfg_attr(full, allow(incomplete_features))]
#![cfg_attr(min, feature(min_const_generics))]

pub struct Vector<T, const N: usize>([T; N]);

pub type TruncatedVector<T, const N: usize> = Vector<T, { N - 1 }>;
//[min]~^ ERROR generic parameters must not be used inside of non trivial constant values

impl<T, const N: usize> Vector<T, { N }> {
/// Drop the last component and return the vector with one fewer dimension.
pub fn trunc(self) -> (TruncatedVector<T, { N }>, T) {
//~^ ERROR constant expression depends on a generic parameter
//[full]~^ ERROR constant expression depends on a generic parameter
unimplemented!()
}
}
Expand Down
10 changes: 10 additions & 0 deletions src/test/ui/const-generics/issues/issue-62456.full.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
error: constant expression depends on a generic parameter
--> $DIR/issue-62456.rs:7:20
|
LL | let _ = [0u64; N + 1];
| ^^^^^
|
= note: this may fail depending on what value the parameter takes

error: aborting due to previous error

10 changes: 10 additions & 0 deletions src/test/ui/const-generics/issues/issue-62456.min.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
error: generic parameters must not be used inside of non trivial constant values
--> $DIR/issue-62456.rs:7:20
|
LL | let _ = [0u64; 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

9 changes: 6 additions & 3 deletions src/test/ui/const-generics/issues/issue-62456.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
#![feature(const_generics)]
//~^ WARN the feature `const_generics` is incomplete
// revisions: full min
#![cfg_attr(full, feature(const_generics))]
#![cfg_attr(full, allow(incomplete_features))]
#![cfg_attr(min, feature(min_const_generics))]

fn foo<const N: usize>() {
let _ = [0u64; N + 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 inside of non trivial constant values
}

fn main() {}
19 changes: 0 additions & 19 deletions src/test/ui/const-generics/issues/issue-62456.stderr

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error: constant expression depends on a generic parameter
--> $DIR/issue-62504.rs:18:25
--> $DIR/issue-62504.rs:19:25
|
LL | ArrayHolder([0; Self::SIZE])
| ^^^^^^^^^^
Expand Down
10 changes: 10 additions & 0 deletions src/test/ui/const-generics/issues/issue-62504.min.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
error: generic parameters must not be used inside of non trivial constant values
--> $DIR/issue-62504.rs:19:25
|
LL | ArrayHolder([0; Self::SIZE])
| ^^^^^^^^^^ non-trivial anonymous constants must not depend on the parameter `Self`
|
= help: it is currently only allowed to use either `Self` or `{ Self }` as generic constants

error: aborting due to previous error

10 changes: 6 additions & 4 deletions src/test/ui/const-generics/issues/issue-62504.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
// Regression test for #62504

#![feature(const_generics)]
// revisions: full min
#![allow(incomplete_features)]
#![cfg_attr(full, feature(const_generics))]
#![cfg_attr(full, allow(incomplete_features))]
#![cfg_attr(min, feature(min_const_generics))]

trait HasSize {
const SIZE: usize;
Expand All @@ -16,7 +17,8 @@ struct ArrayHolder<const X: usize>([u32; X]);
impl<const X: usize> ArrayHolder<X> {
pub const fn new() -> Self {
ArrayHolder([0; Self::SIZE])
//~^ 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 inside of non trivial constant values
}
}

Expand Down
11 changes: 11 additions & 0 deletions src/test/ui/const-generics/issues/issue-62579-no-match.min.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
error: `NoMatch` is forbidden as the type of a const generic parameter
--> $DIR/issue-62579-no-match.rs:10:17
|
LL | fn foo<const T: NoMatch>() -> bool {
| ^^^^^^^
|
= note: the only supported types are integers, `bool` and `char`
= note: more complex types are supported with `#[feature(const_generics)]`

error: aborting due to previous error

10 changes: 6 additions & 4 deletions src/test/ui/const-generics/issues/issue-62579-no-match.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
// run-pass

#![feature(const_generics)]
//~^ WARN the feature `const_generics` is incomplete
// [full] run-pass
// revisions: full min
#![cfg_attr(full, feature(const_generics))]
#![cfg_attr(full, allow(incomplete_features))]
#![cfg_attr(min, feature(min_const_generics))]

#[derive(PartialEq, Eq)]
struct NoMatch;

fn foo<const T: NoMatch>() -> bool {
//[min]~^ ERROR `NoMatch` is forbidden as the type of a const generic parameter
true
}

Expand Down
11 changes: 0 additions & 11 deletions src/test/ui/const-generics/issues/issue-62579-no-match.stderr

This file was deleted.

28 changes: 28 additions & 0 deletions src/test/ui/const-generics/issues/issue-62878.full.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
error[E0770]: the type of const parameters must not depend on other generic parameters
--> $DIR/issue-62878.rs:6:38
|
LL | fn foo<const N: usize, const A: [u8; N]>() {}
| ^ the type must not depend on the parameter `N`

error[E0107]: wrong number of const arguments: expected 2, found 1
--> $DIR/issue-62878.rs:11:5
|
LL | foo::<_, {[1]}>();
| ^^^^^^^^^^^^^^^ expected 2 const arguments

error[E0107]: wrong number of type arguments: expected 0, found 1
--> $DIR/issue-62878.rs:11:11
|
LL | foo::<_, {[1]}>();
| ^ unexpected type argument

error[E0308]: mismatched types
--> $DIR/issue-62878.rs:11:15
|
LL | foo::<_, {[1]}>();
| ^^^ expected `usize`, found array `[{integer}; 1]`

error: aborting due to 4 previous errors

Some errors have detailed explanations: E0107, E0308, E0770.
For more information about an error, try `rustc --explain E0107`.
18 changes: 18 additions & 0 deletions src/test/ui/const-generics/issues/issue-62878.min.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
error[E0770]: the type of const parameters must not depend on other generic parameters
--> $DIR/issue-62878.rs:6:38
|
LL | fn foo<const N: usize, const A: [u8; N]>() {}
| ^ the type must not depend on the parameter `N`

error: `[u8; _]` is forbidden as the type of a const generic parameter
--> $DIR/issue-62878.rs:6:33
|
LL | fn foo<const N: usize, const A: [u8; N]>() {}
| ^^^^^^^
|
= 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 E0770`.
12 changes: 8 additions & 4 deletions src/test/ui/const-generics/issues/issue-62878.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
#![feature(const_generics)] //~ WARN the feature `const_generics` is incomplete
// revisions: full min
#![cfg_attr(full, feature(const_generics))]
#![cfg_attr(full, allow(incomplete_features))]
#![cfg_attr(min, feature(min_const_generics))]

fn foo<const N: usize, const A: [u8; N]>() {}
//~^ ERROR the type of const parameters must not
//[min]~| ERROR `[u8; _]` is forbidden as the type of a const generic parameter

fn main() {
foo::<_, {[1]}>();
//~^ ERROR wrong number of const arguments
//~| ERROR wrong number of type arguments
//~| ERROR mismatched types
//[full]~^ ERROR wrong number of const arguments
//[full]~| ERROR wrong number of type arguments
//[full]~| ERROR mismatched types
}
Loading