Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions src/items/static-items.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,13 @@ r[items.static.read-only]
Non-`mut` static items that contain a type that is not [interior mutable] may be placed in read-only memory.

r[items.static.safety]
All access to a static is safe, but there are a number of restrictions on statics:
All access to a static is safe, but the type is restricted, and must either:

r[items.static.sync]
* The type must have the [`Sync`](std::marker::Sync) trait bound to allow thread-safe access.
* Implement the [`Sync`](std::marker::Sync) trait to allow thread-safe access.

r[items.static.unsafecell]
* Be [`UnsafeCell<T>`](std::cell::UnsafeCell), where `T` implements the [`Sync`](std::marker::Sync) trait.

r[items.static.init.omission]
The initializer expression must be omitted in an [external block], and must be provided for free static items.
Expand Down Expand Up @@ -126,7 +129,7 @@ fn bump_levels_safe() -> u32 {
```

r[items.static.mut.sync]
Copy link
Contributor Author

@madsmtm madsmtm Feb 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unsure about the name of this rule label now.

Mutable statics have the same restrictions as normal statics, except that the type does not have to implement the `Sync` trait.
Mutable statics have the same restrictions as normal statics, except that there are no no restrictions on the type (for example, the type does not have to implement the `Sync` trait).

r[items.static.alternate]
## Using statics or consts
Expand Down