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