@@ -11,15 +11,15 @@ use crate::errors::{
11
11
ComparisonOrShiftInterpretedAsGenericSugg , DoCatchSyntaxRemoved , DotDotDot , EqFieldInit ,
12
12
ExpectedElseBlock , ExpectedEqForLetExpr , ExpectedExpressionFoundLet ,
13
13
FieldExpressionWithGeneric , FloatLiteralRequiresIntegerPart , FoundExprWouldBeStmt ,
14
- IfExpressionMissingCondition , IfExpressionMissingThenBlock , IfExpressionMissingThenBlockSub ,
15
- InvalidBlockMacroSegment , InvalidComparisonOperator , InvalidComparisonOperatorSub ,
16
- InvalidInterpolatedExpression , InvalidLiteralSuffixOnTupleIndex , InvalidLogicalOperator ,
17
- InvalidLogicalOperatorSub , LabeledLoopInBreak , LeadingPlusNotSupported , LeftArrowOperator ,
18
- LifetimeInBorrowExpression , MacroInvocationWithQualifiedPath , MalformedLoopLabel ,
19
- MatchArmBodyWithoutBraces , MatchArmBodyWithoutBracesSugg , MissingCommaAfterMatchArm ,
20
- MissingDotDot , MissingInInForLoop , MissingInInForLoopSub , MissingSemicolonBeforeArray ,
21
- NoFieldsForFnCall , NotAsNegationOperator , NotAsNegationOperatorSub ,
22
- OuterAttributeNotAllowedOnIfElse , ParenthesesWithStructFields ,
14
+ IfExpressionLetSomeSub , IfExpressionMissingCondition , IfExpressionMissingThenBlock ,
15
+ IfExpressionMissingThenBlockSub , InvalidBlockMacroSegment , InvalidComparisonOperator ,
16
+ InvalidComparisonOperatorSub , InvalidInterpolatedExpression , InvalidLiteralSuffixOnTupleIndex ,
17
+ InvalidLogicalOperator , InvalidLogicalOperatorSub , LabeledLoopInBreak , LeadingPlusNotSupported ,
18
+ LeftArrowOperator , LifetimeInBorrowExpression , MacroInvocationWithQualifiedPath ,
19
+ MalformedLoopLabel , MatchArmBodyWithoutBraces , MatchArmBodyWithoutBracesSugg ,
20
+ MissingCommaAfterMatchArm , MissingDotDot , MissingInInForLoop , MissingInInForLoopSub ,
21
+ MissingSemicolonBeforeArray , NoFieldsForFnCall , NotAsNegationOperator ,
22
+ NotAsNegationOperatorSub , OuterAttributeNotAllowedOnIfElse , ParenthesesWithStructFields ,
23
23
RequireColonAfterLabeledExpression , ShiftInterpretedAsGeneric , StructLiteralNotAllowedHere ,
24
24
StructLiteralNotAllowedHereSugg , TildeAsUnaryOperator , UnexpectedIfWithIf ,
25
25
UnexpectedTokenAfterLabel , UnexpectedTokenAfterLabelSugg , WrapExpressionInParentheses ,
@@ -2251,9 +2251,10 @@ impl<'a> Parser<'a> {
2251
2251
if let ExprKind :: Block ( _, None ) = right. kind => {
2252
2252
self . sess . emit_err ( IfExpressionMissingThenBlock {
2253
2253
if_span : lo,
2254
- sub : IfExpressionMissingThenBlockSub :: UnfinishedCondition (
2255
- cond_span. shrink_to_lo ( ) . to ( * binop_span)
2256
- ) ,
2254
+ missing_then_block_sub :
2255
+ IfExpressionMissingThenBlockSub :: UnfinishedCondition ( cond_span. shrink_to_lo ( ) . to ( * binop_span) ) ,
2256
+ let_else_sub : None ,
2257
+
2257
2258
} ) ;
2258
2259
std:: mem:: replace ( right, this. mk_expr_err ( binop_span. shrink_to_hi ( ) ) )
2259
2260
} ,
@@ -2279,9 +2280,15 @@ impl<'a> Parser<'a> {
2279
2280
if let Some ( block) = recover_block_from_condition ( self ) {
2280
2281
block
2281
2282
} else {
2283
+ let let_else_sub = matches ! ( cond. kind, ExprKind :: Let ( ..) )
2284
+ . then ( || IfExpressionLetSomeSub { if_span : lo } ) ;
2285
+
2282
2286
self . sess . emit_err ( IfExpressionMissingThenBlock {
2283
2287
if_span : lo,
2284
- sub : IfExpressionMissingThenBlockSub :: AddThenBlock ( cond_span. shrink_to_hi ( ) ) ,
2288
+ missing_then_block_sub : IfExpressionMissingThenBlockSub :: AddThenBlock (
2289
+ cond_span. shrink_to_hi ( ) ,
2290
+ ) ,
2291
+ let_else_sub,
2285
2292
} ) ;
2286
2293
self . mk_block_err ( cond_span. shrink_to_hi ( ) )
2287
2294
}
0 commit comments