Skip to content

Commit 1487f2f

Browse files
bors[bot]Veykril
andauthored
Merge #7027
7027: Fix macro_rules not accepting brackets or parentheses r=matklad,lnicola a=Veykril Co-authored-by: Lukas Wirth <[email protected]>
2 parents 2c843c4 + 3e0bb89 commit 1487f2f

File tree

3 files changed

+66
-2
lines changed

3 files changed

+66
-2
lines changed

crates/parser/src/grammar/items.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -389,10 +389,15 @@ fn macro_rules(p: &mut Parser, m: Marker) {
389389
}
390390

391391
match p.current() {
392-
T!['{'] => {
392+
// test macro_rules_non_brace
393+
// macro_rules! m ( ($i:ident) => {} );
394+
// macro_rules! m [ ($i:ident) => {} ];
395+
T!['['] | T!['('] => {
393396
token_tree(p);
397+
p.expect(T![;]);
394398
}
395-
_ => p.error("expected `{`"),
399+
T!['{'] => token_tree(p),
400+
_ => p.error("expected `{`, `[`, `(`"),
396401
}
397402
m.complete(p, MACRO_RULES);
398403
}
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
2+
3+
[email protected] "macro_rules"
4+
5+
6+
7+
8+
9+
10+
11+
12+
13+
14+
15+
16+
17+
18+
19+
20+
21+
22+
23+
24+
25+
26+
27+
28+
29+
30+
31+
[email protected] "macro_rules"
32+
33+
34+
35+
36+
37+
38+
39+
40+
41+
42+
43+
44+
45+
46+
47+
48+
49+
50+
51+
52+
53+
54+
55+
56+
57+
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
macro_rules! m ( ($i:ident) => {} );
2+
macro_rules! m [ ($i:ident) => {} ];

0 commit comments

Comments
 (0)