about summary refs log tree commit diff
path: root/src/libstd
diff options
context:
space:
mode:
authorGabriel Majeri <gabriel.majeri6@gmail.com>2018-09-16 12:56:44 +0300
committerGabriel Majeri <gabriel.majeri6@gmail.com>2018-09-27 20:13:33 +0300
commite0df0ae734ec97ad7cc67cf6bed0d142275571b9 (patch)
tree6939a492fc56d86f40f295005e9d4fe77fb39a96 /src/libstd
parentf5e991bee01104342ade57d8f2ea51527190c50d (diff)
downloadrust-e0df0ae734ec97ad7cc67cf6bed0d142275571b9.tar.gz
rust-e0df0ae734ec97ad7cc67cf6bed0d142275571b9.zip
Make example code use global variables
Because `fn main()` was added automatically, the variables
were actually local statics.
Diffstat (limited to 'src/libstd')
-rw-r--r--src/libstd/sync/mod.rs27
1 files changed, 14 insertions, 13 deletions
diff --git a/src/libstd/sync/mod.rs b/src/libstd/sync/mod.rs
index e06e2994069..df153561b4b 100644
--- a/src/libstd/sync/mod.rs
+++ b/src/libstd/sync/mod.rs
@@ -18,17 +18,20 @@
 //! Considering the following code, operating on some global static variables:
 //!
 //! ```rust
-//! # static mut A: u32 = 0;
-//! # static mut B: u32 = 0;
-//! # static mut C: u32 = 0;
-//! # unsafe {
-//! A = 3;
-//! B = 4;
-//! A = A + B;
-//! C = B;
-//! println!("{} {} {}", A, B, C);
-//! C = A;
-//! # }
+//! static mut A: u32 = 0;
+//! static mut B: u32 = 0;
+//! static mut C: u32 = 0;
+//!
+//! fn main() {
+//!     unsafe {
+//!         A = 3;
+//!         B = 4;
+//!         A = A + B;
+//!         C = B;
+//!         println!("{} {} {}", A, B, C);
+//!         C = A;
+//!     }
+//! }
 //! ```
 //!
 //! It appears _as if_ some variables stored in memory are changed, an addition
@@ -42,8 +45,6 @@
 //! - first store to `C` might be moved before the store to `A` or `B`,
 //!   _as if_ we had written `C = 4; A = 3; B = 4;`
 //!
-//! - last store to `C` might be removed, since we never read from it again.
-//!
 //! - assignment of `A + B` to `A` might be removed, the sum can be stored in a
 //!   in a register until it gets printed, and the global variable never gets
 //!   updated.