File tree Expand file tree Collapse file tree 1 file changed +6
-4
lines changed Expand file tree Collapse file tree 1 file changed +6
-4
lines changed Original file line number Diff line number Diff line change @@ -232,15 +232,17 @@ 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.
234
234
235
- For instance, while the previous example was not legal, the following would be:
235
+ For instance the following would be legal even though calls to ` do_it ` are not
236
+ eligible for implicit promotion:
236
237
237
238
``` rust
238
- const BOOL : i32 = {
239
- let ret = if cfg! (windows ) { 0 } else { 1 };
239
+ const fn do_it (x : i32 ) -> i32 { 2 * x }
240
+ const ANSWER : i32 = {
241
+ let ret = do_it (21 );
240
242
ret
241
243
};
242
244
243
- let x : & 'static i32 = & BOOL ;
245
+ let x : & 'static i32 = & ANSWER ;
244
246
```
245
247
246
248
An access to a ` static ` is only promotable within the initializer of another
You can’t perform that action at this time.
0 commit comments