Skip to content

Commit 162405f

Browse files
varkoryodaldevoid
andcommitted
Fix negative integer literal test
Co-Authored-By: Gabriel Smith <[email protected]>
1 parent 3e3a421 commit 162405f

File tree

2 files changed

+8
-19
lines changed

2 files changed

+8
-19
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,22 @@
11
#![feature(const_generics)]
22
//~^ WARN the feature `const_generics` is incomplete and may cause the compiler to crash
33

4-
fn u32_identity<const X: u32>() -> u32 {
4+
fn i32_identity<const X: i32>() -> i32 {
55
5
66
}
77

88
fn foo_a() {
9-
u32_identity::<-1>(); //~ ERROR expected identifier, found `<-`
9+
i32_identity::<-1>(); //~ ERROR expected identifier, found `<-`
1010
}
1111

1212
fn foo_b() {
13-
u32_identity::<1 + 2>(); //~ ERROR expected one of `,` or `>`, found `+`
13+
i32_identity::<1 + 2>(); //~ ERROR expected one of `,` or `>`, found `+`
1414
}
1515

1616
fn foo_c() {
17-
u32_identity::< -1 >(); // ok
18-
// FIXME(const_generics)
19-
//~^^ ERROR cannot apply unary operator `-` to type `u32` [E0600]
17+
i32_identity::< -1 >(); // ok
2018
}
2119

2220
fn main() {
23-
u32_identity::<5>(); // ok
21+
i32_identity::<5>(); // ok
2422
}
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
error: expected identifier, found `<-`
22
--> $DIR/const-expression-parameter.rs:9:19
33
|
4-
LL | u32_identity::<-1>(); //~ ERROR expected identifier, found `<-`
4+
LL | i32_identity::<-1>(); //~ ERROR expected identifier, found `<-`
55
| ^^ expected identifier
66

77
error: expected one of `,` or `>`, found `+`
88
--> $DIR/const-expression-parameter.rs:13:22
99
|
10-
LL | u32_identity::<1 + 2>(); //~ ERROR expected one of `,` or `>`, found `+`
10+
LL | i32_identity::<1 + 2>(); //~ ERROR expected one of `,` or `>`, found `+`
1111
| ^ expected one of `,` or `>` here
1212

1313
warning: the feature `const_generics` is incomplete and may cause the compiler to crash
@@ -16,14 +16,5 @@ warning: the feature `const_generics` is incomplete and may cause the compiler t
1616
LL | #![feature(const_generics)]
1717
| ^^^^^^^^^^^^^^
1818

19-
error[E0600]: cannot apply unary operator `-` to type `u32`
20-
--> $DIR/const-expression-parameter.rs:17:21
21-
|
22-
LL | u32_identity::< -1 >(); // ok
23-
| ^^ cannot apply unary operator `-`
24-
|
25-
= note: unsigned values cannot be negated
26-
27-
error: aborting due to 3 previous errors
19+
error: aborting due to 2 previous errors
2820

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

0 commit comments

Comments
 (0)