File tree 1 file changed +4
-2
lines changed
1 file changed +4
-2
lines changed Original file line number Diff line number Diff line change @@ -13,8 +13,10 @@ There are a few different contexts where promotion is beneficial.
13
13
"Lifetime extension" is a mechanism that affects code like ` &3 ` :
14
14
Instead of putting it on the stack, the ` 3 ` is allocated in global static memory
15
15
and a reference with lifetime ` 'static ` is provided. This is essentially an
16
- automatic transformation turning ` &EXPR ` into
17
- ` { const _PROMOTED = &EXPR; _PROMOTED } ` , but only if ` EXPR ` qualifies.
16
+ automatic transformation turning ` &EXPR ` into `{ const _ PROMOTED = &EXPR;
17
+ _ PROMOTED }` , but only if ` EXPR` qualifies. Topmost projections are not
18
+ promoted, so ` &EXPR.proj1.proj2 ` turns into `{ const _ PROMOTED = &EXPR;
19
+ &(* _ PROMOTED).proj1.proj2 }`.
18
20
19
21
Note that promotion happens on the MIR, not on surface-level syntax. This is
20
22
relevant when discussing e.g. handling of panics caused by overflowing
You can’t perform that action at this time.
0 commit comments