From a6d7cc36dc69382863d2cf5169a8fbd4848a2403 Mon Sep 17 00:00:00 2001 From: Tomek Czajka Date: Wed, 11 Oct 2023 12:06:36 +0200 Subject: [PATCH] Fix temporary drop scope for last expression. The outermost scope is "the entire function", not "the entire function body" which is different. --- src/destructors.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/destructors.md b/src/destructors.md index 17afc3676..9c426426c 100644 --- a/src/destructors.md +++ b/src/destructors.md @@ -156,7 +156,7 @@ temporary variable that holds the result of that expression when used in a Apart from lifetime extension, the temporary scope of an expression is the smallest scope that contains the expression and is one of the following: -* The entire function body. +* The entire function. * A statement. * The body of an [`if`], [`while`] or [`loop`] expression. * The `else` block of an `if` expression. @@ -168,8 +168,8 @@ smallest scope that contains the expression and is one of the following: > **Notes**: > > Temporaries that are created in the final expression of a function -> body are dropped *after* any named variables bound in the function body, as -> there is no smaller enclosing temporary scope. +> body are dropped *after* any named variables bound in the function body. +> Their drop scope is the entire function, as there is no smaller enclosing temporary scope. > > The [scrutinee] of a `match` expression is not a temporary scope, so > temporaries in the scrutinee can be dropped after the `match` expression. For