Preserve literals and range kinds in manual_range_patterns
This commit is contained in:
parent
bcf856bfb3
commit
bbf67c3424
4 changed files with 171 additions and 52 deletions
|
|
@ -13,8 +13,8 @@ fn main() {
|
|||
let _ = matches!(f, 1 | 2147483647);
|
||||
let _ = matches!(f, 0 | 2147483647);
|
||||
let _ = matches!(f, -2147483647 | 2147483647);
|
||||
let _ = matches!(f, 1 | (2..=4));
|
||||
let _ = matches!(f, 1 | (2..4));
|
||||
let _ = matches!(f, 1..=4);
|
||||
let _ = matches!(f, 1..4);
|
||||
let _ = matches!(f, 1..=48324729);
|
||||
let _ = matches!(f, 0..=48324730);
|
||||
let _ = matches!(f, 0..=3);
|
||||
|
|
@ -25,9 +25,20 @@ fn main() {
|
|||
};
|
||||
let _ = matches!(f, -5..=3);
|
||||
let _ = matches!(f, -1 | -5 | 3 | -2 | -4 | -3 | 0 | 1); // 2 is missing
|
||||
let _ = matches!(f, -1000001..=1000001);
|
||||
let _ = matches!(f, -1_000_001..=1_000_001);
|
||||
let _ = matches!(f, -1_000_000..=1_000_000 | -1_000_001 | 1_000_002);
|
||||
|
||||
matches!(f, 0x00..=0x03);
|
||||
matches!(f, 0x00..=0x07);
|
||||
matches!(f, -0x09..=0x00);
|
||||
|
||||
matches!(f, 0..=5);
|
||||
matches!(f, 0..5);
|
||||
|
||||
matches!(f, 0..10);
|
||||
matches!(f, 0..=10);
|
||||
matches!(f, 0..=10);
|
||||
|
||||
macro_rules! mac {
|
||||
($e:expr) => {
|
||||
matches!($e, 1..=10)
|
||||
|
|
|
|||
|
|
@ -28,6 +28,17 @@ fn main() {
|
|||
let _ = matches!(f, -1_000_000..=1_000_000 | -1_000_001 | 1_000_001);
|
||||
let _ = matches!(f, -1_000_000..=1_000_000 | -1_000_001 | 1_000_002);
|
||||
|
||||
matches!(f, 0x00 | 0x01 | 0x02 | 0x03);
|
||||
matches!(f, 0x00..=0x05 | 0x06 | 0x07);
|
||||
matches!(f, -0x09 | -0x08 | -0x07..=0x00);
|
||||
|
||||
matches!(f, 0..5 | 5);
|
||||
matches!(f, 0 | 1..5);
|
||||
|
||||
matches!(f, 0..=5 | 6..10);
|
||||
matches!(f, 0..5 | 5..=10);
|
||||
matches!(f, 5..=10 | 0..5);
|
||||
|
||||
macro_rules! mac {
|
||||
($e:expr) => {
|
||||
matches!($e, 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10)
|
||||
|
|
|
|||
|
|
@ -12,6 +12,18 @@ error: this OR pattern can be rewritten using a range
|
|||
LL | let _ = matches!(f, 4 | 2 | 3 | 1 | 5 | 6 | 9 | 7 | 8 | 10);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `1..=10`
|
||||
|
||||
error: this OR pattern can be rewritten using a range
|
||||
--> $DIR/manual_range_patterns.rs:16:25
|
||||
|
|
||||
LL | let _ = matches!(f, 1 | (2..=4));
|
||||
| ^^^^^^^^^^^ help: try: `1..=4`
|
||||
|
||||
error: this OR pattern can be rewritten using a range
|
||||
--> $DIR/manual_range_patterns.rs:17:25
|
||||
|
|
||||
LL | let _ = matches!(f, 1 | (2..4));
|
||||
| ^^^^^^^^^^ help: try: `1..4`
|
||||
|
||||
error: this OR pattern can be rewritten using a range
|
||||
--> $DIR/manual_range_patterns.rs:18:25
|
||||
|
|
||||
|
|
@ -46,10 +58,58 @@ error: this OR pattern can be rewritten using a range
|
|||
--> $DIR/manual_range_patterns.rs:28:25
|
||||
|
|
||||
LL | let _ = matches!(f, -1_000_000..=1_000_000 | -1_000_001 | 1_000_001);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `-1000001..=1000001`
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `-1_000_001..=1_000_001`
|
||||
|
||||
error: this OR pattern can be rewritten using a range
|
||||
--> $DIR/manual_range_patterns.rs:33:26
|
||||
--> $DIR/manual_range_patterns.rs:31:17
|
||||
|
|
||||
LL | matches!(f, 0x00 | 0x01 | 0x02 | 0x03);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `0x00..=0x03`
|
||||
|
||||
error: this OR pattern can be rewritten using a range
|
||||
--> $DIR/manual_range_patterns.rs:32:17
|
||||
|
|
||||
LL | matches!(f, 0x00..=0x05 | 0x06 | 0x07);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `0x00..=0x07`
|
||||
|
||||
error: this OR pattern can be rewritten using a range
|
||||
--> $DIR/manual_range_patterns.rs:33:17
|
||||
|
|
||||
LL | matches!(f, -0x09 | -0x08 | -0x07..=0x00);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `-0x09..=0x00`
|
||||
|
||||
error: this OR pattern can be rewritten using a range
|
||||
--> $DIR/manual_range_patterns.rs:35:17
|
||||
|
|
||||
LL | matches!(f, 0..5 | 5);
|
||||
| ^^^^^^^^ help: try: `0..=5`
|
||||
|
||||
error: this OR pattern can be rewritten using a range
|
||||
--> $DIR/manual_range_patterns.rs:36:17
|
||||
|
|
||||
LL | matches!(f, 0 | 1..5);
|
||||
| ^^^^^^^^ help: try: `0..5`
|
||||
|
||||
error: this OR pattern can be rewritten using a range
|
||||
--> $DIR/manual_range_patterns.rs:38:17
|
||||
|
|
||||
LL | matches!(f, 0..=5 | 6..10);
|
||||
| ^^^^^^^^^^^^^ help: try: `0..10`
|
||||
|
||||
error: this OR pattern can be rewritten using a range
|
||||
--> $DIR/manual_range_patterns.rs:39:17
|
||||
|
|
||||
LL | matches!(f, 0..5 | 5..=10);
|
||||
| ^^^^^^^^^^^^^ help: try: `0..=10`
|
||||
|
||||
error: this OR pattern can be rewritten using a range
|
||||
--> $DIR/manual_range_patterns.rs:40:17
|
||||
|
|
||||
LL | matches!(f, 5..=10 | 0..5);
|
||||
| ^^^^^^^^^^^^^ help: try: `0..=10`
|
||||
|
||||
error: this OR pattern can be rewritten using a range
|
||||
--> $DIR/manual_range_patterns.rs:44:26
|
||||
|
|
||||
LL | matches!($e, 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10)
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `1..=10`
|
||||
|
|
@ -59,5 +119,5 @@ LL | mac!(f);
|
|||
|
|
||||
= note: this error originates in the macro `mac` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
error: aborting due to 9 previous errors
|
||||
error: aborting due to 19 previous errors
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue