diff options
| author | Johann Hemmann <johann.hemmann@code.berlin> | 2024-01-18 12:50:36 +0100 |
|---|---|---|
| committer | Johann Hemmann <johann.hemmann@code.berlin> | 2024-01-18 12:50:36 +0100 |
| commit | b599de193fdada7f5d37caa52dc7a00834f2687e (patch) | |
| tree | 4df5b5cd0f700316f5c793fd58c864c64e32ce74 | |
| parent | 1ab8c7fd270649e90de9d46e8068ec78738d6676 (diff) | |
Refactor `macro_call` to be consistent with other functions
| -rw-r--r-- | crates/parser/src/grammar/items.rs | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/crates/parser/src/grammar/items.rs b/crates/parser/src/grammar/items.rs index 79347617055..caf2a005a7d 100644 --- a/crates/parser/src/grammar/items.rs +++ b/crates/parser/src/grammar/items.rs @@ -70,16 +70,9 @@ pub(super) fn item_or_macro(p: &mut Parser<'_>, stop_on_r_curly: bool) { // macro_rules! {}; // macro_rules! () // macro_rules! [] - if paths::is_use_path_start(p) - || (p.at_contextual_kw(T![macro_rules]) && p.nth_at(1, BANG) && !p.nth_at(2, IDENT)) - { - match macro_call(p) { - BlockLike::Block => (), - BlockLike::NotBlock => { - p.expect(T![;]); - } - } - m.complete(p, MACRO_CALL); + let no_ident = p.at_contextual_kw(T![macro_rules]) && p.nth_at(1, BANG) && !p.nth_at(2, IDENT); + if paths::is_use_path_start(p) || no_ident { + macro_call(p, m); return; } @@ -436,10 +429,16 @@ fn fn_(p: &mut Parser<'_>, m: Marker) { m.complete(p, FN); } -fn macro_call(p: &mut Parser<'_>) -> BlockLike { +fn macro_call(p: &mut Parser<'_>, m: Marker) { assert!(paths::is_use_path_start(p)); paths::use_path(p); - macro_call_after_excl(p) + match macro_call_after_excl(p) { + BlockLike::Block => (), + BlockLike::NotBlock => { + p.expect(T![;]); + } + } + m.complete(p, MACRO_CALL); } pub(super) fn macro_call_after_excl(p: &mut Parser<'_>) -> BlockLike { |
