mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-27 20:42:04 +00:00
make macro a NameOwner
This commit is contained in:
parent
e7b370226c
commit
2efdf41bdb
6 changed files with 14 additions and 5 deletions
|
@ -1908,6 +1908,7 @@ impl ToOwned for MacroCall {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
impl ast::NameOwner for MacroCall {}
|
||||||
impl MacroCall {
|
impl MacroCall {
|
||||||
pub fn token_tree(&self) -> Option<&TokenTree> {
|
pub fn token_tree(&self) -> Option<&TokenTree> {
|
||||||
super::child_opt(self)
|
super::child_opt(self)
|
||||||
|
|
|
@ -545,7 +545,10 @@ Grammar(
|
||||||
"Visibility": (),
|
"Visibility": (),
|
||||||
"Name": (),
|
"Name": (),
|
||||||
"NameRef": (),
|
"NameRef": (),
|
||||||
"MacroCall": ( options: [ "TokenTree", "Path" ] ),
|
"MacroCall": (
|
||||||
|
traits: [ "NameOwner" ],
|
||||||
|
options: [ "TokenTree", "Path" ],
|
||||||
|
),
|
||||||
"Attr": ( options: [ ["value", "TokenTree"] ] ),
|
"Attr": ( options: [ ["value", "TokenTree"] ] ),
|
||||||
"TokenTree": (),
|
"TokenTree": (),
|
||||||
"TypeParamList": (
|
"TypeParamList": (
|
||||||
|
|
|
@ -347,7 +347,9 @@ fn macro_call(p: &mut Parser) -> BlockLike {
|
||||||
|
|
||||||
pub(super) fn macro_call_after_excl(p: &mut Parser) -> BlockLike {
|
pub(super) fn macro_call_after_excl(p: &mut Parser) -> BlockLike {
|
||||||
p.expect(EXCL);
|
p.expect(EXCL);
|
||||||
p.eat(IDENT);
|
if p.at(IDENT) {
|
||||||
|
name(p);
|
||||||
|
}
|
||||||
match p.current() {
|
match p.current() {
|
||||||
L_CURLY => {
|
L_CURLY => {
|
||||||
token_tree(p);
|
token_tree(p);
|
||||||
|
|
|
@ -6,6 +6,7 @@ SOURCE_FILE@[0; 349)
|
||||||
IDENT@[0; 5) "macro"
|
IDENT@[0; 5) "macro"
|
||||||
err: `expected EXCL`
|
err: `expected EXCL`
|
||||||
WHITESPACE@[5; 6)
|
WHITESPACE@[5; 6)
|
||||||
|
NAME@[6; 21)
|
||||||
IDENT@[6; 21) "parse_use_trees"
|
IDENT@[6; 21) "parse_use_trees"
|
||||||
TOKEN_TREE@[21; 41)
|
TOKEN_TREE@[21; 41)
|
||||||
L_PAREN@[21; 22)
|
L_PAREN@[21; 22)
|
||||||
|
|
|
@ -19,6 +19,7 @@ SOURCE_FILE@[0; 70)
|
||||||
IDENT@[12; 23) "macro_rules"
|
IDENT@[12; 23) "macro_rules"
|
||||||
EXCL@[23; 24)
|
EXCL@[23; 24)
|
||||||
WHITESPACE@[24; 25)
|
WHITESPACE@[24; 25)
|
||||||
|
NAME@[25; 28)
|
||||||
IDENT@[25; 28) "foo"
|
IDENT@[25; 28) "foo"
|
||||||
WHITESPACE@[28; 29)
|
WHITESPACE@[28; 29)
|
||||||
TOKEN_TREE@[29; 31)
|
TOKEN_TREE@[29; 31)
|
||||||
|
|
|
@ -92,6 +92,7 @@ SOURCE_FILE@[0; 167)
|
||||||
IDENT@[109; 120) "macro_rules"
|
IDENT@[109; 120) "macro_rules"
|
||||||
EXCL@[120; 121)
|
EXCL@[120; 121)
|
||||||
WHITESPACE@[121; 122)
|
WHITESPACE@[121; 122)
|
||||||
|
NAME@[122; 126)
|
||||||
IDENT@[122; 126) "test"
|
IDENT@[122; 126) "test"
|
||||||
WHITESPACE@[126; 127)
|
WHITESPACE@[126; 127)
|
||||||
TOKEN_TREE@[127; 152)
|
TOKEN_TREE@[127; 152)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue