-
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
Recover from pub let
#107047
Recover from pub let
#107047
Conversation
(rustbot has picked a reviewer for you, use r? to override) |
The issue has the following idea:
Presumably because some people try to use |
r? diagnostics |
@rustbot ready |
I'm still not confident that this is the right place to put this code. Have you tried placing the recovery into Ideally, we'd consolidate this code into that as well: rust/compiler/rustc_parse/src/parser/item.rs Lines 72 to 76 in 21f6839
|
rust/compiler/rustc_parse/src/parser/item.rs Lines 67 to 80 in 21f6839
When i converted the code above to this:
I got this weird error when
Also when moving the recover code to |
☔ The latest upstream changes (presumably #105670) made this pull request unmergeable. Please resolve the merge conflicts. |
(edited) I'm not sure. You need to share an example of the code :/
I guess that's a good point :/ |
eda2aaf
to
85a20ab
Compare
☔ The latest upstream changes (presumably #107840) made this pull request unmergeable. Please resolve the merge conflicts. |
@rustbot author |
@rustbot ready |
☔ The latest upstream changes (presumably #108682) made this pull request unmergeable. Please resolve the merge conflicts. |
r? @Nilstrieb since you like reviewing parser recoveries 😸 and i've given this pr enough review, and don't want to block it |
"expected item" | ||
}; | ||
err.span_label(self.token.span, label); | ||
if self.is_kw_followed_by_ident(kw::Let) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good.
@@ -111,6 +111,11 @@ impl<'a> Parser<'a> { | |||
// Do not attempt to parse an expression if we're done here. | |||
self.error_outer_attrs(attrs); | |||
self.mk_stmt(lo, StmtKind::Empty) | |||
} else if self.prev_token.is_keyword(kw::Pub) && self.token.is_keyword(kw::Let) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The name of the function is parse_stmt_without_recovery
, so I don't think it's a good idea to do recovery here. I think there was some kind of other function that gets called on invalid statements (I forgot the name but -Ztreat-err-as-bug may guide you there). Maybe you could check there?
@obeis any updates on this? |
Closing this as inactive. Feel free to reöpen this pr or create a new pr if you get the time to work on this. Thanks |
Closes #101622