Auto merge of #16397 - Urhengulas:refactor-parser, r=Veykril

Refactor `macro_call` to be consistent with other functions

https://github.com/rust-lang/rust-analyzer/pull/16314#discussion_r1457324734
This commit is contained in:
bors 2024-01-18 14:11:58 +00:00
commit 48af3ef66d

View file

@ -70,16 +70,9 @@ pub(super) fn item_or_macro(p: &mut Parser<'_>, stop_on_r_curly: bool) {
// macro_rules! {}; // macro_rules! {};
// macro_rules! () // macro_rules! ()
// macro_rules! [] // macro_rules! []
if paths::is_use_path_start(p) let no_ident = p.at_contextual_kw(T![macro_rules]) && p.nth_at(1, BANG) && !p.nth_at(2, 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);
match macro_call(p) {
BlockLike::Block => (),
BlockLike::NotBlock => {
p.expect(T![;]);
}
}
m.complete(p, MACRO_CALL);
return; return;
} }
@ -436,10 +429,16 @@ fn fn_(p: &mut Parser<'_>, m: Marker) {
m.complete(p, FN); 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)); assert!(paths::is_use_path_start(p));
paths::use_path(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 { pub(super) fn macro_call_after_excl(p: &mut Parser<'_>) -> BlockLike {