File tree Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -84,9 +84,15 @@ The following expressions can create mutable lvalues:
84
84
### Temporary lifetimes
85
85
86
86
When using an rvalue in most lvalue contexts, a temporary unnamed lvalue is
87
- created and used instead. The lifetime of temporary values is typically the
88
- innermost enclosing statement; the tail expression of a block is considered
89
- part of the statement that encloses the block.
87
+ created and used instead, if not promoted to ` 'static ` . Promotion of an
88
+ rvalue expression to a ` 'static ` slot occurs when the expression could be
89
+ written in a constant, borrowed, and dereferencing that borrow where the
90
+ expression was the originally written, without changing the runtime behavior.
91
+ That is, the promoted expression can be evaluated at compile-time and the
92
+ resulting value does not contain interior mutability or destructors.
93
+ Otherwise, lifetime of temporary values is typically the innermost enclosing
94
+ statement; the tail expression of a block is considered part of the statement
95
+ that encloses the block
90
96
91
97
When a temporary rvalue is being created that is assigned into a ` let `
92
98
declaration, however, the temporary is created with the lifetime of the
You can’t perform that action at this time.
0 commit comments