|
1 | 1 | # Statics
|
2 | 2 |
|
3 | 3 | Statics (`static`, `static mut`) are the simplest kind of compile-time evaluated data:
|
4 |
| -The user explicitly requested them to be evaluated at compile-time, |
5 |
| -so evaluation errors from computing the initial value of a static are no concern. |
6 |
| -They observably get evaluated *once*, with the result being put at some address known at run-time, |
7 |
| -so there are no fundamental restrictions on what statics can do. |
8 |
| -The compiler checks that statics are `Sync`, justifying sharing their address across threads. |
9 |
| -[Constants](const.md) and [promoteds](promotion.md) are not allowed to read from statics, |
10 |
| -so their final value does not have have to be [const-valid](const_safety.md) in any meaningful way |
11 |
| -(but as of 2019-08, we do check them for validity anyway, to be conservative). |
| 4 | +* The user explicitly requested them to be evaluated at compile-time, |
| 5 | + so evaluation errors from computing the initial value of a static are no concern |
| 6 | + (in other words, [const safety](const_safety.md) is mostly not an issue). |
| 7 | +* They observably get evaluated *once*, with the result being put at some address known at run-time, |
| 8 | + so there are no fundamental restrictions on what statics can do. |
| 9 | +* The compiler checks that statics are `Sync`, justifying sharing their address across threads. |
| 10 | +* [Constants](const.md) and [promoteds](promotion.md) are not allowed to read from statics, |
| 11 | + so their final value does not have have to be [const-valid](const_safety.md#const-safety-check-on-values) in any meaningful way. |
| 12 | + As of 2019-08, we do check them for validity anyway, to be conservative; and indeed constants could be allowed to read from frozen statics. |
12 | 13 |
|
13 | 14 | ## `Drop`
|
14 | 15 |
|
|
0 commit comments