-
Notifications
You must be signed in to change notification settings - Fork 12.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Recover parentheses in range patterns
- Loading branch information
Showing
7 changed files
with
181 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 4 additions & 13 deletions
17
tests/ui/half-open-range-patterns/range_pat_interactions2.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,8 @@ | ||
error[E0586]: inclusive range with no end | ||
--> $DIR/range_pat_interactions2.rs:10:14 | ||
error: expected `)`, found `+` | ||
--> $DIR/range_pat_interactions2.rs:10:19 | ||
| | ||
LL | 0..=(5+1) => errors_only.push(x), | ||
| ^^^ help: use `..` instead | ||
| | ||
= note: inclusive ranges must be bounded at the end (`..=b` or `a..=b`) | ||
|
||
error: expected one of `=>`, `if`, or `|`, found `(` | ||
--> $DIR/range_pat_interactions2.rs:10:17 | ||
| | ||
LL | 0..=(5+1) => errors_only.push(x), | ||
| ^ expected one of `=>`, `if`, or `|` | ||
| ^ expected `)` | ||
|
||
error: aborting due to 2 previous errors | ||
error: aborting due to 1 previous error | ||
|
||
For more information about this error, try `rustc --explain E0586`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
fn main() { | ||
match -1 { | ||
0..=1 => (), | ||
0..=(1) => (), | ||
//~^ error: range pattern bounds cannot have parentheses | ||
(-12)..=4 => (), | ||
//~^ error: range pattern bounds cannot have parentheses | ||
(0)..=(-4) => (), | ||
//~^ error: range pattern bounds cannot have parentheses | ||
//~| error: range pattern bounds cannot have parentheses | ||
}; | ||
} | ||
|
||
macro_rules! m { | ||
($pat:pat) => {}; | ||
(($s:literal)..($e:literal)) => {}; | ||
} | ||
|
||
m!((7)..(7)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
error: range pattern bounds cannot have parentheses | ||
--> $DIR/pat-recover-ranges.rs:4:13 | ||
| | ||
LL | 0..=(1) => (), | ||
| ^ ^ | ||
| | ||
help: remove these parentheses | ||
| | ||
LL - 0..=(1) => (), | ||
LL + 0..=1 => (), | ||
| | ||
|
||
error: range pattern bounds cannot have parentheses | ||
--> $DIR/pat-recover-ranges.rs:6:9 | ||
| | ||
LL | (-12)..=4 => (), | ||
| ^ ^ | ||
| | ||
help: remove these parentheses | ||
| | ||
LL - (-12)..=4 => (), | ||
LL + -12..=4 => (), | ||
| | ||
|
||
error: range pattern bounds cannot have parentheses | ||
--> $DIR/pat-recover-ranges.rs:8:9 | ||
| | ||
LL | (0)..=(-4) => (), | ||
| ^ ^ | ||
| | ||
help: remove these parentheses | ||
| | ||
LL - (0)..=(-4) => (), | ||
LL + 0..=(-4) => (), | ||
| | ||
|
||
error: range pattern bounds cannot have parentheses | ||
--> $DIR/pat-recover-ranges.rs:8:15 | ||
| | ||
LL | (0)..=(-4) => (), | ||
| ^ ^ | ||
| | ||
help: remove these parentheses | ||
| | ||
LL - (0)..=(-4) => (), | ||
LL + (0)..=-4 => (), | ||
| | ||
|
||
error: aborting due to 4 previous errors | ||
|