Skip to content

Commit 9adbc21

Browse files
committed
specify lifetime extension of pin! and format_args! arguments
1 parent 0a25dea commit 9adbc21

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/destructors.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -434,6 +434,7 @@ expression which is one of the following:
434434
expression], [braced struct][struct expression], or [tuple][tuple expression]
435435
expression.
436436
* The arguments to an extending [tuple struct] or [tuple variant] constructor expression.
437+
* The argument(s) to an extending [`pin!`] or [`format_args!`] [macro invocation] expression.
437438
* The final expression of any extending [block expression].
438439

439440
So the borrow expressions in `&mut 0`, `(&1, &mut 2)`, and `Some(&mut 3)`
@@ -447,6 +448,7 @@ extended.
447448
Here are some examples where expressions have extended temporary scopes:
448449

449450
```rust
451+
# use std::pin::pin;
450452
# fn temp() {}
451453
// The temporary that stores the result of `temp()` lives in the same scope
452454
// as x in these cases.
@@ -456,6 +458,8 @@ let x = &temp() as &dyn Send;
456458
# x;
457459
let x = (&*&temp(),);
458460
# x;
461+
let x = pin!(temp());
462+
# x;
459463
let x = { [Some(&temp()) ] };
460464
# x;
461465
let ref x = temp();
@@ -510,6 +514,7 @@ There is one additional case to be aware of: when a panic reaches a [non-unwindi
510514
[initialized]: glossary.md#initialized
511515
[interior mutability]: interior-mutability.md
512516
[lazy boolean expression]: expressions/operator-expr.md#lazy-boolean-operators
517+
[macro invocation]: macros.md#macro-invocation
513518
[non-unwinding ABI boundary]: items/functions.md#unwinding
514519
[panic]: panic.md
515520
[place context]: expressions.md#place-expressions-and-value-expressions
@@ -554,3 +559,6 @@ There is one additional case to be aware of: when a panic reaches a [non-unwindi
554559
[`match`]: expressions/match-expr.md
555560
[`while let`]: expressions/loop-expr.md#while-let-patterns
556561
[`while`]: expressions/loop-expr.md#predicate-loops
562+
563+
[`pin!`]: std::pin::pin
564+
[`format_args!`]: core::format_args

0 commit comments

Comments
 (0)