]> git.lizzy.rs Git - rust.git/commitdiff
Register new snapshots
authorAlex Crichton <alex@alexcrichton.com>
Sat, 11 Oct 2014 04:59:10 +0000 (21:59 -0700)
committerAlex Crichton <alex@alexcrichton.com>
Sat, 11 Oct 2014 05:09:49 +0000 (22:09 -0700)
Also convert a number of `static mut` to just a plain old `static` and remove
some unsafe blocks.

36 files changed:
src/libcollections/string.rs
src/libcollections/trie.rs
src/libcollections/vec.rs
src/libcore/intrinsics.rs
src/libcore/ops.rs
src/libcore/slice.rs
src/libcore/str.rs
src/libcoretest/atomic.rs
src/libgreen/lib.rs
src/libgreen/sched.rs
src/libgreen/stack.rs
src/liblog/lib.rs
src/libnative/io/helper_thread.rs
src/libnative/io/net.rs
src/libnative/io/process.rs
src/libnative/io/timer_unix.rs
src/libnative/io/timer_windows.rs
src/librustc/back/write.rs
src/librustc/middle/trans/base.rs
src/librustrt/args.rs
src/librustrt/at_exit_imp.rs
src/librustrt/bookkeeping.rs
src/librustrt/mutex.rs
src/librustrt/unwind.rs
src/libstd/dynamic_lib.rs
src/libstd/io/tempfile.rs
src/libstd/io/test.rs
src/libstd/os.rs
src/libstd/rt/backtrace.rs
src/libstd/rt/util.rs
src/libsync/atomic.rs
src/libsync/deque.rs
src/libsync/mutex.rs
src/libsync/one.rs
src/libtime/lib.rs
src/snapshots.txt

index 900cf9dfb44e45a121a040e2534e2008122e9cca..848068f20c2d85529eb3933431a8183f8062b73d 100644 (file)
@@ -928,29 +928,6 @@ fn add(&self, other: &S) -> String {
     }
 }
 
-#[cfg(stage0)]
-impl ops::Slice<uint, str> for String {
-    #[inline]
-    fn as_slice_<'a>(&'a self) -> &'a str {
-        self.as_slice()
-    }
-
-    #[inline]
-    fn slice_from_<'a>(&'a self, from: &uint) -> &'a str {
-        self[][*from..]
-    }
-
-    #[inline]
-    fn slice_to_<'a>(&'a self, to: &uint) -> &'a str {
-        self[][..*to]
-    }
-
-    #[inline]
-    fn slice_<'a>(&'a self, from: &uint, to: &uint) -> &'a str {
-        self[][*from..*to]
-    }
-}
-#[cfg(not(stage0))]
 impl ops::Slice<uint, str> for String {
     #[inline]
     fn as_slice_<'a>(&'a self) -> &'a str {
index fe8ced7f2aaafe29645f95182a54e4443b3640e2..a022a1bc89016981cbb140aa2e5eabd4eda4903f 100644 (file)
@@ -389,15 +389,6 @@ macro_rules! bound {
 
 impl<T> TrieMap<T> {
     // If `upper` is true then returns upper_bound else returns lower_bound.
-    #[cfg(stage0)]
-    #[inline]
-    fn bound<'a>(&'a self, key: uint, upper: bool) -> Entries<'a, T> {
-        bound!(Entries, self = self,
-               key = key, is_upper = upper,
-               slice_from = slice_from_, iter = iter,
-               mutability = )
-    }
-    #[cfg(not(stage0))]
     #[inline]
     fn bound<'a>(&'a self, key: uint, upper: bool) -> Entries<'a, T> {
         bound!(Entries, self = self,
@@ -440,15 +431,6 @@ pub fn upper_bound<'a>(&'a self, key: uint) -> Entries<'a, T> {
         self.bound(key, true)
     }
     // If `upper` is true then returns upper_bound else returns lower_bound.
-    #[cfg(stage0)]
-    #[inline]
-    fn bound_mut<'a>(&'a mut self, key: uint, upper: bool) -> MutEntries<'a, T> {
-        bound!(MutEntries, self = self,
-               key = key, is_upper = upper,
-               slice_from = slice_from_mut_, iter = iter_mut,
-               mutability = mut)
-    }
-    #[cfg(not(stage0))]
     #[inline]
     fn bound_mut<'a>(&'a mut self, key: uint, upper: bool) -> MutEntries<'a, T> {
         bound!(MutEntries, self = self,
index a82856c013d647d7a600bbc4669b9b2320a3786b..0933bcb8ab82b140ad4b97f09208b72fc690dc12 100644 (file)
@@ -461,28 +461,6 @@ fn index_mut<'a>(&'a mut self, index: &uint) -> &'a mut T {
     }
 }*/
 
-#[cfg(stage0)]
-impl<T> ops::Slice<uint, [T]> for Vec<T> {
-    #[inline]
-    fn as_slice_<'a>(&'a self) -> &'a [T] {
-        self.as_slice()
-    }
-
-    #[inline]
-    fn slice_from_<'a>(&'a self, start: &uint) -> &'a [T] {
-        self.as_slice().slice_from_(start)
-    }
-
-    #[inline]
-    fn slice_to_<'a>(&'a self, end: &uint) -> &'a [T] {
-        self.as_slice().slice_to_(end)
-    }
-    #[inline]
-    fn slice_<'a>(&'a self, start: &uint, end: &uint) -> &'a [T] {
-        self.as_slice().slice_(start, end)
-    }
-}
-#[cfg(not(stage0))]
 impl<T> ops::Slice<uint, [T]> for Vec<T> {
     #[inline]
     fn as_slice_<'a>(&'a self) -> &'a [T] {
@@ -504,28 +482,6 @@ fn slice_or_fail<'a>(&'a self, start: &uint, end: &uint) -> &'a [T] {
     }
 }
 
