You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/destructors.md
+18-8
Original file line number
Diff line number
Diff line change
@@ -211,20 +211,22 @@ smallest scope that contains the expression and is one of the following:
211
211
guard.
212
212
* The body expression for a match arm.
213
213
* Each operand of a [lazy boolean expression].
214
+
* The pattern-matching condition and consequent body of [`if let`] ([destructors.scope.temporary.edition2024]).
215
+
* The entirety of the tail expression of a block ([destructors.scope.temporary.edition2024]).
214
216
215
217
> **Notes**:
216
218
>
217
-
> Temporaries that are created in the final expression of a function
218
-
> body are dropped *after* any named variables bound in the function body.
219
-
> Their drop scope is the entire function, as there is no smaller enclosing temporary scope.
220
-
>
221
219
> The [scrutinee] of a `match` expression is not a temporary scope, so
222
220
> temporaries in the scrutinee can be dropped after the `match` expression. For
223
221
> example, the temporary for `1` in `match 1 { ref mut z => z };` lives until
224
222
> the end of the statement.
225
223
224
+
r[destructors.scope.temporary.edition2024]
225
+
> **Edition differences**: The 2024 edition added two new temporary scope narrowing rules: `if let` temporaries are dropped before the `else` block, and temporaries of tail expressions of blocks are dropped immediately after the tail expression is evaluated.
0 commit comments