@@ -10,17 +10,19 @@ r[expr.if.syntax]
1010>   ;  ; (` else ` ( [ _ BlockExpression_ ] | _ IfExpression_ ) )<sup >\? </sup >
1111>
1212> _ IfConditions_ :\
13- >   ;  ; _ IfCondition_ ( && _ IfCondition_ )*
13+ >   ;  ; _ IfCondition_ ( && _ IfCondition_ )* [ ^ if-condition-2024 ]
1414>
1515> _ IfCondition_ :\
16- >   ;  ;   ;  ; [ _ Expression_ ] <sub >_ except struct expression_ </sub >\
17- >   ;  ; | ` let ` [ _ Pattern_ ] ` = ` [ _ Scrutinee_ ]
16+ >   ;  ;   ;  ; [ _ Expression_ ] <sub >_ except struct expression or lazy boolean expression_ </sub >\
17+ >   ;  ; | ` let ` [ _ Pattern_ ] ` = ` [ _ Scrutinee_ ] <sub >_ except struct expression or lazy boolean expression_ </sub >
18+ >
19+ > [ ^ if-condition-2024 ] : Editions before 2024 only allow a single _ IfCondition_ .
1820
1921r[ expr.if.intro]
2022The syntax of an ` if ` expression is a sequence of one or more condition operands separated by ` && ` ,
2123followed by a consequent block, any number of ` else if ` conditions and blocks, and an optional trailing ` else ` block.
2224
23- r[ expr.if.condition-bool ]
25+ r[ expr.if.condition]
2426Condition operands must be either an [ _ Expression_ ] with a [ boolean type] or a conditional ` let ` match.
2527
2628r[ expr.if.condition-true]
@@ -160,6 +162,9 @@ If a `||` expression is needed, then parentheses can be used. For example:
160162if let Some (x ) = foo && (condition1 || condition2 ) { /*...*/ }
161163```
162164
165+ r[ expr.if.edition2024]
166+ > ** Edition differences** : Before the 2024 edition, let chains are not supported and only a single _ IfCondition_ is allowed in an ` if ` expression.
167+
163168[ _BlockExpression_ ] : block-expr.md
164169[ _Expression_ ] : ../expressions.md
165170[ _LazyBooleanOperatorExpression_ ] : operator-expr.md#lazy-boolean-operators
0 commit comments