Skip to content

Commit 48af3ef

Browse files
committed
Auto merge of #16397 - Urhengulas:refactor-parser, r=Veykril
Refactor `macro_call` to be consistent with other functions rust-lang/rust-analyzer#16314 (comment)
2 parents 6d31416 + b599de1 commit 48af3ef

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

crates/parser/src/grammar/items.rs

+11-12
Original file line numberDiff line numberDiff line change
@@ -70,16 +70,9 @@ pub(super) fn item_or_macro(p: &mut Parser<'_>, stop_on_r_curly: bool) {
7070
// macro_rules! {};
7171
// macro_rules! ()
7272
// macro_rules! []
73-
if paths::is_use_path_start(p)
74-
|| (p.at_contextual_kw(T![macro_rules]) && p.nth_at(1, BANG) && !p.nth_at(2, IDENT))
75-
{
76-
match macro_call(p) {
77-
BlockLike::Block => (),
78-
BlockLike::NotBlock => {
79-
p.expect(T![;]);
80-
}
81-
}
82-
m.complete(p, MACRO_CALL);
73+
let no_ident = p.at_contextual_kw(T![macro_rules]) && p.nth_at(1, BANG) && !p.nth_at(2, IDENT);
74+
if paths::is_use_path_start(p) || no_ident {
75+
macro_call(p, m);
8376
return;
8477
}
8578

@@ -436,10 +429,16 @@ fn fn_(p: &mut Parser<'_>, m: Marker) {
436429
m.complete(p, FN);
437430
}
438431

439-
fn macro_call(p: &mut Parser<'_>) -> BlockLike {
432+
fn macro_call(p: &mut Parser<'_>, m: Marker) {
440433
assert!(paths::is_use_path_start(p));
441434
paths::use_path(p);
442-
macro_call_after_excl(p)
435+
match macro_call_after_excl(p) {
436+
BlockLike::Block => (),
437+
BlockLike::NotBlock => {
438+
p.expect(T![;]);
439+
}
440+
}
441+
m.complete(p, MACRO_CALL);
443442
}
444443

445444
pub(super) fn macro_call_after_excl(p: &mut Parser<'_>) -> BlockLike {

0 commit comments

Comments
 (0)