Skip to content

Commit 5d7e7c2

Browse files
committed
Add revisions to const generic issue UI tests.
1 parent 0855263 commit 5d7e7c2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+467
-149
lines changed

src/test/ui/const-generics/issues/auxiliary/const_generic_issues_lib.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
#![feature(const_generics)]
1+
#![cfg_attr(full, feature(const_generics))]
2+
#![cfg_attr(full, allow(incomplete_features))]
3+
#![cfg_attr(min, feature(min_const_generics))]
24

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
error: constant expression depends on a generic parameter
2+
--> $DIR/issue-61935.rs:10:14
3+
|
4+
LL | Self:FooImpl<{N==0}>
5+
| ^^^^^^^^^^^^^^^
6+
|
7+
= note: this may fail depending on what value the parameter takes
8+
9+
error: aborting due to previous error
10+
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
error: generic parameters must not be used inside of non trivial constant values
2+
--> $DIR/issue-61935.rs:10:23
3+
|
4+
LL | Self:FooImpl<{N==0}>
5+
| ^ non-trivial anonymous constants must not depend on the parameter `N`
6+
|
7+
= help: it is currently only allowed to use either `N` or `{ N }` as generic constants
8+
9+
error: aborting due to previous error
10+

src/test/ui/const-generics/issues/issue-61935.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
1-
#![feature(const_generics)]
2-
//~^ WARN the feature `const_generics` is incomplete
1+
// revisions: full min
2+
#![cfg_attr(full, feature(const_generics))]
3+
#![cfg_attr(full, allow(incomplete_features))]
4+
#![cfg_attr(min, feature(min_const_generics))]
35

46
trait Foo {}
57

68
impl<const N: usize> Foo for [(); N]
79
where
810
Self:FooImpl<{N==0}>
9-
//~^ERROR constant expression depends on a generic parameter
11+
//[full]~^ERROR constant expression depends on a generic parameter
12+
//[min]~^^ERROR generic parameters must not be used inside of non trivial constant values
1013
{}
1114

1215
trait FooImpl<const IS_ZERO: bool>{}

src/test/ui/const-generics/issues/issue-61935.stderr

Lines changed: 0 additions & 19 deletions
This file was deleted.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
warning: unused variable: `foo`
2+
--> $DIR/issue-62187-encountered-polymorphic-const.rs:17:9
3+
|
4+
LL | let foo = <[u8; 2]>::BIT_LEN;
5+
| ^^^ help: if this is intentional, prefix it with an underscore: `_foo`
6+
|
7+
= note: `#[warn(unused_variables)]` on by default
8+
9+
warning: 1 warning emitted
10+
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
warning: unused variable: `foo`
2+
--> $DIR/issue-62187-encountered-polymorphic-const.rs:17:9
3+
|
4+
LL | let foo = <[u8; 2]>::BIT_LEN;
5+
| ^^^ help: if this is intentional, prefix it with an underscore: `_foo`
6+
|
7+
= note: `#[warn(unused_variables)]` on by default
8+
9+
warning: 1 warning emitted
10+

src/test/ui/const-generics/issues/issue-62187-encountered-polymorphic-const.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
// run-pass
22

3-
#![feature(const_generics)]
4-
//~^ WARN the feature `const_generics` is incomplete
3+
// revisions: full min
4+
#![cfg_attr(full, feature(const_generics))]
5+
#![cfg_attr(full, allow(incomplete_features))]
6+
#![cfg_attr(min, feature(min_const_generics))]
57

