Clarify that static variables are not synonymous with global variables - #4825
Open
seven7763 wants to merge 1 commit into
Open
Clarify that static variables are not synonymous with global variables#4825seven7763 wants to merge 1 commit into
seven7763 wants to merge 1 commit into
Conversation
"In Rust, global variables are called _static_ variables" implies global == static, but a static item is about the 'static lifetime of the binding, not its scope: static items may be declared at module scope or inside a function. Fixes rust-lang#4819
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #4819.
Section 20.1 said "In Rust, global variables are called static variables", which reads as global == static. A
staticitem is defined by its'staticlifetime, not by its scope: per the Reference, static items may be declared at module scope or inside a function. This rewords the paragraph to make that distinction while keeping the section's flow into Listing 20-10.Changes
src/ch20-01-unsafe-rust.md: reworded one paragraph (3 lines) in the "Accessing or Modifying a Mutable Static Variable" section.Validation
dprint check src/ch20-01-unsafe-rust.md— the two reported regions (lines ~337-343, ~493+) also fail on unmodifiedmain; they are pre-existing and outside this change's lines (~390-400).Notes
Kept the change minimal — no restructuring of the section, just the incorrect equivalence.