-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Two consecutive if lets cannot be used as function result #54186
Comments
The key thing to note here is https://doc.rust-lang.org/reference/statements.html#expression-statements for the reason. |
Interesting. Thanks for the two links. So it is intended and also wanted, but not gonna be "fixed"? |
We can add a diagnostic for when its followed by a bin-op like that, but we're not changing the language to accept the code. |
Identify when a stmt could have been parsed as an expr There are some expressions that can be parsed as a statement without a trailing semicolon depending on the context, which can lead to confusing errors due to the same looking code being accepted in some places and not others. Identify these cases and suggest enclosing in parenthesis making the parse non-ambiguous without changing the accepted grammar. Fix rust-lang#54186, cc rust-lang#54482, fix rust-lang#59975, fix rust-lang#47287.
Reopening because I'm reverting the change that fixed it because of #74233. |
MCVE
Error:
Am I missing something? Why is the first one not allowed, but the second one?
The text was updated successfully, but these errors were encountered: