-
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
Some errors could be better handled by detecting a pattern #101291
Comments
I think this issue could be phrase a bit more specifically, i.e. "parse JS style for-loop iteration and suggest fixing it", unless you're suggesting that we try to parse all sorts of different |
Alternatively, this could be fixed with a few different error recoveries. First, we should recover from this:
Then we could also recover from:
|
Detecting |
…=cjgillot Suggest removing unnecessary prefix let in patterns Helps with rust-lang#101291, though I think `@estebank` probably wants this: > Finally, I think it'd be nice if we could detect that we don't know for sure and "just" swallow the rest of the expression (find the next ; accounting for nested braces) or the end of the item (easier). ... to be implemented before we close that issue out completely.
…jgillot Suggest removing unnecessary prefix let in patterns Helps with rust-lang#101291, though I think `@estebank` probably wants this: > Finally, I think it'd be nice if we could detect that we don't know for sure and "just" swallow the rest of the expression (find the next ; accounting for nested braces) or the end of the item (easier). ... to be implemented before we close that issue out completely.
@rustbot label A-diagnostics T-compiler |
Output on
|
Given the current output, I feel like we can close this ticket, while also acknowledging that the space of possible parses of mistaken code hasn't been exhausted yet. |
Exemple Use Case:
It's possibly common enough for people using several languages to apply the wrong, easy to recognize, construct.
Recognizing this construct in case an error is detected would avoid a sequence of suboptimal hints.
Here's the exemple of typing
for let thing of some_iterator
(JavaScript inspired):A more relevant hint would suggest the typical Rust iteration.
Triage note:
@estebank suggested I create an issue here
The text was updated successfully, but these errors were encountered: