File tree 1 file changed +9
-1
lines changed
1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -84,7 +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
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 (these
93
+ properties are determined based on the value where possible, e.g. ` &None `
94
+ always has the type ` &'static Option<_> ` , as it contains nothing disallowed).
95
+ Otherwise, the lifetime of temporary values is typically
88
96
89
97
- the innermost enclosing statement; the tail expression of a block is
90
98
considered part of the statement that encloses the block, or
You can’t perform that action at this time.
0 commit comments