about summary refs log tree commit diff
path: root/src/libstd/sys/wasm
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2019-12-23 02:47:52 +0000
committerbors <bors@rust-lang.org>2019-12-23 02:47:52 +0000
commita916ac22b9f7f1f0f7aba0a41a789b3ecd765018 (patch)
tree139cba4184f0f290fdbdff1aa0aa68352b16ccbb /src/libstd/sys/wasm
parent9b98af84c4aa66392236fff59c86da2130d46d46 (diff)
parent0f24ccd21d9f734a21daaf3566900127167556d1 (diff)
downloadrust-a916ac22b9f7f1f0f7aba0a41a789b3ecd765018.tar.gz
rust-a916ac22b9f7f1f0f7aba0a41a789b3ecd765018.zip
Auto merge of #67540 - Mark-Simulacrum:fmt-the-world, r=Centril
Format the world

This PR modifies the formatting infrastructure a bit in the first commit (to enable the forgotten 2018 edition), as well as removes most directories from the ignore list in rustfmt.toml. It then follows that up with the second commit which runs `x.py fmt` and formats the entire repository.

We continue to not format the test directory (`src/test`) because of interactions with pretty printing and, in part, because re-blessing all of those files is somewhat harder to review, so is best suited for a follow up PR in my opinion.
Diffstat (limited to 'src/libstd/sys/wasm')
-rw-r--r--src/libstd/sys/wasm/alloc.rs2
-rw-r--r--src/libstd/sys/wasm/condvar.rs13
-rw-r--r--src/libstd/sys/wasm/condvar_atomics.rs2
-rw-r--r--src/libstd/sys/wasm/fast_thread_local.rs2
-rw-r--r--src/libstd/sys/wasm/mod.rs14
-rw-r--r--src/libstd/sys/wasm/mutex.rs11
-rw-r--r--src/libstd/sys/wasm/mutex_atomics.rs7
-rw-r--r--src/libstd/sys/wasm/rwlock.rs7
-rw-r--r--src/libstd/sys/wasm/rwlock_atomics.rs23
9 files changed, 30 insertions, 51 deletions
diff --git a/src/libstd/sys/wasm/alloc.rs b/src/libstd/sys/wasm/alloc.rs
index 05e55334ac0..32b8b5bdaea 100644
--- a/src/libstd/sys/wasm/alloc.rs
+++ b/src/libstd/sys/wasm/alloc.rs
@@ -58,7 +58,7 @@ mod lock {
     pub fn lock() -> DropLock {
         loop {
             if LOCKED.swap(1, SeqCst) == 0 {
-                return DropLock
+                return DropLock;
             }
             // Ok so here's where things get a little depressing. At this point
             // in time we need to synchronously acquire a lock, but we're
diff --git a/src/libstd/sys/wasm/condvar.rs b/src/libstd/sys/wasm/condvar.rs
index 9c7cc3c63b1..9fd781c7282 100644
--- a/src/libstd/sys/wasm/condvar.rs
+++ b/src/libstd/sys/wasm/condvar.rs
@@ -1,23 +1,21 @@
 use crate::sys::mutex::Mutex;
 use crate::time::Duration;
 
-pub struct Condvar { }
+pub struct Condvar {}
 
 impl Condvar {
     pub const fn new() -> Condvar {
-        Condvar { }
+        Condvar {}
     }
 
     #[inline]
     pub unsafe fn init(&mut self) {}
 
     #[inline]
-    pub unsafe fn notify_one(&self) {
-    }
+    pub unsafe fn notify_one(&self) {}
 
     #[inline]
-    pub unsafe fn notify_all(&self) {
-    }
+    pub unsafe fn notify_all(&self) {}
 
     pub unsafe fn wait(&self, _mutex: &Mutex) {
         panic!("can't block with web assembly")
@@ -28,6 +26,5 @@ impl Condvar {
     }
 
     #[inline]
-    pub unsafe fn destroy(&self) {
-    }
+    pub unsafe fn destroy(&self) {}
 }
diff --git a/src/libstd/sys/wasm/condvar_atomics.rs b/src/libstd/sys/wasm/condvar_atomics.rs
index f452bbd3487..a4021c0ee83 100644
--- a/src/libstd/sys/wasm/condvar_atomics.rs
+++ b/src/libstd/sys/wasm/condvar_atomics.rs
@@ -78,7 +78,7 @@ impl Condvar {
         // `false` as we weren't actually notified.
         let ret = wasm32::i32_atomic_wait(self.ptr(), ticket, nanos as i64) != 2;
         mutex.lock();
-        return ret
+        return ret;
     }
 
     #[inline]
diff --git a/src/libstd/sys/wasm/fast_thread_local.rs b/src/libstd/sys/wasm/fast_thread_local.rs
index 9bdc26ae7d6..85d66098302 100644
--- a/src/libstd/sys/wasm/fast_thread_local.rs
+++ b/src/libstd/sys/wasm/fast_thread_local.rs
@@ -1,6 +1,6 @@
 #![unstable(feature = "thread_local_internals", issue = "none")]
 
-pub unsafe fn register_dtor(_t: *mut u8, _dtor: unsafe extern fn(*mut u8)) {
+pub unsafe fn register_dtor(_t: *mut u8, _dtor: unsafe extern "C" fn(*mut u8)) {
     // FIXME: right now there is no concept of "thread exit", but this is likely
     // going to show up at some point in the form of an exported symbol that the
     // wasm runtime is going to be expected to call. For now we basically just
diff --git a/src/libstd/sys/wasm/mod.rs b/src/libstd/sys/wasm/mod.rs
index de0bb38dc31..c115f756450 100644
--- a/src/libstd/sys/wasm/mod.rs
+++ b/src/libstd/sys/wasm/mod.rs
@@ -20,6 +20,7 @@ pub mod alloc;
 pub mod args;
 pub mod cmath;
 pub mod env;
+pub mod fast_thread_local;
 pub mod fs;
 pub mod io;
 pub mod memchr;
@@ -29,11 +30,10 @@ pub mod path;
 pub mod pipe;
 pub mod process;
 pub mod stack_overflow;
-pub mod thread;
-pub mod time;
 pub mod stdio;
+pub mod thread;
 pub mod thread_local;
-pub mod fast_thread_local;
+pub mod time;
 
 pub use crate::sys_common::os_str_bytes as os_str;
 
@@ -53,16 +53,14 @@ cfg_if::cfg_if! {
 }
 
 #[cfg(not(test))]
-pub fn init() {
-}
+pub fn init() {}
 
 pub fn unsupported<T>() -> crate::io::Result<T> {
     Err(unsupported_err())
 }
 
 pub fn unsupported_err() -> crate::io::Error {
-    crate::io::Error::new(crate::io::ErrorKind::Other,
-                   "operation not supported on wasm yet")
+    crate::io::Error::new(crate::io::ErrorKind::Other, "operation not supported on wasm yet")
 }
 
 pub fn decode_error_kind(_code: i32) -> crate::io::ErrorKind {
@@ -80,7 +78,7 @@ pub unsafe fn strlen(mut s: *const c_char) -> usize {
         n += 1;
         s = s.offset(1);
     }
-    return n
+    return n;
 }
 
 pub unsafe fn abort_internal() -> ! {
diff --git a/src/libstd/sys/wasm/mutex.rs b/src/libstd/sys/wasm/mutex.rs
index 9d713e9b439..07238d08730 100644
--- a/src/libstd/sys/wasm/mutex.rs
+++ b/src/libstd/sys/wasm/mutex.rs
@@ -13,8 +13,7 @@ impl Mutex {
     }
 
     #[inline]
-    pub unsafe fn init(&mut self) {
-    }
+    pub unsafe fn init(&mut self) {}
 
     #[inline]
     pub unsafe fn lock(&self) {
@@ -40,18 +39,16 @@ impl Mutex {
     }
 
     #[inline]
-    pub unsafe fn destroy(&self) {
-    }
+    pub unsafe fn destroy(&self) {}
 }
 
 // All empty stubs because wasm has no threads yet, so lock acquisition always
 // succeeds.
-pub struct ReentrantMutex {
-}
+pub struct ReentrantMutex {}
 
 impl ReentrantMutex {
     pub unsafe fn uninitialized() -> ReentrantMutex {
-        ReentrantMutex { }
+        ReentrantMutex {}
     }
 
     pub unsafe fn init(&mut self) {}
diff --git a/src/libstd/sys/wasm/mutex_atomics.rs b/src/libstd/sys/wasm/mutex_atomics.rs
index cddd584dd22..90c628a19c2 100644
--- a/src/libstd/sys/wasm/mutex_atomics.rs
+++ b/src/libstd/sys/wasm/mutex_atomics.rs
@@ -1,7 +1,7 @@
 use crate::arch::wasm32;
 use crate::cell::UnsafeCell;
 use crate::mem;
-use crate::sync::atomic::{AtomicUsize, AtomicU32, Ordering::SeqCst};
+use crate::sync::atomic::{AtomicU32, AtomicUsize, Ordering::SeqCst};
 use crate::sys::thread;
 
 pub struct Mutex {
@@ -81,10 +81,7 @@ unsafe impl Sync for ReentrantMutex {}
 
 impl ReentrantMutex {
     pub unsafe fn uninitialized() -> ReentrantMutex {
-        ReentrantMutex {
-            owner: AtomicU32::new(0),
-            recursions: UnsafeCell::new(0),
-        }
+        ReentrantMutex { owner: AtomicU32::new(0), recursions: UnsafeCell::new(0) }
     }
 
     pub unsafe fn init(&mut self) {
diff --git a/src/libstd/sys/wasm/rwlock.rs b/src/libstd/sys/wasm/rwlock.rs
index a2b07c7fa1f..a59944482e9 100644
--- a/src/libstd/sys/wasm/rwlock.rs
+++ b/src/libstd/sys/wasm/rwlock.rs
@@ -9,9 +9,7 @@ unsafe impl Sync for RWLock {} // no threads on wasm
 
 impl RWLock {
     pub const fn new() -> RWLock {
-        RWLock {
-            mode: UnsafeCell::new(0),
-        }
+        RWLock { mode: UnsafeCell::new(0) }
     }
 
     #[inline]
@@ -67,6 +65,5 @@ impl RWLock {
     }
 
     #[inline]
-    pub unsafe fn destroy(&self) {
-    }
+    pub unsafe fn destroy(&self) {}
 }
diff --git a/src/libstd/sys/wasm/rwlock_atomics.rs b/src/libstd/sys/wasm/rwlock_atomics.rs
index c705568cec9..06442e925f4 100644
--- a/src/libstd/sys/wasm/rwlock_atomics.rs
+++ b/src/libstd/sys/wasm/rwlock_atomics.rs
@@ -1,6 +1,6 @@
 use crate::cell::UnsafeCell;
-use crate::sys::mutex::Mutex;
 use crate::sys::condvar::Condvar;
+use crate::sys::mutex::Mutex;
 
 pub struct RWLock {
     lock: Mutex,
@@ -27,11 +27,7 @@ unsafe impl Sync for RWLock {}
 
 impl RWLock {
     pub const fn new() -> RWLock {
-        RWLock {
-            lock: Mutex::new(),
-            cond: Condvar::new(),
-            state: UnsafeCell::new(State::Unlocked),
-        }
+        RWLock { lock: Mutex::new(), cond: Condvar::new(), state: UnsafeCell::new(State::Unlocked) }
     }
 
     #[inline]
@@ -48,7 +44,7 @@ impl RWLock {
         self.lock.lock();
         let ok = (*self.state.get()).inc_readers();
         self.lock.unlock();
-        return ok
+        return ok;
     }
 
     #[inline]
@@ -65,7 +61,7 @@ impl RWLock {
         self.lock.lock();
         let ok = (*self.state.get()).inc_writers();
         self.lock.unlock();
-        return ok
+        return ok;
     }
 
     #[inline]
@@ -106,7 +102,7 @@ impl State {
                 *cnt += 1;
                 true
             }
-            State::Writing => false
+            State::Writing => false,
         }
     }
 
@@ -116,8 +112,7 @@ impl State {
                 *self = State::Writing;
                 true
             }
-            State::Reading(_) |
-            State::Writing => false
+            State::Reading(_) | State::Writing => false,
         }
     }
 
@@ -127,8 +122,7 @@ impl State {
                 *cnt -= 1;
                 *cnt == 0
             }
-            State::Unlocked |
-            State::Writing => invalid(),
+            State::Unlocked | State::Writing => invalid(),
         };
         if zero {
             *self = State::Unlocked;
@@ -139,8 +133,7 @@ impl State {
     fn dec_writers(&mut self) {
         match *self {
             State::Writing => {}
-            State::Unlocked |
-            State::Reading(_) => invalid(),
+            State::Unlocked | State::Reading(_) => invalid(),
         }
         *self = State::Unlocked;
     }