fix #103587, Recover from common if let syntax mistakes/typos
This commit is contained in:
parent
57d3c58ed6
commit
667b15bb0e
7 changed files with 165 additions and 4 deletions
|
@ -9,9 +9,9 @@ use crate::errors::{
|
|||
ArrayBracketsInsteadOfSpaces, ArrayBracketsInsteadOfSpacesSugg, AsyncMoveOrderIncorrect,
|
||||
BinaryFloatLiteralNotSupported, BracesForStructLiteral, CatchAfterTry, CommaAfterBaseStruct,
|
||||
ComparisonInterpretedAsGeneric, ComparisonOrShiftInterpretedAsGenericSugg,
|
||||
DoCatchSyntaxRemoved, DotDotDot, EqFieldInit, ExpectedElseBlock, ExpectedExpressionFoundLet,
|
||||
FieldExpressionWithGeneric, FloatLiteralRequiresIntegerPart, FoundExprWouldBeStmt,
|
||||
HexadecimalFloatLiteralNotSupported, IfExpressionMissingCondition,
|
||||
DoCatchSyntaxRemoved, DotDotDot, EqFieldInit, ExpectedElseBlock, ExpectedEqForLetExpr,
|
||||
ExpectedExpressionFoundLet, FieldExpressionWithGeneric, FloatLiteralRequiresIntegerPart,
|
||||
FoundExprWouldBeStmt, HexadecimalFloatLiteralNotSupported, IfExpressionMissingCondition,
|
||||
IfExpressionMissingThenBlock, IfExpressionMissingThenBlockSub, IntLiteralTooLarge,
|
||||
InvalidBlockMacroSegment, InvalidComparisonOperator, InvalidComparisonOperatorSub,
|
||||
InvalidFloatLiteralSuffix, InvalidFloatLiteralWidth, InvalidIntLiteralWidth,
|
||||
|
@ -2334,7 +2334,15 @@ impl<'a> Parser<'a> {
|
|||
RecoverColon::Yes,
|
||||
CommaRecoveryMode::LikelyTuple,
|
||||
)?;
|
||||
self.expect(&token::Eq)?;
|
||||
if self.token == token::EqEq {
|
||||
self.sess.emit_err(ExpectedEqForLetExpr {
|
||||
span: self.token.span,
|
||||
sugg_span: self.token.span,
|
||||
});
|
||||
self.bump();
|
||||
} else {
|
||||
self.expect(&token::Eq)?;
|
||||
}
|
||||
let expr = self.with_res(self.restrictions | Restrictions::NO_STRUCT_LITERAL, |this| {
|
||||
this.parse_assoc_expr_with(1 + prec_let_scrutinee_needs_par(), None.into())
|
||||
})?;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue