Skip to content

Commit 4c18ee4

Browse files
varkoryodaldevoid
andcommitted
Update const generics tests
Co-Authored-By: Gabriel Smith <[email protected]>
1 parent 54b935b commit 4c18ee4

10 files changed

+30
-53
lines changed

src/test/ui/const-generics/const-expression-parameter.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
//~^ WARN the feature `const_generics` is incomplete and may cause the compiler to crash
33

44
fn u32_identity<const X: u32>() -> u32 {
5-
//~^ ERROR const generics in any position are currently unsupported
65
5
76
}
87

@@ -16,6 +15,8 @@ fn foo_b() {
1615

1716
fn foo_c() {
1817
u32_identity::< -1 >(); // ok
18+
// FIXME(const_generics)
19+
//~^^ ERROR cannot apply unary operator `-` to type `u32` [E0600]
1920
}
2021

2122
fn main() {
Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
error: expected identifier, found `<-`
2-
--> $DIR/const-expression-parameter.rs:10:19
2+
--> $DIR/const-expression-parameter.rs:9:19
33
|
44
LL | u32_identity::<-1>(); //~ ERROR expected identifier, found `<-`
55
| ^^ expected identifier
66

77
error: expected one of `,` or `>`, found `+`
8-
--> $DIR/const-expression-parameter.rs:14:22
8+
--> $DIR/const-expression-parameter.rs:13:22
99
|
1010
LL | u32_identity::<1 + 2>(); //~ ERROR expected one of `,` or `>`, found `+`
1111
| ^ expected one of `,` or `>` here
@@ -16,11 +16,14 @@ warning: the feature `const_generics` is incomplete and may cause the compiler t
1616
LL | #![feature(const_generics)]
1717
| ^^^^^^^^^^^^^^
1818

19-
error: const generics in any position are currently unsupported
20-
--> $DIR/const-expression-parameter.rs:4:23
19+
error[E0600]: cannot apply unary operator `-` to type `u32`
20+
--> $DIR/const-expression-parameter.rs:17:21
2121
|
22-
LL | fn u32_identity<const X: u32>() -> u32 {
23-
| ^
22+
LL | u32_identity::< -1 >(); // ok
23+
| ^^ cannot apply unary operator `-`
24+
|
25+
= note: unsigned values cannot be negated
2426

2527
error: aborting due to 3 previous errors
2628

29+
For more information about this error, try `rustc --explain E0600`.

src/test/ui/const-generics/const-fn-with-const-param.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
const fn const_u32_identity<const X: u32>() -> u32 {
55
//~^ ERROR const parameters are not permitted in `const fn`
6-
//~^^ ERROR const generics in any position are currently unsupported
76
X
87
}
98

src/test/ui/const-generics/const-fn-with-const-param.stderr

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,9 @@ error: const parameters are not permitted in `const fn`
99
|
1010
LL | / const fn const_u32_identity<const X: u32>() -> u32 {
1111
LL | | //~^ ERROR const parameters are not permitted in `const fn`
12-
LL | | //~^^ ERROR const generics in any position are currently unsupported
1312
LL | | X
1413
LL | | }
1514
| |_^
1615

17-
error: const generics in any position are currently unsupported
18-
--> $DIR/const-fn-with-const-param.rs:4:35
19-
|
20-
LL | const fn const_u32_identity<const X: u32>() -> u32 {
21-
| ^
22-
23-
error: aborting due to 2 previous errors
16+
error: aborting due to previous error
2417

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
#![feature(const_generics)]
22
//~^ WARN the feature `const_generics` is incomplete and may cause the compiler to crash
33

4-
fn foo<const X: (), T>(_: T) {
4+
fn foo<const X: (), T>(_: &T) {
55
//~^ ERROR type parameters must be declared prior to const parameters
6-
//~^^ ERROR const generics in any position are currently unsupported
76
}
87

98
fn bar<const X: (), 'a>(_: &'a ()) {
109
//~^ ERROR lifetime parameters must be declared prior to const parameters
11-
//~^^ ERROR const generics in any position are currently unsupported
1210
}
1311

1412
fn main() {}

src/test/ui/const-generics/const-param-before-other-params.stderr

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,26 +7,14 @@ LL | #![feature(const_generics)]
77
error: type parameters must be declared prior to const parameters
88
--> $DIR/const-param-before-other-params.rs:4:21
99
|
10-
LL | fn foo<const X: (), T>(_: T) {
10+
LL | fn foo<const X: (), T>(_: &T) {
1111
| --------------^- help: reorder the parameters: lifetimes, then types, then consts: `<T, const X: ()>`
1212

1313
error: lifetime parameters must be declared prior to const parameters
14-
--> $DIR/const-param-before-other-params.rs:9:21
14+
--> $DIR/const-param-before-other-params.rs:8:21
1515
|
1616
LL | fn bar<const X: (), 'a>(_: &'a ()) {
1717
| --------------^^- help: reorder the parameters: lifetimes, then types, then consts: `<'a, const X: ()>`
1818

19-
error: const generics in any position are currently unsupported
20-
--> $DIR/const-param-before-other-params.rs:4:14
21-
|
22-
LL | fn foo<const X: (), T>(_: T) {
23-
| ^
24-
25-
error: const generics in any position are currently unsupported
26-
--> $DIR/const-param-before-other-params.rs:9:14
27-
|
28-
LL | fn bar<const X: (), 'a>(_: &'a ()) {
29-
| ^
30-
31-
error: aborting due to 4 previous errors
19+
error: aborting due to 2 previous errors
3220

src/test/ui/const-generics/const-param-from-outer-fn.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
//~^ WARN the feature `const_generics` is incomplete and may cause the compiler to crash
33

44
fn foo<const X: u32>() {
5-
//~^ ERROR const generics in any position are currently unsupported
65
fn bar() -> u32 {
76
X //~ ERROR can't use generic parameters from outer function
87
}

src/test/ui/const-generics/const-param-from-outer-fn.stderr

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,15 @@ LL | #![feature(const_generics)]
55
| ^^^^^^^^^^^^^^
66

77
error[E0401]: can't use generic parameters from outer function
8-
--> $DIR/const-param-from-outer-fn.rs:7:9
8+
--> $DIR/const-param-from-outer-fn.rs:6:9
99
|
1010
LL | fn foo<const X: u32>() {
1111
| - const variable from outer function
12-
LL | //~^ ERROR const generics in any position are currently unsupported
1312
LL | fn bar() -> u32 {
1413
| --- try adding a local generic parameter in this method instead
1514
LL | X //~ ERROR can't use generic parameters from outer function
1615
| ^ use of generic parameter from outer function
1716

18-
error: const generics in any position are currently unsupported
19-
--> $DIR/const-param-from-outer-fn.rs:4:14
20-
|
21-
LL | fn foo<const X: u32>() {
22-
| ^
23-
24-
error: aborting due to 2 previous errors
17+
error: aborting due to previous error
2518

2619
For more information about this error, try `rustc --explain E0401`.

src/test/ui/const-generics/const-parameter-uppercase-lint.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,7 @@
44
#![deny(non_upper_case_globals)]
55

66
fn noop<const x: u32>() {
7-
//~^ ERROR const generics in any position are currently unsupported
7+
//~^ ERROR const parameter `x` should have an upper case name
88
}
9+
10+
fn main() {}

src/test/ui/const-generics/const-parameter-uppercase-lint.stderr

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,17 @@ warning: the feature `const_generics` is incomplete and may cause the compiler t
44
LL | #![feature(const_generics)]
55
| ^^^^^^^^^^^^^^
66

7-
error[E0601]: `main` function not found in crate `const_parameter_uppercase_lint`
8-
|
9-
= note: consider adding a `main` function to `$DIR/const-parameter-uppercase-lint.rs`
10-
11-
error: const generics in any position are currently unsupported
7+
error: const parameter `x` should have an upper case name
128
--> $DIR/const-parameter-uppercase-lint.rs:6:15
139
|
1410
LL | fn noop<const x: u32>() {
15-
| ^
11+
| ^ help: convert the identifier to upper case: `X`
12+
|
13+
note: lint level defined here
14+
--> $DIR/const-parameter-uppercase-lint.rs:4:9
15+
|
16+
LL | #![deny(non_upper_case_globals)]
17+
| ^^^^^^^^^^^^^^^^^^^^^^
1618

17-
error: aborting due to 2 previous errors
19+
error: aborting due to previous error
1820

19-
For more information about this error, try `rustc --explain E0601`.

0 commit comments

Comments
 (0)