Skip to content

Commit

Permalink
Document rvalue promotion to 'static.
Browse files Browse the repository at this point in the history
  • Loading branch information
eddyb committed Aug 16, 2017
1 parent a3dcfe5 commit ec5a4b7
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/expressions.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,15 @@ The following expressions can create mutable lvalues:
### Temporary lifetimes

When using an rvalue in most lvalue contexts, a temporary unnamed lvalue is
created and used instead. The lifetime of temporary values is typically
created and used instead, if not promoted to `'static`. Promotion of an
rvalue expression to a `'static` slot occurs when the expression could be
written in a constant, borrowed, and dereferencing that borrow where the
expression was the originally written, without changing the runtime behavior.
That is, the promoted expression can be evaluated at compile-time and the
resulting value does not contain interior mutability or destructors (these
properties are determined based on the value where possible, e.g. `&None`
always has the type `&'static Option<_>`, as it contains nothing disallowed).
Otherwise, the lifetime of temporary values is typically

- the innermost enclosing statement; the tail expression of a block is
considered part of the statement that encloses the block, or
Expand Down

0 comments on commit ec5a4b7

Please sign in to comment.