-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #16314 - Urhengulas:macro_rule-as-macro-name, r=Veykril
`macro_rules` as macro name This PR makes RA parse `macro_rules! {}` (note the missing identifier) as a `MACRO_CALL` instead of `MACRO_RULES`. Fixes #15969.
- Loading branch information
Showing
5 changed files
with
144 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
crates/parser/test_data/parser/inline/err/0026_macro_rules_as_macro_name.rast
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
SOURCE_FILE | ||
MACRO_CALL | ||
PATH | ||
PATH_SEGMENT | ||
NAME_REF | ||
IDENT "macro_rules" | ||
BANG "!" | ||
WHITESPACE " " | ||
TOKEN_TREE | ||
L_CURLY "{" | ||
R_CURLY "}" | ||
ERROR | ||
SEMICOLON ";" | ||
WHITESPACE "\n" | ||
MACRO_CALL | ||
PATH | ||
PATH_SEGMENT | ||
NAME_REF | ||
IDENT "macro_rules" | ||
BANG "!" | ||
WHITESPACE " " | ||
TOKEN_TREE | ||
L_PAREN "(" | ||
R_PAREN ")" | ||
WHITESPACE "\n" | ||
MACRO_CALL | ||
PATH | ||
PATH_SEGMENT | ||
NAME_REF | ||
IDENT "macro_rules" | ||
BANG "!" | ||
WHITESPACE " " | ||
TOKEN_TREE | ||
L_BRACK "[" | ||
R_BRACK "]" | ||
WHITESPACE "\n" | ||
error 15: expected an item | ||
error 32: expected SEMICOLON | ||
error 48: expected SEMICOLON |
3 changes: 3 additions & 0 deletions
3
crates/parser/test_data/parser/inline/err/0026_macro_rules_as_macro_name.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
macro_rules! {}; | ||
macro_rules! () | ||
macro_rules! [] |
72 changes: 72 additions & 0 deletions
72
crates/parser/test_data/parser/inline/ok/0208_macro_rules_as_macro_name.rast
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
SOURCE_FILE | ||
MACRO_CALL | ||
PATH | ||
PATH_SEGMENT | ||
NAME_REF | ||
IDENT "macro_rules" | ||
BANG "!" | ||
WHITESPACE " " | ||
TOKEN_TREE | ||
L_CURLY "{" | ||
R_CURLY "}" | ||
WHITESPACE "\n" | ||
MACRO_CALL | ||
PATH | ||
PATH_SEGMENT | ||
NAME_REF | ||
IDENT "macro_rules" | ||
BANG "!" | ||
WHITESPACE " " | ||
TOKEN_TREE | ||
L_PAREN "(" | ||
R_PAREN ")" | ||
SEMICOLON ";" | ||
WHITESPACE "\n" | ||
MACRO_CALL | ||
PATH | ||
PATH_SEGMENT | ||
NAME_REF | ||
IDENT "macro_rules" | ||
BANG "!" | ||
WHITESPACE " " | ||
TOKEN_TREE | ||
L_BRACK "[" | ||
R_BRACK "]" | ||
SEMICOLON ";" | ||
WHITESPACE "\n" | ||
FN | ||
FN_KW "fn" | ||
WHITESPACE " " | ||
NAME | ||
IDENT "main" | ||
PARAM_LIST | ||
L_PAREN "(" | ||
R_PAREN ")" | ||
WHITESPACE " " | ||
BLOCK_EXPR | ||
STMT_LIST | ||
L_CURLY "{" | ||
WHITESPACE "\n " | ||
LET_STMT | ||
LET_KW "let" | ||
WHITESPACE " " | ||
IDENT_PAT | ||
NAME | ||
IDENT "foo" | ||
WHITESPACE " " | ||
EQ "=" | ||
WHITESPACE " " | ||
MACRO_EXPR | ||
MACRO_CALL | ||
PATH | ||
PATH_SEGMENT | ||
NAME_REF | ||
IDENT "macro_rules" | ||
BANG "!" | ||
TOKEN_TREE | ||
L_PAREN "(" | ||
R_PAREN ")" | ||
SEMICOLON ";" | ||
WHITESPACE "\n" | ||
R_CURLY "}" | ||
WHITESPACE "\n" |
6 changes: 6 additions & 0 deletions
6
crates/parser/test_data/parser/inline/ok/0208_macro_rules_as_macro_name.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
macro_rules! {} | ||
macro_rules! (); | ||
macro_rules! []; | ||
fn main() { | ||
let foo = macro_rules!(); | ||
} |