File tree Expand file tree Collapse file tree 1 file changed +4
-2
lines changed Expand file tree Collapse file tree 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.
1313"Lifetime extension" is a mechanism that affects code like ` &3 ` :
1414Instead of putting it on the stack, the ` 3 ` is allocated in global static memory
1515and 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 }`.
1820
1921Note that promotion happens on the MIR, not on surface-level syntax. This is
2022relevant when discussing e.g. handling of panics caused by overflowing
You can’t perform that action at this time.
0 commit comments