-
Notifications
You must be signed in to change notification settings - Fork 13k
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 #112345 - bvanjoi:fix-112342, r=nilstrieb,est31
fix(expand): prevent infinity loop in macro containing only "///" Fixes #112342 Issue #112342 was caused by an infinity loop in `parse_tt_inner`, and the state of it is as follows: - `matcher`: `[Sequence, Token(Doc), SequenceKleeneOpNoSep(op: ZeroOrMore), Eof]` - loop: | Iteration | Action | | - | - | | 0 | enter `Sequence`| | 1 | enter `Token(Doc)` and `mp.idx += 1` had been executed | | 2 | enter `SequenceKleeneOpNoSep` and reset `mp.idx` to `1` | | 3 | enter `Token(Doc)` again| To prevent the infinite loop, a check for whether it only contains `DocComment` in `check_lhs_no_empty_seq` had been added.
- Loading branch information
Showing
6 changed files
with
212 additions
and
10 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 |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// same as #95267, ignore doc comment although it's a bug. | ||
|
||
macro_rules! m1 { | ||
( | ||
$( | ||
/// | ||
)* | ||
//~^^^ERROR repetition matches empty token tree | ||
) => {}; | ||
} | ||
|
||
m1! {} | ||
|
||
macro_rules! m2 { | ||
( | ||
$( | ||
/// | ||
)+ | ||
//~^^^ERROR repetition matches empty token tree | ||
) => {}; | ||
} | ||
|
||
m2! {} | ||
|
||
macro_rules! m3 { | ||
( | ||
$( | ||
/// | ||
)? | ||
//~^^^ERROR repetition matches empty token tree | ||
) => {}; | ||
} | ||
|
||
m3! {} | ||
|
||
|
||
macro_rules! m4 { | ||
( | ||
$( | ||
/// | ||
/// | ||
)* | ||
//~^^^^ERROR repetition matches empty token tree | ||
) => {}; | ||
} | ||
|
||
m4! {} | ||
|
||
fn main() {} |
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,64 @@ | ||
note: doc comments are ignored in matcher position | ||
--> $DIR/issue-112342-1.rs:6:13 | ||
| | ||
LL | /// | ||
| ^^^ | ||
|
||
error: repetition matches empty token tree | ||
--> $DIR/issue-112342-1.rs:5:10 | ||
| | ||
LL | $( | ||
| __________^ | ||
LL | | /// | ||
LL | | )* | ||
| |_________^ | ||
|
||
note: doc comments are ignored in matcher position | ||
--> $DIR/issue-112342-1.rs:17:13 | ||
| | ||
LL | /// | ||
| ^^^ | ||
|
||
error: repetition matches empty token tree | ||
--> $DIR/issue-112342-1.rs:16:10 | ||
| | ||
LL | $( | ||
| __________^ | ||
LL | | /// | ||
LL | | )+ | ||
| |_________^ | ||
|
||
note: doc comments are ignored in matcher position | ||
--> $DIR/issue-112342-1.rs:28:13 | ||
| | ||
LL | /// | ||
| ^^^ | ||
|
||
error: repetition matches empty token tree | ||
--> $DIR/issue-112342-1.rs:27:10 | ||
| | ||
LL | $( | ||
| __________^ | ||
LL | | /// | ||
LL | | )? | ||
| |_________^ | ||
|
||
note: doc comments are ignored in matcher position | ||
--> $DIR/issue-112342-1.rs:40:13 | ||
| | ||
LL | / /// | ||
LL | | /// | ||
| |_______________^ | ||
|
||
error: repetition matches empty token tree | ||
--> $DIR/issue-112342-1.rs:39:10 | ||
| | ||
LL | $( | ||
| __________^ | ||
LL | | /// | ||
LL | | /// | ||
LL | | )* | ||
| |_________^ | ||
|
||
error: aborting due to 4 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,39 @@ | ||
// check-pass | ||
|
||
// same as #95267, ignore doc comment although it's a bug. | ||
|
||
macro_rules! m1 { | ||
( | ||
$( | ||
/// | ||
$expr: expr, | ||
)* | ||
) => {}; | ||
} | ||
|
||
m1! {} | ||
|
||
macro_rules! m2 { | ||
( | ||
$( | ||
/// | ||
$expr: expr, | ||
/// | ||
)* | ||
) => {}; | ||
} | ||
|
||
m2! {} | ||
|
||
macro_rules! m3 { | ||
( | ||
$( | ||
/// | ||
$tt: tt, | ||
)* | ||
) => {}; | ||
} | ||
|
||
m3! {} | ||
|
||
fn main() {} |
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,24 @@ | ||
note: doc comments are ignored in matcher position | ||
--> $DIR/issue-112342-2.rs:8:13 | ||
| | ||
LL | /// | ||
| ^^^ | ||
|
||
note: doc comments are ignored in matcher position | ||
--> $DIR/issue-112342-2.rs:19:13 | ||
| | ||
LL | /// | ||
| ^^^ | ||
|
||
note: doc comments are ignored in matcher position | ||
--> $DIR/issue-112342-2.rs:21:13 | ||
| | ||
LL | /// | ||
| ^^^ | ||
|
||
note: doc comments are ignored in matcher position | ||
--> $DIR/issue-112342-2.rs:31:13 | ||
| | ||
LL | /// | ||
| ^^^ | ||
|