Skip to content

Commit 4484905

Browse files
committed
attempt to clarify 'static' unique address guarantees
1 parent 46d65f8 commit 4484905

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/items/static-items.md

+7-6
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,17 @@
88
> [^extern-safety]: The `safe` and `unsafe` function qualifiers are only
99
> allowed semantically within `extern` blocks.
1010
11-
A *static item* is similar to a [constant], except that it represents a precise
12-
memory location in the program. All references to the static refer to the same
13-
memory location. Static items have the `static` lifetime, which outlives all
14-
other lifetimes in a Rust program. Static items do not call [`drop`] at the
15-
end of the program.
11+
A *static item* is similar to a [constant], except that it represents an allocated object in the
12+
program that is initialized with the initializer expression. This allocated object is disjoint from
13+
all other allocated objects. All references and raw pointers to the static refer to the same
14+
allocated object. Static items have the `static` lifetime, which outlives all other lifetimes in a
15+
Rust program. Static items do not call [`drop`] at the end of the program.
1616

1717
The static declaration defines a static value in the [value namespace] of the module or block where it is located.
1818

1919
The static initializer is a [constant expression] evaluated at compile time.
20-
Static initializers may refer to other statics.
20+
Static initializers may refer to and even read from other statics.
21+
When reading from mutable statics, they read the initial value of that static.
2122

2223
Non-`mut` static items that contain a type that is not [interior mutable] may
2324
be placed in read-only memory.

0 commit comments

Comments
 (0)