Skip to content

Fix incorrect parse of statement macro followed by range#1815

Merged
dtolnay merged 1 commit intomasterfrom
macrange
Dec 29, 2024
Merged

Fix incorrect parse of statement macro followed by range#1815
dtolnay merged 1 commit intomasterfrom
macrange

Conversation

@dtolnay
Copy link
Owner

@dtolnay dtolnay commented Dec 29, 2024

For the program fn main() { m! {} .. }, Syn would previously parse this as [Stmt::Expr(Expr::Range { start: Expr::Macro, end: None })]. The correct parse is [Stmt::Macro, Stmt::Expr(Expr::Range { start: None, end: None })] as is clear from the following diagnostic from rustc.

error[E0308]: mismatched types
 --> src/main.rs:1:19
  |
1 | fn main() { m! {} .. }
  |          -        ^^ expected `()`, found `RangeFull`
  |          |
  |          expected `()` because of default return type

@dtolnay dtolnay merged commit ce081e8 into master Dec 29, 2024
@dtolnay dtolnay deleted the macrange branch December 29, 2024 18:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant