Unnamed repository; edit this file 'description' to name the repository.
9 files changed, 145 insertions, 150 deletions
diff --git a/crates/parser/src/grammar/items.rs b/crates/parser/src/grammar/items.rs index 6405a508ab..0c52d5aadb 100644 --- a/crates/parser/src/grammar/items.rs +++ b/crates/parser/src/grammar/items.rs @@ -249,14 +249,8 @@ fn opt_item_without_modifiers(p: &mut Parser, m: Marker) -> Result<(), Marker> { T![enum] => adt::enum_(p, m), IDENT if p.at_contextual_kw("union") && p.nth(1) == IDENT => adt::union(p, m), - // test pub_macro_def - // pub macro m($:ident) {} - T![macro] => { - macro_def(p, m); - } - IDENT if p.at_contextual_kw("macro_rules") && p.nth(1) == BANG => { - macro_rules(p, m); - } + T![macro] => macro_def(p, m), + IDENT if p.at_contextual_kw("macro_rules") && p.nth(1) == BANG => macro_rules(p, m), T![const] if (la == IDENT || la == T![_] || la == T![mut]) => consts::konst(p, m), T![static] => consts::static_(p, m), @@ -413,12 +407,13 @@ fn macro_rules(p: &mut Parser, m: Marker) { } // test macro_def -// macro m { ($i:ident) => {} } // macro m($i:ident) {} fn macro_def(p: &mut Parser, m: Marker) { p.expect(T![macro]); name_r(p, ITEM_RECOVERY_SET); if p.at(T!['{']) { + // test macro_def_curly + // macro m { ($i:ident) => {} } token_tree(p); } else if !p.at(T!['(']) { p.error("unmatched `(`"); diff --git a/crates/syntax/test_data/parser/inline/ok/0147_macro_def.rast b/crates/syntax/test_data/parser/inline/ok/0147_macro_def.rast index 6655aeab13..4d7b78d5ca 100644 --- a/crates/syntax/test_data/parser/inline/ok/0147_macro_def.rast +++ b/crates/syntax/test_data/parser/inline/ok/0147_macro_def.rast @@ -1,45 +1,19 @@ [email protected] "macro" - [email protected] " " - [email protected] "{" - [email protected] " " - [email protected] "(" - [email protected] "$" - [email protected] "i" - [email protected] ":" - [email protected] "ident" - [email protected] ")" - [email protected] " " - [email protected] "=" - [email protected] ">" - [email protected] " " - [email protected] "{" - [email protected] "}" - [email protected] " " - [email protected] "}" - [email protected] "\n" - [email protected] "macro" - [email protected] " " - [email protected] "m" - [email protected] "(" - [email protected] "$" - [email protected] "i" - [email protected] ":" - [email protected] "ident" - [email protected] ")" - [email protected] " " - [email protected] "{" - [email protected] "}" - [email protected] "\n" + [email protected] "(" + [email protected] "$" + [email protected] "i" + [email protected] ":" + [email protected] "ident" + [email protected] ")" + [email protected] " " + [email protected] "{" + [email protected] "}" + [email protected] "\n" diff --git a/crates/syntax/test_data/parser/inline/ok/0147_macro_def.rs b/crates/syntax/test_data/parser/inline/ok/0147_macro_def.rs index 319a4e2aad..a014ae5464 100644 --- a/crates/syntax/test_data/parser/inline/ok/0147_macro_def.rs +++ b/crates/syntax/test_data/parser/inline/ok/0147_macro_def.rs @@ -1,2 +1 @@ -macro m { ($i:ident) => {} } macro m($i:ident) {} diff --git a/crates/syntax/test_data/parser/inline/ok/0148_pub_macro_def.rast b/crates/syntax/test_data/parser/inline/ok/0148_pub_macro_def.rast deleted file mode 100644 index 1c527f60b9..0000000000 --- a/crates/syntax/test_data/parser/inline/ok/0148_pub_macro_def.rast +++ /dev/null @@ -1,21 +0,0 @@ - [email protected] "pub" - [email protected] " " - [email protected] "macro" - [email protected] " " - [email protected] "m" - [email protected] "(" - [email protected] "$" - [email protected] ":" - [email protected] "ident" - [email protected] ")" - [email protected] " " - [email protected] "{" - [email protected] "}" - [email protected] "\n" diff --git a/crates/syntax/test_data/parser/inline/ok/0148_pub_macro_def.rs b/crates/syntax/test_data/parser/inline/ok/0148_pub_macro_def.rs deleted file mode 100644 index 3b2be597fd..0000000000 --- a/crates/syntax/test_data/parser/inline/ok/0148_pub_macro_def.rs +++ /dev/null @@ -1 +0,0 @@ -pub macro m($:ident) {} diff --git a/crates/syntax/test_data/parser/inline/ok/0173_macro_def_curly.rast b/crates/syntax/test_data/parser/inline/ok/0173_macro_def_curly.rast new file mode 100644 index 0000000000..3ec00bf55a --- /dev/null +++ b/crates/syntax/test_data/parser/inline/ok/0173_macro_def_curly.rast @@ -0,0 +1,27 @@ + [email protected] "macro" + [email protected] " " + [email protected] "m" + [email protected] " " + [email protected] "{" + [email protected] " " + [email protected] "(" + [email protected] "$" + [email protected] "i" + [email protected] ":" + [email protected] "ident" + [email protected] ")" + [email protected] " " + [email protected] "=" + [email protected] ">" + [email protected] " " + [email protected] "{" + [email protected] "}" + [email protected] " " + [email protected] "}" + [email protected] "\n" diff --git a/crates/syntax/test_data/parser/inline/ok/0173_macro_def_curly.rs b/crates/syntax/test_data/parser/inline/ok/0173_macro_def_curly.rs new file mode 100644 index 0000000000..5ed0c777dc --- /dev/null +++ b/crates/syntax/test_data/parser/inline/ok/0173_macro_def_curly.rs @@ -0,0 +1 @@ +macro m { ($i:ident) => {} } diff --git a/crates/syntax/test_data/parser/ok/0012_visibility.rast b/crates/syntax/test_data/parser/ok/0012_visibility.rast index c5dbfb702a..79dc9001a2 100644 --- a/crates/syntax/test_data/parser/ok/0012_visibility.rast +++ b/crates/syntax/test_data/parser/ok/0012_visibility.rast @@ -1,4 +1,4 @@ [email protected] "fn" @@ -28,81 +28,101 @@ [email protected] [email protected] "\n" [email protected] "pub" - [email protected] "(" - [email protected] "crate" - [email protected] ")" - [email protected] " " - [email protected] "fn" - [email protected] " " - [email protected] "c" - [email protected] "(" - [email protected] ")" - [email protected] " " - [email protected] "{" - [email protected] "}" - [email protected] "\n" - [email protected] "pub" - [email protected] "(" - [email protected] "super" - [email protected] ")" - [email protected] " " - [email protected] "fn" + [email protected] " " + [email protected] "macro" + [email protected] " " + [email protected] "m" + [email protected] "(" + [email protected] "$" + [email protected] ":" + [email protected] "ident" + [email protected] ")" + [email protected] " " + [email protected] "{" + [email protected] "}" + [email protected] "\n" + [email protected] "pub" + [email protected] "(" + [email protected] "crate" + [email protected] ")" - [email protected] "d" - [email protected] "(" - [email protected] ")" - [email protected] " " - [email protected] "{" - [email protected] "}" - [email protected] "\n" - [email protected] "pub" - [email protected] "(" - [email protected] "in" - [email protected] " " - [email protected] "foo" - [email protected] "::" - [email protected] "bar" - [email protected] "::" - [email protected] "baz" - [email protected] ")" - [email protected] " " - [email protected] "fn" - [email protected] " " - [email protected] "e" - [email protected] "(" - [email protected] ")" - [email protected] " " - [email protected] "{" - [email protected] "}" - [email protected] "\n" + [email protected] "fn" + [email protected] " " + [email protected] "c" + [email protected] "(" + [email protected] ")" + [email protected] " " + [email protected] "{" + [email protected] "}" + [email protected] "\n" + [email protected] "pub" + [email protected] "(" + [email protected] "super" + [email protected] ")" + [email protected] " " + [email protected] "fn" + [email protected] " " + [email protected] "d" + [email protected] "(" + [email protected] ")" + [email protected] " " + [email protected] "{" + [email protected] "}" + [email protected] "\n" + [email protected] "pub" + [email protected] "(" + [email protected] "in" + [email protected] " " + [email protected] "foo" + [email protected] "::" + [email protected] "bar" + [email protected] "::" + [email protected] "baz" + [email protected] ")" + [email protected] " " + [email protected] "fn" + [email protected] " " + [email protected] "e" + [email protected] "(" + [email protected] ")" + [email protected] " " + [email protected] "{" + [email protected] "}" + [email protected] "\n" diff --git a/crates/syntax/test_data/parser/ok/0012_visibility.rs b/crates/syntax/test_data/parser/ok/0012_visibility.rs index 75b1db1213..129d486fae 100644 --- a/crates/syntax/test_data/parser/ok/0012_visibility.rs +++ b/crates/syntax/test_data/parser/ok/0012_visibility.rs @@ -1,5 +1,6 @@ fn a() {} pub fn b() {} +pub macro m($:ident) {} pub(crate) fn c() {} pub(super) fn d() {} pub(in foo::bar::baz) fn e() {} |