Fix negative integer literal test
Co-Authored-By: Gabriel Smith <yodaldevoid@users.noreply.github.com>
This commit is contained in:
parent
3e3a4212e8
commit
162405f222
2 changed files with 8 additions and 19 deletions
|
|
@ -1,24 +1,22 @@
|
|||
#![feature(const_generics)]
|
||||
//~^ WARN the feature `const_generics` is incomplete and may cause the compiler to crash
|
||||
|
||||
fn u32_identity<const X: u32>() -> u32 {
|
||||
fn i32_identity<const X: i32>() -> i32 {
|
||||
5
|
||||
}
|
||||
|
||||
fn foo_a() {
|
||||
u32_identity::<-1>(); //~ ERROR expected identifier, found `<-`
|
||||
i32_identity::<-1>(); //~ ERROR expected identifier, found `<-`
|
||||
}
|
||||
|
||||
fn foo_b() {
|
||||
u32_identity::<1 + 2>(); //~ ERROR expected one of `,` or `>`, found `+`
|
||||
i32_identity::<1 + 2>(); //~ ERROR expected one of `,` or `>`, found `+`
|
||||
}
|
||||
|
||||
fn foo_c() {
|
||||
u32_identity::< -1 >(); // ok
|
||||
// FIXME(const_generics)
|
||||
//~^^ ERROR cannot apply unary operator `-` to type `u32` [E0600]
|
||||
i32_identity::< -1 >(); // ok
|
||||
}
|
||||
|
||||
fn main() {
|
||||
u32_identity::<5>(); // ok
|
||||
i32_identity::<5>(); // ok
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,13 +1,13 @@
|
|||
error: expected identifier, found `<-`
|
||||
--> $DIR/const-expression-parameter.rs:9:19
|
||||
|
|
||||
LL | u32_identity::<-1>(); //~ ERROR expected identifier, found `<-`
|
||||
LL | i32_identity::<-1>(); //~ ERROR expected identifier, found `<-`
|
||||
| ^^ expected identifier
|
||||
|
||||
error: expected one of `,` or `>`, found `+`
|
||||
--> $DIR/const-expression-parameter.rs:13:22
|
||||
|
|
||||
LL | u32_identity::<1 + 2>(); //~ ERROR expected one of `,` or `>`, found `+`
|
||||
LL | i32_identity::<1 + 2>(); //~ ERROR expected one of `,` or `>`, found `+`
|
||||
| ^ expected one of `,` or `>` here
|
||||
|
||||
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
|
|||
LL | #![feature(const_generics)]
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
||||
error[E0600]: cannot apply unary operator `-` to type `u32`
|
||||
--> $DIR/const-expression-parameter.rs:17:21
|
||||
|
|
||||
LL | u32_identity::< -1 >(); // ok
|
||||
| ^^ cannot apply unary operator `-`
|
||||
|
|
||||
= note: unsigned values cannot be negated
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0600`.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue