Skip to content

Commit

Permalink
Auto merge of rust-lang#16397 - Urhengulas:refactor-parser, r=Veykril
Browse files Browse the repository at this point in the history
Refactor `macro_call` to be consistent with other functions

rust-lang/rust-analyzer#16314 (comment)
  • Loading branch information
bors committed Jan 18, 2024
2 parents 6d31416 + b599de1 commit 48af3ef
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions crates/parser/src/grammar/items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 48af3ef

Please sign in to comment.