-
Notifications
You must be signed in to change notification settings - Fork 559
isolate non-mut static part from static-item section #760
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
base: master
Are you sure you want to change the base?
Changes from all 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 | ||||
|---|---|---|---|---|---|---|
|
|
@@ -8,12 +8,16 @@ | |||||
| 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. Static items have the `static` lifetime, which outlives all | ||||||
| other lifetimes in a Rust program. Non-`mut` static items that contain a type | ||||||
| other lifetimes in a Rust program. | ||||||
|
|
||||||
| ## Non-mut statics | ||||||
|
|
||||||
| Non-`mut` static items that contain a type | ||||||
| that is not [interior mutable] may be placed in read-only memory. Static items | ||||||
| do not call [`drop`] at the end of the program. | ||||||
|
|
||||||
| All access to a static is safe, but there are a number of restrictions on | ||||||
| statics: | ||||||
| All access to a Non-`mut` static is safe, but there are a number of restrictions on | ||||||
|
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.
Suggested change
|
||||||
| Non-`mut` statics: | ||||||
|
Comment on lines
+19
to
+20
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. Not all these rules seem to apply to non- Also, this sentence (the original) seems to be a very strong assertion (all access?). I'm not up to speed on safety issues, so maybe @Centril could validate what should be safe, or if this wording makes sense. 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. Yeah this diff seems to remove rules about cc @RalfJung and @eddyb on the access thing, but notably, a 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. I mean you can access a non- "all access" is slightly misleading though; writing to a (This might also be a good place to call out that mutating a non- 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.
Suggested change
|
||||||
|
|
||||||
| * The type must have the `Sync` trait bound to allow thread-safe access. | ||||||
| * Statics allow using paths to statics in the [constant expression] used to | ||||||
|
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like it could use some more re-arranging. The sentence about
dropshould probably be moved up since it applies to both mut and non-mut, correct?