Skip to content

Commit 45d867e

Browse files
committed
incorporate feedback
1 parent 11d1592 commit 45d867e

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

promotion.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -226,8 +226,8 @@ the result of computing a promoted is a value that does not need dropping.
226226

227227
### Access to a `const` or `static`
228228

229-
When accessing a `const` in a promotable context, its value anyway gets computed
230-
at compile-time, so we do not have to check the initializer. However, the
229+
When accessing a `const` in a promotable context, its value gets computed
230+
at compile-time anyway, so we do not have to check the initializer. However, the
231231
restrictions described above still apply for the *result* of the promoted
232232
computation: in particular, it must be a valid `const` (i.e., it cannot
233233
introduce interior mutability) and it must not require dropping.
@@ -272,12 +272,13 @@ const context, the user likely expects that `x` will live on the stack and be
272272
initialized at run-time. Although this is not (to my knowledge) guaranteed by
273273
the language, we do not wish to violate the user's expectations here.
274274

275-
However, constant-folding still applies: the optimizer may compute `x` at
275+
Note that constant-folding still applies: the optimizer may compute `x` at
276276
compile-time and even inline it everywhere if it can show that this does not
277277
observably alter program behavior. Promotion is very different from
278278
constant-folding as promotion can introduce observable differences in behavior
279279
(if const-evaluation fails) and as it is *guaranteed* to happen in some cases
280-
(and thus exploited by the borrow checker).
280+
(and thus exploited by the borrow checker). This is reflected in the fact that
281+
promotion affects lifetimes, but constant folding does not.
281282

282283
### Single assignment
283284

0 commit comments

Comments
 (0)