]> git.lizzy.rs Git - rust.git/commitdiff
make macro a NameOwner
authorAleksey Kladov <aleksey.kladov@gmail.com>
Mon, 11 Feb 2019 16:23:13 +0000 (19:23 +0300)
committerAleksey Kladov <aleksey.kladov@gmail.com>
Mon, 11 Feb 2019 16:24:13 +0000 (19:24 +0300)
crates/ra_syntax/src/ast/generated.rs
crates/ra_syntax/src/grammar.ron
crates/ra_syntax/src/grammar/items.rs
crates/ra_syntax/tests/data/parser/err/0028_macro_2.0.txt
crates/ra_syntax/tests/data/parser/inline/ok/0062_mod_contents.txt
crates/ra_syntax/tests/data/parser/inline/ok/0096_no_semi_after_block.txt

index 256277609f65cb067bdf8631412db2c99821ffbb..d2b080743b7da457cce1d0a439657646b883699b 100644 (file)
@@ -1908,6 +1908,7 @@ fn to_owned(&self) -> TreeArc<MacroCall> { TreeArc::cast(self.syntax.to_owned())
 }
 
 
+impl ast::NameOwner for MacroCall {}
 impl MacroCall {
     pub fn token_tree(&self) -> Option<&TokenTree> {
         super::child_opt(self)
index d428bc5955d9e969b8b4c8876f42c40f87f7cbec..2e4b2d776c2a4d0abafe153cecab85722aebc080 100644 (file)
@@ -545,7 +545,10 @@ Grammar(
         "Visibility": (),
         "Name": (),
         "NameRef": (),
-        "MacroCall": ( options: [ "TokenTree", "Path" ] ),
+        "MacroCall": (
+            traits: [ "NameOwner" ],
+            options: [ "TokenTree", "Path" ],
+        ),
         "Attr": ( options: [ ["value", "TokenTree"] ] ),
         "TokenTree": (),
         "TypeParamList": (
index a61f260cf19e8ba02a1d18ed3f99532aaea5e8ff..4b962c1f37f989d42942ed7d7b5ed896bd5a79ef 100644 (file)
@@ -347,7 +347,9 @@ fn macro_call(p: &mut Parser) -> BlockLike {
 
 pub(super) fn macro_call_after_excl(p: &mut Parser) -> BlockLike {
     p.expect(EXCL);
-    p.eat(IDENT);
+    if p.at(IDENT) {
+        name(p);
+    }
     match p.current() {
         L_CURLY => {
             token_tree(p);
index 12919fab7a8fbe7dc30f5d39a1298ca6e12ea1c6..440bd7f92ada92367e76c418fb7531b16d66289b 100644 (file)
@@ -6,7 +6,8 @@ SOURCE_FILE@[0; 349)
           IDENT@[0; 5) "macro"
           err: `expected EXCL`
     WHITESPACE@[5; 6)
-    IDENT@[6; 21) "parse_use_trees"
+    NAME@[6; 21)
+      IDENT@[6; 21) "parse_use_trees"
     TOKEN_TREE@[21; 41)
       L_PAREN@[21; 22)
       DOLLAR@[22; 23)
index 62528ca47c90b67bc7d47cae3e34f4308d73b059..6ccd0ffc30526c1270eb5a21a0aef28f168520dd 100644 (file)
@@ -19,7 +19,8 @@ SOURCE_FILE@[0; 70)
           IDENT@[12; 23) "macro_rules"
     EXCL@[23; 24)
     WHITESPACE@[24; 25)
-    IDENT@[25; 28) "foo"
+    NAME@[25; 28)
+      IDENT@[25; 28) "foo"
     WHITESPACE@[28; 29)
     TOKEN_TREE@[29; 31)
       L_CURLY@[29; 30)
index 63b2300916b74d64252410851ce857e98a99a6fd..ac789651a5e19695b43da116812ad0fd979707c4 100644 (file)
@@ -92,7 +92,8 @@ SOURCE_FILE@[0; 167)
                 IDENT@[109; 120) "macro_rules"
           EXCL@[120; 121)
           WHITESPACE@[121; 122)
-          IDENT@[122; 126) "test"
+          NAME@[122; 126)
+            IDENT@[122; 126) "test"
           WHITESPACE@[126; 127)
           TOKEN_TREE@[127; 152)
             L_CURLY@[127; 128)