Skip to content

Commit 861652f

Browse files
Merge #4225
4225: Special-case try macro_rules r=matklad a=edwin0cheng Similar to #4221, but for `macro_rules! try {}` Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2 parents 972afff + 45c4f62 commit 861652f

File tree

3 files changed

+39
-0
lines changed

3 files changed

+39
-0
lines changed

crates/ra_parser/src/grammar/items.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,17 @@ pub(super) fn macro_call_after_excl(p: &mut Parser) -> BlockLike {
415415
if p.at(IDENT) {
416416
name(p);
417417
}
418+
// Special-case `macro_rules! try`.
419+
// This is a hack until we do proper edition support
420+
421+
// test try_macro_rules
422+
// macro_rules! try { () => {} }
423+
if p.at(T![try]) {
424+
let m = p.start();
425+
p.bump_remap(IDENT);
426+
m.complete(p, NAME);
427+
}
428+
418429
match p.current() {
419430
T!['{'] => {
420431
token_tree(p);
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
SOURCE_FILE@0..30
2+
MACRO_CALL@0..29
3+
PATH@0..11
4+
PATH_SEGMENT@0..11
5+
NAME_REF@0..11
6+
IDENT@0..11 "macro_rules"
7+
BANG@11..12 "!"
8+
WHITESPACE@12..13 " "
9+
NAME@13..16
10+
IDENT@13..16 "try"
11+
WHITESPACE@16..17 " "
12+
TOKEN_TREE@17..29
13+
L_CURLY@17..18 "{"
14+
WHITESPACE@18..19 " "
15+
TOKEN_TREE@19..21
16+
L_PAREN@19..20 "("
17+
R_PAREN@20..21 ")"
18+
WHITESPACE@21..22 " "
19+
EQ@22..23 "="
20+
R_ANGLE@23..24 ">"
21+
WHITESPACE@24..25 " "
22+
TOKEN_TREE@25..27
23+
L_CURLY@25..26 "{"
24+
R_CURLY@26..27 "}"
25+
WHITESPACE@27..28 " "
26+
R_CURLY@28..29 "}"
27+
WHITESPACE@29..30 "\n"
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
macro_rules! try { () => {} }

0 commit comments

Comments
 (0)