Fix macro matching of meta then => or ==

The parser declared it was invalid meta because it consumed the lone `=`, which is incorrect.
This commit is contained in:
Chayim Refael Friedman 2026-01-26 16:13:06 +02:00
parent 2532c48f1e
commit 6ef381d4e2
2 changed files with 21 additions and 1 deletions

View File

@ -237,3 +237,23 @@ fn test() {
"#]],
);
}
#[test]
fn meta_fat_arrow() {
check(
r#"
macro_rules! m {
( $m:meta => ) => {};
}
m! { foo => }
"#,
expect![[r#"
macro_rules! m {
( $m:meta => ) => {};
}
"#]],
);
}

View File

@ -70,7 +70,7 @@ pub(super) fn meta(p: &mut Parser<'_>) {
paths::attr_path(p);
match p.current() {
T![=] => {
T![=] if !p.at(T![=>]) && !p.at(T![==]) => {
p.bump(T![=]);
if expressions::expr(p).is_none() {
p.error("expected expression");