Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix incorrect parse of statement macro followed by range #1815

Merged
merged 1 commit into from
Dec 29, 2024
Merged

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
30 checks passed
@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