-#[cfg(stage0)]
-impl<T> ops::SliceMut<uint, [T]> for Vec<T> {
-    #[inline]
-    fn as_mut_slice_<'a>(&'a mut self) -> &'a mut [T] {
-        self.as_mut_slice()
-    }
-
-    #[inline]
-    fn slice_from_mut_<'a>(&'a mut self, start: &uint) -> &'a mut [T] {
-        self.as_mut_slice().slice_from_mut_(start)
-    }
-
-    #[inline]
-    fn slice_to_mut_<'a>(&'a mut self, end: &uint) -> &'a mut [T] {
-        self.as_mut_slice().slice_to_mut_(end)
-    }
-    #[inline]
-    fn slice_mut_<'a>(&'a mut self, start: &uint, end: &uint) -> &'a mut [T] {
-        self.as_mut_slice().slice_mut_(start, end)
-    }
-}
-#[cfg(not(stage0))]
 impl<T> ops::SliceMut<uint, [T]> for Vec<T> {
     #[inline]
     fn as_mut_slice_<'a>(&'a mut self) -> &'a mut [T] {
index 7d86b65168f3cdc2763cb5bc6a785196ee6bcd86..3f7dcb36cf6982d864e43a42f76e9782f7206a36 100644 (file)
@@ -254,7 +254,6 @@ fn visit_leave_fn(&mut self, purity: uint, proto: uint,
     /// enabling further optimizations.
     ///
     /// NB: This is very different from the `unreachable!()` macro!
-    #[cfg(not(stage0))]
     pub fn unreachable() -> !;
 
     /// Execute a breakpoint trap, for inspection by a debugger.
index b08432c773e61a48bcf0e060c58b136d37f6e2ed..f7cfa4c1bafee5c7ccfc474379ff2a358c29f48a 100644 (file)
@@ -711,7 +711,6 @@ pub trait IndexMut<Index, Result> {
  * }
  * ```
  */
-#[cfg(not(stage0))]
 #[lang="slice"]
 pub trait Slice<Idx, Sized? Result> for Sized? {
     /// The method for the slicing operation foo[]
@@ -723,21 +722,6 @@ pub trait Slice<Idx, Sized? Result> for Sized? {
     /// The method for the slicing operation foo[from..to]
     fn slice_or_fail<'a>(&'a self, from: &Idx, to: &Idx) -> &'a Result;
 }
-#[cfg(stage0)]
-/**
- *
- */
-#[lang="slice"]
-pub trait Slice<Idx, Sized? Result> for Sized? {
-    /// The method for the slicing operation foo[]
-    fn as_slice_<'a>(&'a self) -> &'a Result;
-    /// The method for the slicing operation foo[from..]
-    fn slice_from_<'a>(&'a self, from: &Idx) -> &'a Result;
-    /// The method for the slicing operation foo[..to]
-    fn slice_to_<'a>(&'a self, to: &Idx) -> &'a Result;
-    /// The method for the slicing operation foo[from..to]
-    fn slice_<'a>(&'a self, from: &Idx, to: &Idx) -> &'a Result;
-}
 
 /**
  *
@@ -776,7 +760,6 @@ pub trait Slice<Idx, Sized? Result> for Sized? {
  * }
  * ```
  */
-#[cfg(not(stage0))]
 #[lang="slice_mut"]
 pub trait SliceMut<Idx, Sized? Result> for Sized? {
     /// The method for the slicing operation foo[]
@@ -788,21 +771,7 @@ pub trait SliceMut<Idx, Sized? Result> for Sized? {
     /// The method for the slicing operation foo[from..to]
     fn slice_or_fail_mut<'a>(&'a mut self, from: &Idx, to: &Idx) -> &'a mut Result;
 }
-#[cfg(stage0)]
-/**
- *
- */
-#[lang="slice_mut"]
-pub trait SliceMut<Idx, Sized? Result> for Sized? {
-    /// The method for the slicing operation foo[mut]
-    fn as_mut_slice_<'a>(&'a mut self) -> &'a mut Result;
-    /// The method for the slicing operation foo[mut from..]
-    fn slice_from_mut_<'a>(&'a mut self, from: &Idx) -> &'a mut Result;
-    /// The method for the slicing operation foo[mut ..to]
-    fn slice_to_mut_<'a>(&'a mut self, to: &Idx) -> &'a mut Result;
-    /// The method for the slicing operation foo[mut from..to]
-    fn slice_mut_<'a>(&'a mut self, from: &Idx, to: &Idx) -> &'a mut Result;
-}
+
 /**
  *
  * The `Deref` trait is used to specify the functionality of dereferencing
index 02c0c9bf31069a1ae76e95baaa789844584e87c9..5847a6177d7296d031a2cd2ac30fb0f871876545 100644 (file)
@@ -488,7 +488,6 @@ fn pop_ref(&mut self) -> Option<&'a T> {
 
 
 
-#[cfg(not(stage0))]
 impl<T> ops::Slice<uint, [T]> for [T] {
     #[inline]
     fn as_slice_<'a>(&'a self) -> &'a [T] {
@@ -516,36 +515,7 @@ fn slice_or_fail<'a>(&'a self, start: &uint, end: &uint) -> &'a [T] {
         }
     }
 }
-#[cfg(stage0)]
-impl<T> ops::Slice<uint, [T]> for [T] {
-    #[inline]
-    fn as_slice_<'a>(&'a self) -> &'a [T] {
-        self
-    }
-
-    #[inline]
-    fn slice_from_<'a>(&'a self, start: &uint) -> &'a [T] {
-        self.slice_(start, &self.len())
-    }
 
-    #[inline]
-    fn slice_to_<'a>(&'a self, end: &uint) -> &'a [T] {
-        self.slice_(&0, end)
-    }
-    #[inline]
-    fn slice_<'a>(&'a self, start: &uint, end: &uint) -> &'a [T] {
-        assert!(*start <= *end);
-        assert!(*end <= self.len());
-        unsafe {
-            transmute(RawSlice {
-                    data: self.as_ptr().offset(*start as int),
-                    len: (*end - *start)
-                })
-        }
-    }
-}
-
-#[cfg(not(stage0))]
 impl<T> ops::SliceMut<uint, [T]> for [T] {
     #[inline]
     fn as_mut_slice_<'a>(&'a mut self) -> &'a mut [T] {
@@ -574,35 +544,6 @@ fn slice_or_fail_mut<'a>(&'a mut self, start: &uint, end: &uint) -> &'a mut [T]
         }
     }
 }
-#[cfg(stage0)]
-impl<T> ops::SliceMut<uint, [T]> for [T] {
-    #[inline]
-    fn as_mut_slice_<'a>(&'a mut self) -> &'a mut [T] {
-        self
-    }
-
-    #[inline]
-    fn slice_from_mut_<'a>(&'a mut self, start: &uint) -> &'a mut [T] {
-        let len = &self.len();
-        self.slice_mut_(start, len)
-    }
-
-    #[inline]
-    fn slice_to_mut_<'a>(&'a mut self, end: &uint) -> &'a mut [T] {
-        self.slice_mut_(&0, end)
-    }
-    #[inline]
-    fn slice_mut_<'a>(&'a mut self, start: &uint, end: &uint) -> &'a mut [T] {
-        assert!(*start <= *end);
-        assert!(*end <= self.len());
-        unsafe {
-            transmute(RawSlice {
-                    data: self.as_ptr().offset(*start as int),
-                    len: (*end - *start)
-                })
-        }
-    }
-}
 
 /// Extension methods for slices such that their elements are
 /// mutable.
index 1cbe955274b65995ac281a960f948d2993be8aab..e8cd93ba7dc4248c5e513bd338fb4fb6ee1fe68a 100644 (file)
@@ -1164,29 +1164,6 @@ impl<'a, S: Str> Equiv<S> for &'a str {
         fn equiv(&self, other: &S) -> bool { eq_slice(*self, other.as_slice()) }
     }
 
-    #[cfg(stage0)]
-    impl ops::Slice<uint, str> for str {
-        #[inline]
-        fn as_slice_<'a>(&'a self) -> &'a str {
-            self
-        }
-
-        #[inline]
-        fn slice_from_<'a>(&'a self, from: &uint) -> &'a str {
-            self.slice_from(*from)
-        }
-
-        #[inline]
-        fn slice_to_<'a>(&'a self, to: &uint) -> &'a str {
-            self.slice_to(*to)
-        }
-
-        #[inline]
-        fn slice_<'a>(&'a self, from: &uint, to: &uint) -> &'a str {
-            self.slice(*from, *to)
-        }
-    }
-    #[cfg(not(stage0))]
     impl ops::Slice<uint, str> for str {
         #[inline]
         fn as_slice_<'a>(&'a self) -> &'a str {
index e8fae3fa6df65394f2117fa41edd58e09cc23b25..ab9c7ab9f11da115e3e71cc15cdad0402ef1a2ba 100644 (file)
@@ -69,15 +69,13 @@ fn int_xor() {
     assert_eq!(x.load(SeqCst), 0xf731 ^ 0x137f);
 }
 
-static mut S_BOOL : AtomicBool = INIT_ATOMIC_BOOL;
-static mut S_INT  : AtomicInt  = INIT_ATOMIC_INT;
-static mut S_UINT : AtomicUint = INIT_ATOMIC_UINT;
+static S_BOOL : AtomicBool = INIT_ATOMIC_BOOL;
+static S_INT  : AtomicInt  = INIT_ATOMIC_INT;
+static S_UINT : AtomicUint = INIT_ATOMIC_UINT;
 
 #[test]
 fn static_init() {
-    unsafe {
-        assert!(!S_BOOL.load(SeqCst));
-        assert!(S_INT.load(SeqCst) == 0);
-        assert!(S_UINT.load(SeqCst) == 0);
-    }
+    assert!(!S_BOOL.load(SeqCst));
+    assert!(S_INT.load(SeqCst) == 0);
+    assert!(S_UINT.load(SeqCst) == 0);
 }
index 8eee7ed845fece990ec35a2e70e776e767bd3c5c..5435a6f74d38bc33ef54a42663b5a09e415b56e4 100644 (file)
@@ -335,7 +335,7 @@ impl SchedPool {
     /// This will configure the pool according to the `config` parameter, and
     /// initially run `main` inside the pool of schedulers.
     pub fn new(config: PoolConfig) -> SchedPool {
-        static mut POOL_ID: AtomicUint = INIT_ATOMIC_UINT;
+        static POOL_ID: AtomicUint = INIT_ATOMIC_UINT;
 
         let PoolConfig {
             threads: nscheds,
@@ -349,7 +349,7 @@ pub fn new(config: PoolConfig) -> SchedPool {
             threads: vec![],
             handles: vec![],
             stealers: vec![],
-            id: unsafe { POOL_ID.fetch_add(1, SeqCst) },
+            id: POOL_ID.fetch_add(1, SeqCst),
             sleepers: SleeperList::new(),
             stack_pool: StackPool::new(),
             deque_pool: deque::BufferPool::new(),
index feb381e4a21b4bc381b99f057b2586fe902d5963..f36a43c3c291e95eb38357c20bc0832d4908ec5a 100644 (file)
@@ -1458,7 +1458,7 @@ fn single_threaded_yield() {
     #[test]
     fn test_spawn_sched_blocking() {
         use std::rt::mutex::{StaticNativeMutex, NATIVE_MUTEX_INIT};
-        static mut LOCK: StaticNativeMutex = NATIVE_MUTEX_INIT;
+        static LOCK: StaticNativeMutex = NATIVE_MUTEX_INIT;
 
         // Testing that a task in one scheduler can block in foreign code
         // without affecting other schedulers
index 23b41f6c6e75bc2a8c2d1c83a1d5b140d1caae0a..6a5772ff6282a5c764f0a3a92695ff9337591fd4 100644 (file)
@@ -158,8 +158,8 @@ pub fn give_stack(&mut self, stack: Stack) {
 }
 
 fn max_cached_stacks() -> uint {
-    static mut AMT: atomic::AtomicUint = atomic::INIT_ATOMIC_UINT;
-    match unsafe { AMT.load(atomic::SeqCst) } {
+    static AMT: atomic::AtomicUint = atomic::INIT_ATOMIC_UINT;
+    match AMT.load(atomic::SeqCst) {
         0 => {}
         n => return n - 1,
     }
@@ -169,7 +169,7 @@ fn max_cached_stacks() -> uint {
     let amt = amt.unwrap_or(10);
     // 0 is our sentinel value, so ensure that we'll never see 0 after
     // initialization has run
-    unsafe { AMT.store(amt + 1, atomic::SeqCst); }
+    AMT.store(amt + 1, atomic::SeqCst);
     return amt;
 }
 
index b08ad3b6c61740cd3a237d1ff905cb32e8a21657..9d5080522c26ea9bf3f27328c6740235d966f6d1 100644 (file)
@@ -348,8 +348,8 @@ pub struct LogLocation {
 /// module's log statement should be emitted or not.
 #[doc(hidden)]
 pub fn mod_enabled(level: u32, module: &str) -> bool {
-    static mut INIT: Once = ONCE_INIT;
-    unsafe { INIT.doit(init); }
+    static INIT: Once = ONCE_INIT;
+    INIT.doit(init);
 
     // It's possible for many threads are in this function, only one of them
     // will perform the global initialization, but all of them will need to check
index 1f51f8eacd634afefa06ab8db42a9d61dafe3dfe..8aff1732a41fcc11387fe083c2e24c57257903c4 100644 (file)
@@ -55,8 +55,8 @@ pub struct Helper<M> {
     pub initialized: UnsafeCell<bool>,
 }
 
-macro_rules! helper_init( (static mut $name:ident: Helper<$m:ty>) => (
-    static mut $name: Helper<$m> = Helper {
+macro_rules! helper_init( (static $name:ident: Helper<$m:ty>) => (
+    static $name: Helper<$m> = Helper {
         lock: ::std::rt::mutex::NATIVE_MUTEX_INIT,
         chan: ::std::cell::UnsafeCell { value: 0 as *mut Sender<$m> },
         signal: ::std::cell::UnsafeCell { value: 0 },
index aa2b1a6f14e6bd39773bca8c4fa5119e714c16fa..a4b97a3eb84efef282a2c12e0fb8cc734e5c5a52 100644 (file)
@@ -1063,7 +1063,7 @@ pub fn init() {
         unsafe {
             use std::rt::mutex::{StaticNativeMutex, NATIVE_MUTEX_INIT};
             static mut INITIALIZED: bool = false;
-            static mut LOCK: StaticNativeMutex = NATIVE_MUTEX_INIT;
+            static LOCK: StaticNativeMutex = NATIVE_MUTEX_INIT;
 
             let _guard = LOCK.lock();
             if !INITIALIZED {
index 7a0c1c35d65c86aad3856b5a5362d0974f03e39d..2ca25f1eeb91656248f3d2add8131288b8ad4246 100644 (file)
@@ -28,7 +28,7 @@
 #[cfg(unix)] use io::helper_thread::Helper;
 
 #[cfg(unix)]
-helper_init!(static mut HELPER: Helper<Req>)
+helper_init!(static HELPER: Helper<Req>)
 
 /**
  * A value representing a child process.
@@ -988,7 +988,7 @@ fn waitpid(pid: pid_t, deadline: u64) -> IoResult<rtio::ProcessExit> {
     // The actual communication between the helper thread and this thread is
     // quite simple, just a channel moving data around.
 
-    unsafe { HELPER.boot(register_sigchld, waitpid_helper) }
+    HELPER.boot(register_sigchld, waitpid_helper);
 
     match waitpid_nowait(pid) {
         Some(ret) => return Ok(ret),
@@ -996,7 +996,7 @@ fn waitpid(pid: pid_t, deadline: u64) -> IoResult<rtio::ProcessExit> {
     }
 
     let (tx, rx) = channel();
-    unsafe { HELPER.send(NewChild(pid, tx, deadline)); }
+    HELPER.send(NewChild(pid, tx, deadline));
     return match rx.recv_opt() {
         Ok(e) => Ok(e),
         Err(()) => Err(util::timeout("wait timed out")),
index 8c6fd83a76bad265967f78ebcdf1909d3950adec..4d4ba33aec45f6ee0d71542e48fc5c7a2d1ddf78 100644 (file)
@@ -59,7 +59,7 @@
 use io::file::FileDesc;
 use io::helper_thread::Helper;
 
-helper_init!(static mut HELPER: Helper<Req>)
+helper_init!(static HELPER: Helper<Req>)
 
 pub struct Timer {
     id: uint,
@@ -204,10 +204,10 @@ impl Timer {
     pub fn new() -> IoResult<Timer> {
         // See notes above regarding using int return value
         // instead of ()
-        unsafe { HELPER.boot(|| {}, helper); }
+        HELPER.boot(|| {}, helper);
 
-        static mut ID: atomic::AtomicUint = atomic::INIT_ATOMIC_UINT;
-        let id = unsafe { ID.fetch_add(1, atomic::Relaxed) };
+        static ID: atomic::AtomicUint = atomic::INIT_ATOMIC_UINT;
+        let id = ID.fetch_add(1, atomic::Relaxed);
         Ok(Timer {
             id: id,
             inner: Some(box Inner {
@@ -237,7 +237,7 @@ fn inner(&mut self) -> Box<Inner> {
             Some(i) => i,
             None => {
                 let (tx, rx) = channel();
-                unsafe { HELPER.send(RemoveTimer(self.id, tx)); }
+                HELPER.send(RemoveTimer(self.id, tx));
                 rx.recv()
             }
         }
@@ -262,7 +262,7 @@ fn oneshot(&mut self, msecs: u64, cb: Box<rtio::Callback + Send>) {
         inner.interval = msecs;
         inner.target = now + msecs;
 
-        unsafe { HELPER.send(NewTimer(inner)); }
+        HELPER.send(NewTimer(inner));
     }
 
     fn period(&mut self, msecs: u64, cb: Box<rtio::Callback + Send>) {
@@ -274,7 +274,7 @@ fn period(&mut self, msecs: u64, cb: Box<rtio::Callback + Send>) {
         inner.interval = msecs;
         inner.target = now + msecs;
 
-        unsafe { HELPER.send(NewTimer(inner)); }
+        HELPER.send(NewTimer(inner));
     }
 }
 
index 82d318111727f1714d34527fb9e71aa9ce586678..421cc28e157b1ae4dd06558ca10379706ca66854 100644 (file)
@@ -28,7 +28,7 @@
 
 use io::helper_thread::Helper;
 
-helper_init!(static mut HELPER: Helper<Req>)
+helper_init!(static HELPER: Helper<Req>)
 
 pub struct Timer {
     obj: libc::HANDLE,
@@ -104,7 +104,7 @@ pub fn now() -> u64 {
 
 impl Timer {
     pub fn new() -> IoResult<Timer> {
-        unsafe { HELPER.boot(|| {}, helper) }
+        HELPER.boot(|| {}, helper);
 
         let obj = unsafe {
             imp::CreateWaitableTimerA(ptr::null_mut(), 0, ptr::null())
@@ -126,7 +126,7 @@ fn remove(&mut self) {
         if !self.on_worker { return }
 
         let (tx, rx) = channel();
-        unsafe { HELPER.send(RemoveTimer(self.obj, tx)) }
+        HELPER.send(RemoveTimer(self.obj, tx));
         rx.recv();
 
         self.on_worker = false;
@@ -158,7 +158,7 @@ fn oneshot(&mut self, msecs: u64, cb: Box<Callback + Send>) {
                                   ptr::null_mut(), 0)
         }, 1);
 
-        unsafe { HELPER.send(NewTimer(self.obj, cb, true)) }
+        HELPER.send(NewTimer(self.obj, cb, true));
         self.on_worker = true;
     }
 
@@ -172,7 +172,7 @@ fn period(&mut self, msecs: u64, cb: Box<Callback + Send>) {
                                   ptr::null_mut(), ptr::null_mut(), 0)
         }, 1);
 
-        unsafe { HELPER.send(NewTimer(self.obj, cb, false)) }
+        HELPER.send(NewTimer(self.obj, cb, false));
         self.on_worker = true;
     }
 }
index 7b4d1780ccd690fb072fcd600e29fb6103df936f..603f5ed227cdf8e0621701cb6d4d100d0f06abdc 100644 (file)
@@ -936,7 +936,7 @@ pub fn run_assembler(sess: &Session, outputs: &OutputFilenames) {
 
 unsafe fn configure_llvm(sess: &Session) {
     use std::sync::{Once, ONCE_INIT};
-    static mut INIT: Once = ONCE_INIT;
+    static INIT: Once = ONCE_INIT;
 
     // Copy what clang does by turning on loop vectorization at O2 and
     // slp vectorization at O3
index 692017b67501136ef95c795f31980de8b94ed184..1a1b2b9d2575e40435c13c75a715f6064842ac1b 100644 (file)
@@ -3035,7 +3035,7 @@ pub fn trans_crate<'tcx>(analysis: CrateAnalysis<'tcx>)
     // Before we touch LLVM, make sure that multithreading is enabled.
     unsafe {
         use std::sync::{Once, ONCE_INIT};
-        static mut INIT: Once = ONCE_INIT;
+        static INIT: Once = ONCE_INIT;
         static mut POISONED: bool = false;
         INIT.doit(|| {
             if llvm::LLVMStartMultithreaded() != 1 {
index bd63886baeeda176a95558d77445a7046e474d1e..9b1dd7a82549448f955eb231aecdba1ab0c4fcd3 100644 (file)
@@ -54,8 +54,8 @@ mod imp {
 
     use mutex::{StaticNativeMutex, NATIVE_MUTEX_INIT};
 
-    static mut global_args_ptr: uint = 0;
-    static mut lock: StaticNativeMutex = NATIVE_MUTEX_INIT;
+    static mut GLOBAL_ARGS_PTR: uint = 0;
+    static LOCK: StaticNativeMutex = NATIVE_MUTEX_INIT;
 
     pub unsafe fn init(argc: int, argv: *const *const u8) {
         let args = load_argc_and_argv(argc, argv);
@@ -64,7 +64,7 @@ pub unsafe fn init(argc: int, argv: *const *const u8) {
 
     pub unsafe fn cleanup() {
         rtassert!(take().is_some());
-        lock.destroy();
+        LOCK.destroy();
     }
 
     pub fn take() -> Option<Vec<Vec<u8>>> {
@@ -92,13 +92,13 @@ pub fn clone() -> Option<Vec<Vec<u8>>> {
 
     fn with_lock<T>(f: || -> T) -> T {
         unsafe {
-            let _guard = lock.lock();
+            let _guard = LOCK.lock();
             f()
         }
     }
 
     fn get_global_ptr() -> *mut Option<Box<Vec<Vec<u8>>>> {
-        unsafe { mem::transmute(&global_args_ptr) }
+        unsafe { mem::transmute(&GLOBAL_ARGS_PTR) }
     }
 
     unsafe fn load_argc_and_argv(argc: int, argv: *const *const u8) -> Vec<Vec<u8>> {
index 8854c33b169f2a15f4d5522f8f3ac7068b3fe39a..c54afb241aebbc48d1b61e24c455b0ba58c17dd9 100644 (file)
@@ -24,8 +24,8 @@
 
 type Queue = Exclusive<Vec<proc():Send>>;
 
-static mut QUEUE: atomic::AtomicUint = atomic::INIT_ATOMIC_UINT;
-static mut RUNNING: atomic::AtomicBool = atomic::INIT_ATOMIC_BOOL;
+static QUEUE: atomic::AtomicUint = atomic::INIT_ATOMIC_UINT;
+static RUNNING: atomic::AtomicBool = atomic::INIT_ATOMIC_BOOL;
 
 pub fn init() {
     let state: Box<Queue> = box Exclusive::new(Vec::new());
index a88bc86828f82eeff793f89e149dfaf1924daf78..714bbd569bdbc7c279aaf6483d9df91fe84ce425 100644 (file)
@@ -23,8 +23,8 @@
 
 use mutex::{StaticNativeMutex, NATIVE_MUTEX_INIT};
 
-static mut TASK_COUNT: atomic::AtomicUint = atomic::INIT_ATOMIC_UINT;
-static mut TASK_LOCK: StaticNativeMutex = NATIVE_MUTEX_INIT;
+static TASK_COUNT: atomic::AtomicUint = atomic::INIT_ATOMIC_UINT;
+static TASK_LOCK: StaticNativeMutex = NATIVE_MUTEX_INIT;
 
 pub struct Token { _private: () }
 
@@ -35,7 +35,7 @@ fn drop(&mut self) { decrement() }
 /// Increment the number of live tasks, returning a token which will decrement
 /// the count when dropped.
 pub fn increment() -> Token {
-    let _ = unsafe { TASK_COUNT.fetch_add(1, atomic::SeqCst) };
+    let _ = TASK_COUNT.fetch_add(1, atomic::SeqCst);
     Token { _private: () }
 }
 
index bd47874d6472058665d46d5c71cd386d44c28044..7d4fb2f5c529e41b1478a7ec355da341f02c7ba0 100644 (file)
@@ -36,7 +36,7 @@
 //! use std::rt::mutex::{NativeMutex, StaticNativeMutex, NATIVE_MUTEX_INIT};
 //!
 //! // Use a statically initialized mutex
-//! static mut LOCK: StaticNativeMutex = NATIVE_MUTEX_INIT;
+//! static LOCK: StaticNativeMutex = NATIVE_MUTEX_INIT;
 //!
 //! unsafe {
 //!     let _guard = LOCK.lock();
@@ -109,7 +109,7 @@ pub unsafe fn new() -> StaticNativeMutex {
     ///
     /// ```rust
     /// use std::rt::mutex::{StaticNativeMutex, NATIVE_MUTEX_INIT};
-    /// static mut LOCK: StaticNativeMutex = NATIVE_MUTEX_INIT;
+    /// static LOCK: StaticNativeMutex = NATIVE_MUTEX_INIT;
     /// unsafe {
     ///     let _guard = LOCK.lock();
     ///     // critical section...
@@ -655,7 +655,7 @@ mod test {
 
     #[test]
     fn smoke_lock() {
-        static mut lock: StaticNativeMutex = NATIVE_MUTEX_INIT;
+        static lock: StaticNativeMutex = NATIVE_MUTEX_INIT;
         unsafe {
             let _guard = lock.lock();
         }
@@ -663,7 +663,7 @@ fn smoke_lock() {
 
     #[test]
     fn smoke_cond() {
-        static mut lock: StaticNativeMutex = NATIVE_MUTEX_INIT;
+        static lock: StaticNativeMutex = NATIVE_MUTEX_INIT;
         unsafe {
             let guard = lock.lock();
             let t = Thread::start(proc() {
@@ -679,7 +679,7 @@ fn smoke_cond() {
 
     #[test]
     fn smoke_lock_noguard() {
-        static mut lock: StaticNativeMutex = NATIVE_MUTEX_INIT;
+        static lock: StaticNativeMutex = NATIVE_MUTEX_INIT;
         unsafe {
             lock.lock_noguard();
             lock.unlock_noguard();
@@ -688,7 +688,7 @@ fn smoke_lock_noguard() {
 
     #[test]
     fn smoke_cond_noguard() {
-        static mut lock: StaticNativeMutex = NATIVE_MUTEX_INIT;
+        static lock: StaticNativeMutex = NATIVE_MUTEX_INIT;
         unsafe {
             lock.lock_noguard();
             let t = Thread::start(proc() {
index 2a2fa29eca0b29bd4ead1b4c96e3d3f2a1b08487..9483beca1c39d781878413f1da5d92ffba88d776 100644 (file)
@@ -92,7 +92,7 @@ struct Exception {
 //
 // For more information, see below.
 const MAX_CALLBACKS: uint = 16;
-static mut CALLBACKS: [atomic::AtomicUint, ..MAX_CALLBACKS] =
+static CALLBACKS: [atomic::AtomicUint, ..MAX_CALLBACKS] =
         [atomic::INIT_ATOMIC_UINT, atomic::INIT_ATOMIC_UINT,
          atomic::INIT_ATOMIC_UINT, atomic::INIT_ATOMIC_UINT,
          atomic::INIT_ATOMIC_UINT, atomic::INIT_ATOMIC_UINT,
@@ -101,7 +101,7 @@ struct Exception {
          atomic::INIT_ATOMIC_UINT, atomic::INIT_ATOMIC_UINT,
          atomic::INIT_ATOMIC_UINT, atomic::INIT_ATOMIC_UINT,
          atomic::INIT_ATOMIC_UINT, atomic::INIT_ATOMIC_UINT];
-static mut CALLBACK_CNT: atomic::AtomicUint = atomic::INIT_ATOMIC_UINT;
+static CALLBACK_CNT: atomic::AtomicUint = atomic::INIT_ATOMIC_UINT;
 
 impl Unwinder {
     pub fn new() -> Unwinder {
@@ -560,7 +560,7 @@ fn begin_unwind_inner(msg: Box<Any + Send>, file_line: &(&'static str, uint)) ->
     // so we just chalk it up to a race condition and move on to the next
     // callback. Additionally, CALLBACK_CNT may briefly be higher than
     // MAX_CALLBACKS, so we're sure to clamp it as necessary.
-    let callbacks = unsafe {
+    let callbacks = {
         let amt = CALLBACK_CNT.load(atomic::SeqCst);
         CALLBACKS[..cmp::min(amt, MAX_CALLBACKS)]
     };
index 5cd0b3010c5a18e721f69df5dcfa6c74532a1853..bc71f8ae7900cf4415e397573887d2523302e32a 100644 (file)
@@ -230,11 +230,11 @@ pub unsafe fn open_internal() -> *mut u8 {
 
     pub fn check_for_errors_in<T>(f: || -> T) -> Result<T, String> {
         use rt::mutex::{StaticNativeMutex, NATIVE_MUTEX_INIT};
-        static mut lock: StaticNativeMutex = NATIVE_MUTEX_INIT;
+        static LOCK: StaticNativeMutex = NATIVE_MUTEX_INIT;
         unsafe {
             // dlerror isn't thread safe, so we need to lock around this entire
             // sequence
-            let _guard = lock.lock();
+            let _guard = LOCK.lock();
             let _old_error = dlerror();
 
             let result = f();
index 1d8aedb172bae39d19673ee9b1977a9759de1cc7..e9d6ef2e341306dc17f63e257031c389622c67b7 100644 (file)
@@ -38,14 +38,14 @@ pub fn new_in(tmpdir: &Path, suffix: &str) -> IoResult<TempDir> {
             return TempDir::new_in(&os::make_absolute(tmpdir), suffix);
         }
 
-        static mut CNT: atomic::AtomicUint = atomic::INIT_ATOMIC_UINT;
+        static CNT: atomic::AtomicUint = atomic::INIT_ATOMIC_UINT;
 
         let mut attempts = 0u;
         loop {
             let filename =
                 format!("rs-{}-{}-{}",
                         unsafe { libc::getpid() },
-                        unsafe { CNT.fetch_add(1, atomic::SeqCst) },
+                        CNT.fetch_add(1, atomic::SeqCst),
                         suffix);
             let p = tmpdir.join(filename);
             match fs::mkdir(&p, io::USER_RWX) {
index 1a47e20f5858083964fa85265a4d100185be21ec..9b4333a6d8298753892921cb5cedc9d33971dc90 100644 (file)
 
 /// Get a port number, starting at 9600, for use in tests
 pub fn next_test_port() -> u16 {
-    static mut next_offset: AtomicUint = INIT_ATOMIC_UINT;
-    unsafe {
-        base_port() + next_offset.fetch_add(1, Relaxed) as u16
-    }
+    static NEXT_OFFSET: AtomicUint = INIT_ATOMIC_UINT;
+    base_port() + NEXT_OFFSET.fetch_add(1, Relaxed) as u16
 }
 
 /// Get a temporary path which could be the location of a unix socket
 pub fn next_test_unix() -> Path {
-    static mut COUNT: AtomicUint = INIT_ATOMIC_UINT;
+    static COUNT: AtomicUint = INIT_ATOMIC_UINT;
     // base port and pid are an attempt to be unique between multiple
     // test-runners of different configurations running on one
     // buildbot, the count is to be unique within this executable.
     let string = format!("rust-test-unix-path-{}-{}-{}",
                          base_port(),
                          unsafe {libc::getpid()},
-                         unsafe {COUNT.fetch_add(1, Relaxed)});
+                         COUNT.fetch_add(1, Relaxed));
     if cfg!(unix) {
         os::tmpdir().join(string)
     } else {
index 60386ec0631b7bf2e161390e49250e0cf510c2e0..03eca5c728b0555e7d382e796cac8c190e45bf65 100644 (file)
@@ -192,10 +192,10 @@ pub fn fill_utf16_buf_and_decode(f: |*mut u16, DWORD| -> DWORD)
 fn with_env_lock<T>(f: || -> T) -> T {
     use rt::mutex::{StaticNativeMutex, NATIVE_MUTEX_INIT};
 
-    static mut lock: StaticNativeMutex = NATIVE_MUTEX_INIT;
+    static LOCK: StaticNativeMutex = NATIVE_MUTEX_INIT;
 
     unsafe {
-        let _guard = lock.lock();
+        let _guard = LOCK.lock();
         f()
     }
 }
@@ -1073,7 +1073,7 @@ pub fn last_os_error() -> String {
     error_string(errno() as uint)
 }
 
-static mut EXIT_STATUS: AtomicInt = INIT_ATOMIC_INT;
+static EXIT_STATUS: AtomicInt = INIT_ATOMIC_INT;
 
 /**
  * Sets the process exit code
@@ -1086,13 +1086,13 @@ pub fn last_os_error() -> String {
  * Note that this is not synchronized against modifications of other threads.
  */
 pub fn set_exit_status(code: int) {
-    unsafe { EXIT_STATUS.store(code, SeqCst) }
+    EXIT_STATUS.store(code, SeqCst)
 }
 
 /// Fetches the process's current exit code. This defaults to 0 and can change
 /// by calling `set_exit_status`.
 pub fn get_exit_status() -> int {
-    unsafe { EXIT_STATUS.load(SeqCst) }
+    EXIT_STATUS.load(SeqCst)
 }
 
 #[cfg(target_os = "macos")]
