Recover for PAT = EXPR {}
This commit is contained in:
@@ -585,14 +585,13 @@ pub(crate) struct MissingInInForLoop {
|
||||
|
||||
#[derive(Subdiagnostic)]
|
||||
pub(crate) enum MissingInInForLoopSub {
|
||||
// User wrote `for pat of expr {}`
|
||||
// Has been misleading, at least in the past (closed Issue #48492), thus maybe-incorrect
|
||||
#[suggestion(
|
||||
parse_use_in_not_of,
|
||||
style = "verbose",
|
||||
applicability = "maybe-incorrect",
|
||||
code = "in"
|
||||
)]
|
||||
#[suggestion(parse_use_in, style = "verbose", applicability = "maybe-incorrect", code = "in")]
|
||||
InNotOf(#[primary_span] Span),
|
||||
// User wrote `for pat = expr {}`
|
||||
#[suggestion(parse_use_in, style = "verbose", applicability = "maybe-incorrect", code = "in")]
|
||||
InNotEq(#[primary_span] Span),
|
||||
#[suggestion(parse_add_in, style = "verbose", applicability = "maybe-incorrect", code = " in ")]
|
||||
AddIn(#[primary_span] Span),
|
||||
}
|
||||
|
||||
@@ -3028,6 +3028,8 @@ impl<'a> Parser<'a> {
|
||||
let span = self.token.span;
|
||||
self.bump();
|
||||
(span, errors::MissingInInForLoopSub::InNotOf)
|
||||
} else if self.eat(exp!(Eq)) {
|
||||
(self.prev_token.span, errors::MissingInInForLoopSub::InNotEq)
|
||||
} else {
|
||||
(self.prev_token.span.between(self.token.span), errors::MissingInInForLoopSub::AddIn)
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user