@@ -226,8 +226,8 @@ the result of computing a promoted is a value that does not need dropping.
226
226
227
227
### Access to a ` const ` or ` static `
228
228
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
231
231
restrictions described above still apply for the * result* of the promoted
232
232
computation: in particular, it must be a valid ` const ` (i.e., it cannot
233
233
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
272
272
initialized at run-time. Although this is not (to my knowledge) guaranteed by
273
273
the language, we do not wish to violate the user's expectations here.
274
274
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
276
276
compile-time and even inline it everywhere if it can show that this does not
277
277
observably alter program behavior. Promotion is very different from
278
278
constant-folding as promotion can introduce observable differences in behavior
279
279
(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.
281
282
282
283
### Single assignment
283
284
0 commit comments