Add regression test for negative unsigned literals in patterns
This commit is contained in:
parent
8df89d1cb0
commit
24d94b2db9
2 changed files with 39 additions and 0 deletions
22
tests/ui/type/pattern_types/signed_ranges.rs
Normal file
22
tests/ui/type/pattern_types/signed_ranges.rs
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
#![feature(pattern_types)]
|
||||
#![feature(pattern_type_macro)]
|
||||
|
||||
use std::pat::pattern_type;
|
||||
|
||||
type Sign = pattern_type!(u32 is -10..);
|
||||
//~^ ERROR: cannot apply unary operator `-`
|
||||
|
||||
type SignedChar = pattern_type!(char is -'A'..);
|
||||
//~^ ERROR: cannot apply unary operator `-`
|
||||
|
||||
fn main() {
|
||||
match 42_u8 {
|
||||
-10..253 => {}
|
||||
_ => {}
|
||||
}
|
||||
|
||||
match 'A' {
|
||||
-'\0'..'a' => {}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
17
tests/ui/type/pattern_types/signed_ranges.stderr
Normal file
17
tests/ui/type/pattern_types/signed_ranges.stderr
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
error[E0600]: cannot apply unary operator `-` to type `u32`
|
||||
--> $DIR/signed_ranges.rs:6:34
|
||||
|
|
||||
LL | type Sign = pattern_type!(u32 is -10..);
|
||||
| ^^^ cannot apply unary operator `-`
|
||||
|
|
||||
= note: unsigned values cannot be negated
|
||||
|
||||
error[E0600]: cannot apply unary operator `-` to type `char`
|
||||
--> $DIR/signed_ranges.rs:9:41
|
||||
|
|
||||
LL | type SignedChar = pattern_type!(char is -'A'..);
|
||||
| ^^^^ cannot apply unary operator `-`
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0600`.
|
||||
Loading…
Add table
Add a link
Reference in a new issue