68
pub trait BitLen: Sized {
79
const BIT_LEN: usize;

src/test/ui/const-generics/issues/issue-62187-encountered-polymorphic-const.stderr

Lines changed: 0 additions & 19 deletions
This file was deleted.

src/test/ui/const-generics/issues/issue-62220.stderr renamed to src/test/ui/const-generics/issues/issue-62220.full.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: constant expression depends on a generic parameter
2-
--> $DIR/issue-62220.rs:10:27
2+
--> $DIR/issue-62220.rs:13:27
33
|
44
LL | pub fn trunc(self) -> (TruncatedVector<T, { N }>, T) {
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
error: generic parameters must not be used inside of non trivial constant values
2+
--> $DIR/issue-62220.rs:8:59
3+
|
4+
LL | pub type TruncatedVector<T, const N: usize> = Vector<T, { N - 1 }>;
5+
| ^ non-trivial anonymous constants must not depend on the parameter `N`
6+
|
7+
= help: it is currently only allowed to use either `N` or `{ N }` as generic constants
8+
9+
error: aborting due to previous error
10+

src/test/ui/const-generics/issues/issue-62220.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
1-
#![allow(incomplete_features)]
2-
#![feature(const_generics)]
1+
// revisions: full min
2+
#![cfg_attr(full, feature(const_generics))]
3+
#![cfg_attr(full, allow(incomplete_features))]
4+
#![cfg_attr(min, feature(min_const_generics))]
35

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

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

811
impl<T, const N: usize> Vector<T, { N }> {
912
/// Drop the last component and return the vector with one fewer dimension.
1013
pub fn trunc(self) -> (TruncatedVector<T, { N }>, T) {
11-
//~^ ERROR constant expression depends on a generic parameter
14+
//[full]~^ ERROR constant expression depends on a generic parameter
1215
unimplemented!()
1316
}
1417
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
error: constant expression depends on a generic parameter
2+
--> $DIR/issue-62456.rs:7:20
3+
|
4+
LL | let _ = [0u64; N + 1];
5+
| ^^^^^
6+
|
7+
= note: this may fail depending on what value the parameter takes
8+
9+
error: aborting due to previous error
10+
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
error: generic parameters must not be used inside of non trivial constant values
2+
--> $DIR/issue-62456.rs:7:20
3+
|
4+
LL | let _ = [0u64; N + 1];
5+
| ^ non-trivial anonymous constants must not depend on the parameter `N`
6+
|
7+
= help: it is currently only allowed to use either `N` or `{ N }` as generic constants
8+
9+
error: aborting due to previous error
10+
Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
1-
#![feature(const_generics)]
2-
//~^ WARN the feature `const_generics` is incomplete
1+
// revisions: full min
2+
#![cfg_attr(full, feature(const_generics))]
3+
#![cfg_attr(full, allow(incomplete_features))]
4+
#![cfg_attr(min, feature(min_const_generics))]
35

46
fn foo<const N: usize>() {
57
let _ = [0u64; N + 1];
6-
//~^ ERROR constant expression depends on a generic parameter
8+
//[full]~^ ERROR constant expression depends on a generic parameter
9+
//[min]~^^ ERROR generic parameters must not be used inside of non trivial constant values
710
}
811

912
fn main() {}

src/test/ui/const-generics/issues/issue-62456.stderr

Lines changed: 0 additions & 19 deletions
This file was deleted.

src/test/ui/const-generics/issues/issue-62504.stderr renamed to src/test/ui/const-generics/issues/issue-62504.full.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: constant expression depends on a generic parameter
2-
--> $DIR/issue-62504.rs:18:25
2+
--> $DIR/issue-62504.rs:19:25
33
|
44
LL | ArrayHolder([0; Self::SIZE])
55
| ^^^^^^^^^^
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
error: generic parameters must not be used inside of non trivial constant values
2+
--> $DIR/issue-62504.rs:19:25
3+
|
4+
LL | ArrayHolder([0; Self::SIZE])
5+
| ^^^^^^^^^^ non-trivial anonymous constants must not depend on the parameter `Self`
6+
|
7+
= help: it is currently only allowed to use either `Self` or `{ Self }` as generic constants
8+
9+
error: aborting due to previous error
10+

src/test/ui/const-generics/issues/issue-62504.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
// Regression test for #62504
2-
3-
#![feature(const_generics)]
1+
// revisions: full min
42
#![allow(incomplete_features)]
3+
#![cfg_attr(full, feature(const_generics))]
4+
#![cfg_attr(full, allow(incomplete_features))]
5+
#![cfg_attr(min, feature(min_const_generics))]
56

67
trait HasSize {
78
const SIZE: usize;
@@ -16,7 +17,8 @@ struct ArrayHolder<const X: usize>([u32; X]);
1617
impl<const X: usize> ArrayHolder<X> {
1718
pub const fn new() -> Self {
1819
ArrayHolder([0; Self::SIZE])
19-
//~^ ERROR constant expression depends on a generic parameter
20+
//[full]~^ ERROR constant expression depends on a generic parameter
21+
//[min]~^^ ERROR generic parameters must not be used inside of non trivial constant values
2022
}
2123
}
2224

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
error: `NoMatch` is forbidden as the type of a const generic parameter
2+
--> $DIR/issue-62579-no-match.rs:10:17
3+
|
4+
LL | fn foo<const T: NoMatch>() -> bool {
5+
| ^^^^^^^
6+
|
7+
= note: the only supported types are integers, `bool` and `char`
8+
= note: more complex types are supported with `#[feature(const_generics)]`
9+
10+
error: aborting due to previous error
11+

src/test/ui/const-generics/issues/issue-62579-no-match.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
1-
// run-pass
2-
3-
#![feature(const_generics)]
4-
//~^ WARN the feature `const_generics` is incomplete
1+
// [full] run-pass
2+
// revisions: full min
3+
#![cfg_attr(full, feature(const_generics))]
4+
#![cfg_attr(full, allow(incomplete_features))]
5+
#![cfg_attr(min, feature(min_const_generics))]
56

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

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

src/test/ui/const-generics/issues/issue-62579-no-match.stderr

Lines changed: 0 additions & 11 deletions
This file was deleted.
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
error[E0770]: the type of const parameters must not depend on other generic parameters
2+
--> $DIR/issue-62878.rs:6:38
3+
|
4+
LL | fn foo<const N: usize, const A: [u8; N]>() {}
5+
| ^ the type must not depend on the parameter `N`
6+
7+
error[E0107]: wrong number of const arguments: expected 2, found 1
8+
--> $DIR/issue-62878.rs:11:5
9+
|
10+
LL | foo::<_, {[1]}>();
11+
| ^^^^^^^^^^^^^^^ expected 2 const arguments
12+
13+
error[E0107]: wrong number of type arguments: expected 0, found 1
14+
--> $DIR/issue-62878.rs:11:11
15+
|
16+
LL | foo::<_, {[1]}>();
17+
| ^ unexpected type argument
18+
19+
error[E0308]: mismatched types
20+
--> $DIR/issue-62878.rs:11:15
21+
|
22+
LL | foo::<_, {[1]}>();
23+
| ^^^ expected `usize`, found array `[{integer}; 1]`
24+
25+
error: aborting due to 4 previous errors
26+
27+
Some errors have detailed explanations: E0107, E0308, E0770.
28+
For more information about an error, try `rustc --explain E0107`.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
error[E0770]: the type of const parameters must not depend on other generic parameters
2+
--> $DIR/issue-62878.rs:6:38
3+
|
4+
LL | fn foo<const N: usize, const A: [u8; N]>() {}
5+
| ^ the type must not depend on the parameter `N`
6+
7+
error: `[u8; _]` is forbidden as the type of a const generic parameter
8+
--> $DIR/issue-62878.rs:6:33
9+
|
10+
LL | fn foo<const N: usize, const A: [u8; N]>() {}
11+
| ^^^^^^^
12+
|
13+
= note: the only supported types are integers, `bool` and `char`
14+
= note: more complex types are supported with `#[feature(const_generics)]`
15+
16+
error: aborting due to 2 previous errors
17+
18+
For more information about this error, try `rustc --explain E0770`.
Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
1-
#![feature(const_generics)] //~ WARN the feature `const_generics` is incomplete
1+
// revisions: full min
2+
#![cfg_attr(full, feature(const_generics))]
3+
#![cfg_attr(full, allow(incomplete_features))]
4+
#![cfg_attr(min, feature(min_const_generics))]
25

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

610
fn main() {
711
foo::<_, {[1]}>();
8-
//~^ ERROR wrong number of const arguments
9-
//~| ERROR wrong number of type arguments
10-
//~| ERROR mismatched types
12+
//[full]~^ ERROR wrong number of const arguments
13+
//[full]~| ERROR wrong number of type arguments
14+
//[full]~| ERROR mismatched types
1115
}

0 commit comments

Comments
 (0)