Skip to content

Commit 5fe9e1d

Browse files
committed
Changes from review
1 parent f17058b commit 5fe9e1d

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
lines changed

src/destructors.md

+6-5
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,9 @@ leaves a drop scope all variables associated to that scope are dropped in
6767
reverse order of declaration (for variables) or creation (for temporaries).
6868

6969
r[destructors.scope.desugaring]
70-
Drop scopes are determined after replacing [`for`], [`if let`], and
71-
[`while let`] expressions with the equivalent expressions using [`match`].
70+
Drop scopes can be determined by replacing [`for`], [`if`], and [`while`]
71+
expressions with equivalent expressions using [`match`], [`loop`] and
72+
`break`.
7273

7374
r[destructors.scope.operators]
7475
Overloaded operators are not distinguished from built-in operators and [binding
@@ -204,11 +205,11 @@ smallest scope that contains the expression and is one of the following:
204205
* A statement.
205206
* The body of an [`if`], [`while`] or [`loop`] expression.
206207
* The `else` block of an `if` expression.
207-
* The condition expression of an `if` or `while` expression, or a `match`
208-
guard.
208+
* The non-pattern matching condition expression of an `if` or `while` expression,
209+
or a `match` guard.
209210
* The body expression for a match arm.
210211
* Each operand of a [lazy boolean expression].
211-
* The pattern-matching condition and consequent body of [`if let`] ([destructors.scope.temporary.edition2024]).
212+
* The pattern-matching condition(s) and consequent body of [`if`] ([destructors.scope.temporary.edition2024]).
212213
* The entirety of the tail expression of a block ([destructors.scope.temporary.edition2024]).
213214

214215
> **Notes**:

src/expressions/if-expr.md

+9-4
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,19 @@ r[expr.if.syntax]
1010
> &nbsp;&nbsp; (`else` ( [_BlockExpression_] | _IfExpression_ ) )<sup>\?</sup>
1111
>
1212
> _IfConditions_ :\
13-
> &nbsp;&nbsp; _IfCondition_ ( && _IfCondition_ )*
13+
> &nbsp;&nbsp; _IfCondition_ ( && _IfCondition_ )*[^if-condition-2024]
1414
>
1515
> _IfCondition_ :\
16-
> &nbsp;&nbsp; &nbsp;&nbsp; [_Expression_]<sub>_except struct expression_</sub>\
17-
> &nbsp;&nbsp; | `let` [_Pattern_] `=` [_Scrutinee_]
16+
> &nbsp;&nbsp; &nbsp;&nbsp; [_Expression_]<sub>_except struct expression or lazy boolean expression_</sub>\
17+
> &nbsp;&nbsp; | `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
1921
r[expr.if.intro]
2022
The syntax of an `if` expression is a sequence of one or more condition operands separated by `&&`,
2123
followed 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]
2426
Condition operands must be either an [_Expression_] with a [boolean type] or a conditional `let` match.
2527

2628
r[expr.if.condition-true]
@@ -160,6 +162,9 @@ If a `||` expression is needed, then parentheses can be used. For example:
160162
if 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

Comments
 (0)