Skip to content

Commit 2efdf41

Browse files
committed
make macro a NameOwner
1 parent e7b3702 commit 2efdf41

File tree

6 files changed

+14
-5
lines changed

6 files changed

+14
-5
lines changed

crates/ra_syntax/src/ast/generated.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1908,6 +1908,7 @@ impl ToOwned for MacroCall {
19081908
}
19091909

19101910

1911+
impl ast::NameOwner for MacroCall {}
19111912
impl MacroCall {
19121913
pub fn token_tree(&self) -> Option<&TokenTree> {
19131914
super::child_opt(self)

crates/ra_syntax/src/grammar.ron

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -545,7 +545,10 @@ Grammar(
545545
"Visibility": (),
546546
"Name": (),
547547
"NameRef": (),
548-
"MacroCall": ( options: [ "TokenTree", "Path" ] ),
548+
"MacroCall": (
549+
traits: [ "NameOwner" ],
550+
options: [ "TokenTree", "Path" ],
551+
),
549552
"Attr": ( options: [ ["value", "TokenTree"] ] ),
550553
"TokenTree": (),
551554
"TypeParamList": (

crates/ra_syntax/src/grammar/items.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,9 @@ fn macro_call(p: &mut Parser) -> BlockLike {
347347

348348
pub(super) fn macro_call_after_excl(p: &mut Parser) -> BlockLike {
349349
p.expect(EXCL);
350-
p.eat(IDENT);
350+
if p.at(IDENT) {
351+
name(p);
352+
}
351353
match p.current() {
352354
L_CURLY => {
353355
token_tree(p);

crates/ra_syntax/tests/data/parser/err/0028_macro_2.0.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ SOURCE_FILE@[0; 349)
66
IDENT@[0; 5) "macro"
77
err: `expected EXCL`
88
WHITESPACE@[5; 6)
9-
IDENT@[6; 21) "parse_use_trees"
9+
NAME@[6; 21)
10+
IDENT@[6; 21) "parse_use_trees"
1011
TOKEN_TREE@[21; 41)
1112
L_PAREN@[21; 22)
1213
DOLLAR@[22; 23)

crates/ra_syntax/tests/data/parser/inline/ok/0062_mod_contents.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ SOURCE_FILE@[0; 70)
1919
IDENT@[12; 23) "macro_rules"
2020
EXCL@[23; 24)
2121
WHITESPACE@[24; 25)
22-
IDENT@[25; 28) "foo"
22+
NAME@[25; 28)
23+
IDENT@[25; 28) "foo"
2324
WHITESPACE@[28; 29)
2425
TOKEN_TREE@[29; 31)
2526
L_CURLY@[29; 30)

crates/ra_syntax/tests/data/parser/inline/ok/0096_no_semi_after_block.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,8 @@ SOURCE_FILE@[0; 167)
9292
IDENT@[109; 120) "macro_rules"
9393
EXCL@[120; 121)
9494
WHITESPACE@[121; 122)
95-
IDENT@[122; 126) "test"
95+
NAME@[122; 126)
96+
IDENT@[122; 126) "test"
9697
WHITESPACE@[126; 127)
9798
TOKEN_TREE@[127; 152)
9899
L_CURLY@[127; 128)

0 commit comments

Comments
 (0)