@@ -425,6 +425,7 @@ scope of the initializer expression is extended.
425425r[ destructors.scope.lifetime-extension.exprs]
426426#### Extending based on expressions
427427
428+ r[ destructors.scope.lifetime-extension.exprs.extending]
428429For a let statement with an initializer, an * extending expression* is an
429430expression which is one of the following:
430431
@@ -434,19 +435,26 @@ expression which is one of the following:
434435 expression] , [ braced struct] [ struct expression ] , or [ tuple] [ tuple expression ]
435436 expression.
436437* The arguments to an extending [ tuple struct] or [ tuple variant] constructor expression.
438+ * The argument(s) to an extending [ ` pin! ` ] or [ ` format_args! ` ] [ macro invocation] expression.
437439* The final expression of any extending [ block expression] .
438440
439441So the borrow expressions in ` &mut 0 ` , ` (&1, &mut 2) ` , and ` Some(&mut 3) `
440442are all extending expressions. The borrows in ` &0 + &1 ` and ` f(&mut 0) ` are not.
441443
444+ r[ destructors.scope.lifetime-extension.exprs.borrow]
442445The operand of any extending borrow expression has its temporary scope
443446extended.
444447
448+ r[ destructors.scope.lifetime-extension.exprs.macros]
449+ The built-in macros [ ` pin! ` ] and [ ` format_args! ` ] create temporaries.
450+ Any extending [ ` pin! ` ] or [ ` format_args! ` ] [ macro invocation] expression has an extended temporary scope.
451+
445452#### Examples
446453
447454Here are some examples where expressions have extended temporary scopes:
448455
449456``` rust
457+ # use std :: pin :: pin;
450458# fn temp () {}
451459// The temporary that stores the result of `temp()` lives in the same scope
452460// as x in these cases.
@@ -456,6 +464,8 @@ let x = &temp() as &dyn Send;
456464# x ;
457465let x = (& * & temp (),);
458466# x ;
467+ let x = pin! (temp ());
468+ # x ;
459469let x = { [Some (& temp ()) ] };
460470# x ;
461471let ref x = temp ();
@@ -510,6 +520,7 @@ There is one additional case to be aware of: when a panic reaches a [non-unwindi
510520[ initialized ] : glossary.md#initialized
511521[ interior mutability ] : interior-mutability.md
512522[ lazy boolean expression ] : expressions/operator-expr.md#lazy-boolean-operators
523+ [ macro invocation ] : macros.md#macro-invocation
513524[ non-unwinding ABI boundary ] : items/functions.md#unwinding
514525[ panic ] : panic.md
515526[ place context ] : expressions.md#place-expressions-and-value-expressions
@@ -554,3 +565,6 @@ There is one additional case to be aware of: when a panic reaches a [non-unwindi
554565[ `match` ] : expressions/match-expr.md
555566[ `while let` ] : expressions/loop-expr.md#while-let-patterns
556567[ `while` ] : expressions/loop-expr.md#predicate-loops
568+
569+ [ `pin!` ] : std::pin::pin
570+ [ `format_args!` ] : core::format_args
0 commit comments