@@ -12,21 +12,26 @@ r[items.static.syntax]
12
12
> allowed semantically within ` extern ` blocks.
13
13
14
14
r[ items.static.intro]
15
- A * static item* is similar to a [ constant] , except that it represents a precise
16
- memory location in the program . All references to the static refer to the same
17
- memory location .
15
+ A * static item* is similar to a [ constant] , except that it represents an allocated object in the
16
+ program that is initialized with the initializer expression . All references and raw pointers to the
17
+ static refer to the same allocated object .
18
18
19
19
r[ items.static.lifetime]
20
- Static items have the ` static ` lifetime, which outlives all
21
- other lifetimes in a Rust program. Static items do not call [ ` drop ` ] at the
22
- end of the program.
20
+ Static items have the ` static ` lifetime, which outlives all other lifetimes in a Rust program.
21
+ Static items do not call [ ` drop ` ] at the end of the program.
22
+
23
+ r[ items.static.storage-disjointness]
24
+ This allocated object is disjoint from all other ` static ` objects as well as heap-allocated and
25
+ stack-allocated variables. However, the storage of immutable ` static ` items can overlap with objects
26
+ that do not themselves have a unique address, such as [ promoteds] and [ ` const ` items] [ constant ] .
23
27
24
28
r[ items.static.namespace]
25
29
The static declaration defines a static value in the [ value namespace] of the module or block where it is located.
26
30
27
31
r[ items.static.init]
28
32
The static initializer is a [ constant expression] evaluated at compile time.
29
- Static initializers may refer to other statics.
33
+ Static initializers may refer to and read from other statics.
34
+ When reading from mutable statics, they read the initial value of that static.
30
35
31
36
r[ items.static.read-only]
32
37
Non-` mut ` static items that contain a type that is not [ interior mutable] may
@@ -173,3 +178,4 @@ following are true:
173
178
[ _Expression_ ] : ../expressions.md
174
179
[ value namespace ] : ../names/namespaces.md
175
180
[ _ItemSafety_ ] : functions.md
181
+ [ promoteds ] : ../destructors.md#constant-promotion
0 commit comments