index 6cbbc0af3909e4e7ea9afefcc91b934466ab9ddf..e05e533be56c572aaa5931fe36049b07c9471a97 100644 (file)
 // 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 @@ fn backtrace(buf: *mut *mut libc::c_void,
         // 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 @@ struct Context<'a> {
         // 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 @@ impl Drop for Cleanup {
     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
index ed24ed2a569c754564316a0255811129b75ddfab..ec301369804ed78f30d4286e548440a489470521 100644 (file)
@@ -41,8 +41,8 @@ pub fn limit_thread_creation_due_to_osx_and_valgrind() -> bool {
 }
 
 pub fn min_stack() -> uint {
-    static mut MIN: atomic::AtomicUint = atomic::INIT_ATOMIC_UINT;
-    match unsafe { MIN.load(atomic::SeqCst) } {
+    static MIN: atomic::AtomicUint = atomic::INIT_ATOMIC_UINT;
+    match MIN.load(atomic::SeqCst) {
         0 => {}
         n => return n - 1,
     }
@@ -50,7 +50,7 @@ pub fn min_stack() -> uint {
     let amt = amt.unwrap_or(2 * 1024 * 1024);
     // 0 is our sentinel value, so ensure that we'll never see 0 after
     // initialization has run
-    unsafe { MIN.store(amt + 1, atomic::SeqCst); }
+    MIN.store(amt + 1, atomic::SeqCst);
     return amt;
 }
 
index cd7102a756a4dc0359e8a5329a20aa8776ba01ee..e853e44d6f9b5776e245f557b20ce0133317e553 100644 (file)
 //! ```
 //! use std::sync::atomic::{AtomicUint, SeqCst, INIT_ATOMIC_UINT};
 //!
-//! static mut GLOBAL_TASK_COUNT: AtomicUint = INIT_ATOMIC_UINT;
+//! static GLOBAL_TASK_COUNT: AtomicUint = INIT_ATOMIC_UINT;
 //!
-//! unsafe {
-//!     let old_task_count = GLOBAL_TASK_COUNT.fetch_add(1, SeqCst);
-//!     println!("live tasks: {}", old_task_count + 1);
-//! }
+//! let old_task_count = GLOBAL_TASK_COUNT.fetch_add(1, SeqCst);
+//! println!("live tasks: {}", old_task_count + 1);
 //! ```
 
 #![allow(deprecated)]
index 15c0c14b28a86d587f75d2c48c9550f2d944237f..33881629329803706774956030f72b2699166f13 100644 (file)
@@ -545,8 +545,8 @@ fn many_stampede() {
     fn stress() {
         static AMT: int = 100000;
         static NTHREADS: int = 8;
-        static mut DONE: AtomicBool = INIT_ATOMIC_BOOL;
-        static mut HITS: AtomicUint = INIT_ATOMIC_UINT;
+        static DONE: AtomicBool = INIT_ATOMIC_BOOL;
+        static HITS: AtomicUint = INIT_ATOMIC_UINT;
         let pool = BufferPool::<int>::new();
         let (w, s) = pool.deque();
 
@@ -604,7 +604,7 @@ fn stress() {
     fn no_starvation() {
         static AMT: int = 10000;
         static NTHREADS: int = 4;
-        static mut DONE: AtomicBool = INIT_ATOMIC_BOOL;
+        static DONE: AtomicBool = INIT_ATOMIC_BOOL;
         let pool = BufferPool::<(int, uint)>::new();
         let (w, s) = pool.deque();
 
index c6413d0d09cc724a3d0235624494d32ced2a30cb..9861d27c8cdf5fa6ccba7f1e8d457cfdb399210f 100644 (file)
@@ -127,9 +127,9 @@ enum Flavor {
 /// ```rust
 /// use sync::mutex::{StaticMutex, MUTEX_INIT};
 ///
-/// static mut LOCK: StaticMutex = MUTEX_INIT;
+/// static LOCK: StaticMutex = MUTEX_INIT;
 ///
-/// unsafe {
+/// {
 ///     let _g = LOCK.lock();
 ///     // do some productive work
 /// }
@@ -536,7 +536,7 @@ fn smoke() {
 
     #[test]
     fn smoke_static() {
-        static mut m: StaticMutex = MUTEX_INIT;
+        static m: StaticMutex = MUTEX_INIT;
         unsafe {
             drop(m.lock());
             drop(m.lock());
@@ -546,7 +546,7 @@ fn smoke_static() {
 
     #[test]
     fn lots_and_lots() {
-        static mut m: StaticMutex = MUTEX_INIT;
+        static m: StaticMutex = MUTEX_INIT;
         static mut CNT: uint = 0;
         static M: uint = 1000;
         static N: uint = 3;
index c740c4f3d2e95f2076cd896c23a52ddbb763bffd..f0c72780be10a12b866509b59c831e4032623b20 100644 (file)
 /// ```rust
 /// use sync::one::{Once, ONCE_INIT};
 ///
-/// static mut START: Once = ONCE_INIT;
+/// static START: Once = ONCE_INIT;
 ///
-/// unsafe {
-///     START.doit(|| {
-///         // run initialization here
-///     });
-/// }
+/// START.doit(|| {
+///     // run initialization here
+/// });
 /// ```
 pub struct Once {
     mutex: StaticMutex,
@@ -128,17 +126,17 @@ mod test {
 
     #[test]
     fn smoke_once() {
-        static mut o: Once = ONCE_INIT;
+        static o: Once = ONCE_INIT;
         let mut a = 0i;
-        unsafe { o.doit(|| a += 1); }
+        o.doit(|| a += 1);
         assert_eq!(a, 1);
-        unsafe { o.doit(|| a += 1); }
+        o.doit(|| a += 1);
         assert_eq!(a, 1);
     }
 
     #[test]
     fn stampede_once() {
-        static mut o: Once = ONCE_INIT;
+        static o: Once = ONCE_INIT;
         static mut run: bool = false;
 
         let (tx, rx) = channel();
index b94885290b3a40e98e6c8d707356624d53bcde1c..1e051bc1558f1b309bf3e7ceac79795e84b94110 100644 (file)
@@ -192,7 +192,7 @@ fn os_precise_time_ns() -> u64 {
     fn os_precise_time_ns() -> u64 {
         static mut TIMEBASE: libc::mach_timebase_info = libc::mach_timebase_info { numer: 0,
                                                                                    denom: 0 };
-        static mut ONCE: std::sync::Once = std::sync::ONCE_INIT;
+        static ONCE: std::sync::Once = std::sync::ONCE_INIT;
         unsafe {
             ONCE.doit(|| {
                 imp::mach_timebase_info(&mut TIMEBASE);
index ab5b6b280dc871f2c11f0adf85602b34184af3a8..4d88fd6a03164e8c2cb81880651b0771650e5c93 100644 (file)
@@ -1,3 +1,12 @@
+S 2014-10-10 78a7676
+  freebsd-x86_64 511061af382e2e837a6d615823e1a952e8281483
+  linux-i386 0644637db852db8a6c603ded0531ccaa60291bd3
+  linux-x86_64 656b8c23fbb97794e85973aca725a4b9cd07b29e
+  macos-i386 e4d9709fcfe485fcca00f0aa1fe456e2f164ed96
+  macos-x86_64 6b1aa5a441965da87961be81950e8663eadba377
+  winnt-i386 b87f8f040adb464e9f8455a37de8582e9e2c8cf3
+  winnt-x86_64 b883264902ac0585a80175ba27dc141f5c4f8618
+
 S 2014-10-04 749ff5e
   freebsd-x86_64 f39d94487d29b3d48217b1295ad2cda8c941e694
   linux-i386 555aca74f9a268f80cab2df1147dc6406403e9e4