-
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
Confusing parser error when writing expression in item context #119161
Comments
|
Ah, thanks. Makes sense, actually, when I think about it. Maybe it can be mentioned in the docs or the diagnostics can be improved to mention that function calls cannot happed at the top-level? |
@ChrisDenton I've had a personal backlog item to "fallback to parsing expression in item context" (and in pattern context) for better diagnostics here, but haven't had the time to do so. If someone wants to take that on sooner than I will, I would be more than happy to help them. |
panic::set_hook
cannot be used, produces parser errors instead
There are too many code examples following this style(especially in library), fix this specific doc may not help, maybe we need a more general solution... |
@estebank I don't know how to fallback to get a better diagnostics here, any more hint? |
Playground: https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=2241d9411a77aa3a465dd34e997bd74d
I tried using the documented example for
std::panic::set_hook
in a clean project (see playground)I expected to see this happen: It compiles
Instead, this happened:
I tried this with
1.74.1
,1.75.0-beta.7 (2023-12-16 b216e7b0e7a2bdf11300)
, and1.76.0-nightly (2023-12-17 6a62871320e262661bb1)
from the playground as well as locally withNone of them worked, it's the same error in all cases.
I also tried various forms of using
set_hook
:And they all produce the same error.
The text was updated successfully, but these errors were encountered: