about summary refs log tree commit diff
path: root/src/libstd/rt/backtrace.rs
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2014-10-10 21:59:10 -0700
committerAlex Crichton <alex@alexcrichton.com>2014-10-10 22:09:49 -0700
commitdae48a07f34dcf714b3b57029f4e03a0b95a269e (patch)
tree4ced3fe4c6c167508f0f7d1308473dfec676846d /src/libstd/rt/backtrace.rs
parent1add4dedc131d5f98d82feafe80d92ed1f3f6d49 (diff)
downloadrust-dae48a07f34dcf714b3b57029f4e03a0b95a269e.tar.gz
rust-dae48a07f34dcf714b3b57029f4e03a0b95a269e.zip
Register new snapshots
Also convert a number of `static mut` to just a plain old `static` and remove
some unsafe blocks.
Diffstat (limited to 'src/libstd/rt/backtrace.rs')
-rw-r--r--src/libstd/rt/backtrace.rs20
1 files changed, 9 insertions, 11 deletions
diff --git a/src/libstd/rt/backtrace.rs b/src/libstd/rt/backtrace.rs
index 6cbbc0af390..e05e533be56 100644
--- a/src/libstd/rt/backtrace.rs
+++ b/src/libstd/rt/backtrace.rs
@@ -28,20 +28,18 @@ pub use self::imp::write;
 // For now logging is turned off by default, and this function checks to see
 // whether the magical environment variable is present to see if it's turned on.
 pub fn log_enabled() -> bool {
-    static mut ENABLED: atomic::AtomicInt = atomic::INIT_ATOMIC_INT;
-    unsafe {
-        match ENABLED.load(atomic::SeqCst) {
-            1 => return false,
-            2 => return true,
-            _ => {}
-        }
+    static ENABLED: atomic::AtomicInt = atomic::INIT_ATOMIC_INT;
+    match ENABLED.load(atomic::SeqCst) {
+        1 => return false,
+        2 => return true,
+        _ => {}
     }
 
     let val = match os::getenv("RUST_BACKTRACE") {
         Some(..) => 2,
         None => 1,
     };
-    unsafe { ENABLED.store(val, atomic::SeqCst); }
+    ENABLED.store(val, atomic::SeqCst);
     val == 2
 }
 
@@ -268,7 +266,7 @@ mod imp {
         // while it doesn't requires lock for work as everything is
         // local, it still displays much nicer backtraces when a
         // couple of tasks fail simultaneously
-        static mut LOCK: StaticNativeMutex = NATIVE_MUTEX_INIT;
+        static LOCK: StaticNativeMutex = NATIVE_MUTEX_INIT;
         let _g = unsafe { LOCK.lock() };
 
         try!(writeln!(w, "stack backtrace:"));
@@ -301,7 +299,7 @@ mod imp {
         // is semi-reasonable in terms of printing anyway, and we know that all
         // I/O done here is blocking I/O, not green I/O, so we don't have to
         // worry about this being a native vs green mutex.
-        static mut LOCK: StaticNativeMutex = NATIVE_MUTEX_INIT;
+        static LOCK: StaticNativeMutex = NATIVE_MUTEX_INIT;
         let _g = unsafe { LOCK.lock() };
 
         try!(writeln!(w, "stack backtrace:"));
@@ -931,7 +929,7 @@ mod imp {
     pub fn write(w: &mut Writer) -> IoResult<()> {
         // According to windows documentation, all dbghelp functions are
         // single-threaded.
-        static mut LOCK: StaticNativeMutex = NATIVE_MUTEX_INIT;
+        static LOCK: StaticNativeMutex = NATIVE_MUTEX_INIT;
         let _g = unsafe { LOCK.lock() };
 
         // Open up dbghelp.dll, we don't link to it explicitly because it can't