File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed
Expand file tree Collapse file tree 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:
8484### Temporary lifetimes
8585
8686When 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
8896
8997- the innermost enclosing statement; the tail expression of a block is
9098 considered part of the statement that encloses the block, or
You can’t perform that action at this time.
0 commit comments