-
Notifications
You must be signed in to change notification settings - Fork 533
distinct 'static' items never overlap #1657
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,21 +12,27 @@ r[items.static.syntax] | |
> allowed semantically within `extern` blocks. | ||
|
||
r[items.static.intro] | ||
A *static item* is similar to a [constant], except that it represents a precise | ||
memory location in the program. All references to the static refer to the same | ||
memory location. | ||
A *static item* is similar to a [constant], except that it represents an allocated object in the | ||
program that is initialized with the initializer expression. All references and raw pointers to the | ||
static refer to the same allocated object. | ||
|
||
r[items.static.lifetime] | ||
Static items have the `static` lifetime, which outlives all | ||
other lifetimes in a Rust program. Static items do not call [`drop`] at the | ||
end of the program. | ||
Static items have the `static` lifetime, which outlives all other lifetimes in a Rust program. | ||
Static items do not call [`drop`] at the end of the program. | ||
|
||
r[items.static.storage-disjointness] | ||
If the `static` has a size of at least 1 byte, this allocated object is disjoint from all other | ||
`static` objects as well as heap-allocated and stack-allocated variables. However, the storage of | ||
RalfJung marked this conversation as resolved.
Show resolved
Hide resolved
|
||
immutable `static` items can overlap with objects that do not themselves have a unique address, such | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. “Immutable There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes we should have this as a shared definition somewhere that we can reference. |
||
as [promoteds] and [`const` items][constant]. | ||
|
||
r[items.static.namespace] | ||
The static declaration defines a static value in the [value namespace] of the module or block where it is located. | ||
|
||
r[items.static.init] | ||
The static initializer is a [constant expression] evaluated at compile time. | ||
Static initializers may refer to other statics. | ||
Static initializers may refer to and read from other statics. | ||
When reading from mutable statics, they read the initial value of that static. | ||
|
||
r[items.static.read-only] | ||
Non-`mut` static items that contain a type that is not [interior mutable] may | ||
|
@@ -173,3 +179,4 @@ following are true: | |
[_Expression_]: ../expressions.md | ||
[value namespace]: ../names/namespaces.md | ||
[_ItemSafety_]: functions.md | ||
[promoteds]: ../destructors.md#constant-promotion |
Uh oh!
There was an error while loading. Please reload this page.