-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
Document that leading blocks are never expressions #13012
Comments
This is caused by the parser parsing {1} + 1
unsafe {1} + 1
if true {1} else {1} + 1 @nikomatsakis, @brson, this relates to the discussion at the work week. I think we resolved that this is working as intended, but did we intend to write up documentation for this? |
It's also an issue with macros. I think there's already an issue for that case. |
We do allow 1 + {1};
1 + unsafe{ 1 }
1 + if true {1} else {1} It seems like the reverse should work also. |
#5941 for macros. |
@alexcrichton this is working as intended, yes. I had no particular plan to write docs but of course that's always a nice thing to do. Not sure where that'd go, I'd assume it's just part of the language grammar, which we ought to document but as part of general work on the reference manual I guess. @Thiez no, the reverse does not work, it introduces parser ambiguities, use a parenthesis. |
Updated title/description to reflect what needs to be done. |
I'm not sure how or where to appropriately document this, it seems like just straight-up invalid code. |
Traige: still not clear exactly with what to do for an "I expected this to work but it doesn't," so I'm giving this a close. It's not scalable to put every kind of quesiton like this in the docs, and I don't see people asking about this very often. If it becomes a problem, we can try to figure something out eventually. |
This change improves the `generate_function` assist to support generating static methods/associated functions using the `Self::assoc()` syntax. Previously, one could generate a static method, but only when specifying the type name directly (like `Foo::assoc()`). After this change, `Self` is supported as well as the type name. Fixes rust-lang#13012
…soc-2, r=Veykril feat: Generate static method using Self::assoc() syntax This change improves the `generate_function` assist to support generating static methods/associated functions using the `Self::assoc()` syntax. Previously, one could generate a static method, but only when specifying the type name directly (like `Foo::assoc()`). After this change, `Self` is supported as well as the type name. Fixes rust-lang#13012
[`single_match`, `single_match_else`] fix suggestion when match irrefutable fixes rust-lang#13012 changelog:[`single_match`, `single_match_else`]: fix suggestion when `match` irrefutable
Updated description
The fact that leading blocks are never expressions needs to be documented in the language reference both in the grammar section and likely elsewhere to make it known
Original description
You need parentheses:
but it doesn't seem like that should be necessary.
The text was updated successfully, but these errors were encountered: