forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#57610 - mark-i-m:nested-matchers, r=petroch…
…enkov Fix nested `?` matchers fix rust-lang#57597 I'm not 100% if this works yet... cc @alercah When this is ready (but perhaps not yet):
- Loading branch information
Showing
5 changed files
with
253 additions
and
24 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,62 +1,110 @@ | ||
error: repetition matches empty token tree | ||
--> $DIR/issue-5067.rs:4:8 | ||
--> $DIR/issue-5067.rs:9:8 | ||
| | ||
LL | ( $()* ) => {}; | ||
| ^^ | ||
|
||
error: repetition matches empty token tree | ||
--> $DIR/issue-5067.rs:6:8 | ||
--> $DIR/issue-5067.rs:11:8 | ||
| | ||
LL | ( $()+ ) => {}; | ||
| ^^ | ||
|
||
error: repetition matches empty token tree | ||
--> $DIR/issue-5067.rs:12:9 | ||
--> $DIR/issue-5067.rs:13:8 | ||
| | ||
LL | ( $()? ) => {}; | ||
| ^^ | ||
|
||
error: repetition matches empty token tree | ||
--> $DIR/issue-5067.rs:18:9 | ||
| | ||
LL | ( [$()*] ) => {}; | ||
| ^^ | ||
|
||
error: repetition matches empty token tree | ||
--> $DIR/issue-5067.rs:14:9 | ||
--> $DIR/issue-5067.rs:20:9 | ||
| | ||
LL | ( [$()+] ) => {}; | ||
| ^^ | ||
|
||
error: repetition matches empty token tree | ||
--> $DIR/issue-5067.rs:20:8 | ||
--> $DIR/issue-5067.rs:22:9 | ||
| | ||
LL | ( [$()?] ) => {}; | ||
| ^^ | ||
|
||
error: repetition matches empty token tree | ||
--> $DIR/issue-5067.rs:27:8 | ||
| | ||
LL | ( $($()* $(),* $(a)* $(a),* )* ) => {}; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: repetition matches empty token tree | ||
--> $DIR/issue-5067.rs:22:8 | ||
--> $DIR/issue-5067.rs:29:8 | ||
| | ||
LL | ( $($()* $(),* $(a)* $(a),* )+ ) => {}; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: repetition matches empty token tree | ||
--> $DIR/issue-5067.rs:28:12 | ||
--> $DIR/issue-5067.rs:31:8 | ||
| | ||
LL | ( $($()* $(),* $(a)* $(a),* )? ) => {}; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: repetition matches empty token tree | ||
--> $DIR/issue-5067.rs:33:8 | ||
| | ||
LL | ( $($()? $(),* $(a)? $(a),* )* ) => {}; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: repetition matches empty token tree | ||
--> $DIR/issue-5067.rs:35:8 | ||
| | ||
LL | ( $($()? $(),* $(a)? $(a),* )+ ) => {}; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: repetition matches empty token tree | ||
--> $DIR/issue-5067.rs:37:8 | ||
| | ||
LL | ( $($()? $(),* $(a)? $(a),* )? ) => {}; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: repetition matches empty token tree | ||
--> $DIR/issue-5067.rs:47:12 | ||
| | ||
LL | ( $(a $()+)* ) => {}; | ||
| ^^ | ||
|
||
error: repetition matches empty token tree | ||
--> $DIR/issue-5067.rs:30:12 | ||
--> $DIR/issue-5067.rs:49:12 | ||
| | ||
LL | ( $(a $()*)+ ) => {}; | ||
| ^^ | ||
|
||
error: repetition matches empty token tree | ||
--> $DIR/issue-5067.rs:38:18 | ||
--> $DIR/issue-5067.rs:51:12 | ||
| | ||
LL | ( $(a $()+)? ) => {}; | ||
| ^^ | ||
|
||
error: repetition matches empty token tree | ||
--> $DIR/issue-5067.rs:53:12 | ||
| | ||
LL | ( $(a $()?)+ ) => {}; | ||
| ^^ | ||
|
||
error: repetition matches empty token tree | ||
--> $DIR/issue-5067.rs:60:18 | ||
| | ||
LL | (a $e1:expr $($(, a $e2:expr)*)*) => ([$e1 $($(, $e2)*)*]); | ||
| ^^^^^^^^^^^^^^^^^^ | ||
|
||
error: repetition matches empty token tree | ||
--> $DIR/issue-5067.rs:50:8 | ||
--> $DIR/issue-5067.rs:71:8 | ||
| | ||
LL | ( $()* ) => {} | ||
LL | ( $()* ) => {}; | ||
| ^^ | ||
|
||
error: aborting due to 10 previous errors | ||
error: aborting due to 18 previous errors | ||
|
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,80 @@ | ||
// Regression test for #57597. | ||
// | ||
// Make sure that nested matchers work correctly rather than causing an infinite loop or crash. | ||
|
||
// edition:2018 | ||
|
||
macro_rules! foo1 { | ||
($($($i:ident)?)+) => {}; | ||
//~^ ERROR repetition matches empty token tree | ||
} | ||
|
||
macro_rules! foo2 { | ||
($($($i:ident)?)*) => {}; | ||
//~^ ERROR repetition matches empty token tree | ||
} | ||
|
||
macro_rules! foo3 { | ||
($($($i:ident)?)?) => {}; | ||
//~^ ERROR repetition matches empty token tree | ||
} | ||
|
||
macro_rules! foo4 { | ||
($($($($i:ident)?)?)?) => {}; | ||
//~^ ERROR repetition matches empty token tree | ||
} | ||
|
||
macro_rules! foo5 { | ||
($($($($i:ident)*)?)?) => {}; | ||
//~^ ERROR repetition matches empty token tree | ||
} | ||
|
||
macro_rules! foo6 { | ||
($($($($i:ident)?)*)?) => {}; | ||
//~^ ERROR repetition matches empty token tree | ||
} | ||
|
||
macro_rules! foo7 { | ||
($($($($i:ident)?)?)*) => {}; | ||
//~^ ERROR repetition matches empty token tree | ||
} | ||
|
||
macro_rules! foo8 { | ||
($($($($i:ident)*)*)?) => {}; | ||
//~^ ERROR repetition matches empty token tree | ||
} | ||
|
||
macro_rules! foo9 { | ||
($($($($i:ident)?)*)*) => {}; | ||
//~^ ERROR repetition matches empty token tree | ||
} | ||
|
||
macro_rules! foo10 { | ||
($($($($i:ident)?)*)+) => {}; | ||
//~^ ERROR repetition matches empty token tree | ||
} | ||
|
||
macro_rules! foo11 { | ||
($($($($i:ident)+)?)*) => {}; | ||
//~^ ERROR repetition matches empty token tree | ||
} | ||
|
||
macro_rules! foo12 { | ||
($($($($i:ident)+)*)?) => {}; | ||
//~^ ERROR repetition matches empty token tree | ||
} | ||
|
||
fn main() { | ||
foo1!(); | ||
foo2!(); | ||
foo3!(); | ||
foo4!(); | ||
foo5!(); | ||
foo6!(); | ||
foo7!(); | ||
foo8!(); | ||
foo9!(); | ||
foo10!(); | ||
foo11!(); | ||
foo12!(); | ||
} |
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,74 @@ | ||
error: repetition matches empty token tree | ||
--> $DIR/issue-57597.rs:8:7 | ||
| | ||
LL | ($($($i:ident)?)+) => {}; | ||
| ^^^^^^^^^^^^^^ | ||
|
||
error: repetition matches empty token tree | ||
--> $DIR/issue-57597.rs:13:7 | ||
| | ||
LL | ($($($i:ident)?)*) => {}; | ||
| ^^^^^^^^^^^^^^ | ||
|
||
error: repetition matches empty token tree | ||
--> $DIR/issue-57597.rs:18:7 | ||
| | ||
LL | ($($($i:ident)?)?) => {}; | ||
| ^^^^^^^^^^^^^^ | ||
|
||
error: repetition matches empty token tree | ||
--> $DIR/issue-57597.rs:23:7 | ||
| | ||
LL | ($($($($i:ident)?)?)?) => {}; | ||
| ^^^^^^^^^^^^^^^^^^ | ||
|
||
error: repetition matches empty token tree | ||
--> $DIR/issue-57597.rs:28:7 | ||
| | ||
LL | ($($($($i:ident)*)?)?) => {}; | ||
| ^^^^^^^^^^^^^^^^^^ | ||
|
||
error: repetition matches empty token tree | ||
--> $DIR/issue-57597.rs:33:7 | ||
| | ||
LL | ($($($($i:ident)?)*)?) => {}; | ||
| ^^^^^^^^^^^^^^^^^^ | ||
|
||
error: repetition matches empty token tree | ||
--> $DIR/issue-57597.rs:38:7 | ||
| | ||
LL | ($($($($i:ident)?)?)*) => {}; | ||
| ^^^^^^^^^^^^^^^^^^ | ||
|
||
error: repetition matches empty token tree | ||
--> $DIR/issue-57597.rs:43:7 | ||
| | ||
LL | ($($($($i:ident)*)*)?) => {}; | ||
| ^^^^^^^^^^^^^^^^^^ | ||
|
||
error: repetition matches empty token tree | ||
--> $DIR/issue-57597.rs:48:7 | ||
| | ||
LL | ($($($($i:ident)?)*)*) => {}; | ||
| ^^^^^^^^^^^^^^^^^^ | ||
|
||
error: repetition matches empty token tree | ||
--> $DIR/issue-57597.rs:53:7 | ||
| | ||
LL | ($($($($i:ident)?)*)+) => {}; | ||
| ^^^^^^^^^^^^^^^^^^ | ||
|
||
error: repetition matches empty token tree | ||
--> $DIR/issue-57597.rs:58:7 | ||
| | ||
LL | ($($($($i:ident)+)?)*) => {}; | ||
| ^^^^^^^^^^^^^^^^^^ | ||
|
||
error: repetition matches empty token tree | ||
--> $DIR/issue-57597.rs:63:7 | ||
| | ||
LL | ($($($($i:ident)+)*)?) => {}; | ||
| ^^^^^^^^^^^^^^^^^^ | ||
|
||
error: aborting due to 12 previous errors | ||
|