about summary refs log tree commit diff
path: root/src/libstd/sys/wasm
diff options
context:
space:
mode:
authorDavid Tolnay <dtolnay@gmail.com>2019-11-27 10:28:39 -0800
committerDavid Tolnay <dtolnay@gmail.com>2019-11-29 18:37:58 -0800
commitc34fbfaad38cf5829ef5cfe780dc9d58480adeaa (patch)
treee57b66ed06aec18dc13ff7f14a243ca3dc3c27d1 /src/libstd/sys/wasm
parent9081929d45f12d3f56d43b1d6db7519981580fc9 (diff)
downloadrust-c34fbfaad38cf5829ef5cfe780dc9d58480adeaa.tar.gz
rust-c34fbfaad38cf5829ef5cfe780dc9d58480adeaa.zip
Format libstd/sys with rustfmt
This commit applies rustfmt with rust-lang/rust's default settings to
files in src/libstd/sys *that are not involved in any currently open PR*
to minimize merge conflicts. THe list of files involved in open PRs was
determined by querying GitHub's GraphQL API with this script:
https://gist.github.com/dtolnay/aa9c34993dc051a4f344d1b10e4487e8

With the list of files from the script in outstanding_files, the
relevant commands were:

    $ find src/libstd/sys -name '*.rs' \
        | xargs rustfmt --edition=2018 --unstable-features --skip-children
    $ rg libstd/sys outstanding_files | xargs git checkout --

Repeating this process several months apart should get us coverage of
most of the rest of the files.

To confirm no funny business:

    $ git checkout $THIS_COMMIT^
    $ git show --pretty= --name-only $THIS_COMMIT \
        | xargs rustfmt --edition=2018 --unstable-features --skip-children
    $ git diff $THIS_COMMIT  # there should be no difference
Diffstat (limited to 'src/libstd/sys/wasm')
-rw-r--r--src/libstd/sys/wasm/args.rs8
-rw-r--r--src/libstd/sys/wasm/cmath.rs2
-rw-r--r--src/libstd/sys/wasm/fs.rs28
-rw-r--r--src/libstd/sys/wasm/net.rs21
-rw-r--r--src/libstd/sys/wasm/os.rs6
-rw-r--r--src/libstd/sys/wasm/path.rs2
-rw-r--r--src/libstd/sys/wasm/pipe.rs5
-rw-r--r--src/libstd/sys/wasm/process.rs29
-rw-r--r--src/libstd/sys/wasm/stack_overflow.rs6
-rw-r--r--src/libstd/sys/wasm/thread.rs16
-rw-r--r--src/libstd/sys/wasm/thread_local.rs2
-rw-r--r--src/libstd/sys/wasm/time.rs3
12 files changed, 54 insertions, 74 deletions
diff --git a/src/libstd/sys/wasm/args.rs b/src/libstd/sys/wasm/args.rs
index 8279e5280e9..3b6557ae325 100644
--- a/src/libstd/sys/wasm/args.rs
+++ b/src/libstd/sys/wasm/args.rs
@@ -6,14 +6,10 @@ pub unsafe fn init(_argc: isize, _argv: *const *const u8) {
     // On wasm these should always be null, so there's nothing for us to do here
 }
 
-pub unsafe fn cleanup() {
-}
+pub unsafe fn cleanup() {}
 
 pub fn args() -> Args {
-    Args {
-        iter: Vec::new().into_iter(),
-        _dont_send_or_sync_me: PhantomData,
-    }
+    Args { iter: Vec::new().into_iter(), _dont_send_or_sync_me: PhantomData }
 }
 
 pub struct Args {
diff --git a/src/libstd/sys/wasm/cmath.rs b/src/libstd/sys/wasm/cmath.rs
index fa7783122c2..304cf906b2a 100644
--- a/src/libstd/sys/wasm/cmath.rs
+++ b/src/libstd/sys/wasm/cmath.rs
@@ -1,5 +1,5 @@
 // These symbols are all defined in `compiler-builtins`
-extern {
+extern "C" {
     pub fn acos(n: f64) -> f64;
     pub fn acosf(n: f32) -> f32;
     pub fn asin(n: f64) -> f64;
diff --git a/src/libstd/sys/wasm/fs.rs b/src/libstd/sys/wasm/fs.rs
index e9095b375fe..e6160d1457d 100644
--- a/src/libstd/sys/wasm/fs.rs
+++ b/src/libstd/sys/wasm/fs.rs
@@ -1,7 +1,7 @@
 use crate::ffi::OsString;
 use crate::fmt;
 use crate::hash::{Hash, Hasher};
-use crate::io::{self, SeekFrom, IoSlice, IoSliceMut};
+use crate::io::{self, IoSlice, IoSliceMut, SeekFrom};
 use crate::path::{Path, PathBuf};
 use crate::sys::time::SystemTime;
 use crate::sys::{unsupported, Void};
@@ -15,14 +15,14 @@ pub struct ReadDir(Void);
 pub struct DirEntry(Void);
 
 #[derive(Clone, Debug)]
-pub struct OpenOptions { }
+pub struct OpenOptions {}
 
 pub struct FilePermissions(Void);
 
 pub struct FileType(Void);
 
 #[derive(Debug)]
-pub struct DirBuilder { }
+pub struct DirBuilder {}
 
 impl FileAttr {
     pub fn size(&self) -> u64 {
@@ -78,8 +78,7 @@ impl PartialEq for FilePermissions {
     }
 }
 
-impl Eq for FilePermissions {
-}
+impl Eq for FilePermissions {}
 
 impl fmt::Debug for FilePermissions {
     fn fmt(&self, _f: &mut fmt::Formatter<'_>) -> fmt::Result {
@@ -115,8 +114,7 @@ impl PartialEq for FileType {
     }
 }
 
-impl Eq for FileType {
-}
+impl Eq for FileType {}
 
 impl Hash for FileType {
     fn hash<H: Hasher>(&self, _h: &mut H) {
@@ -164,15 +162,15 @@ impl DirEntry {
 
 impl OpenOptions {
     pub fn new() -> OpenOptions {
-        OpenOptions { }
+        OpenOptions {}
     }
 
-    pub fn read(&mut self, _read: bool) { }
-    pub fn write(&mut self, _write: bool) { }
-    pub fn append(&mut self, _append: bool) { }
-    pub fn truncate(&mut self, _truncate: bool) { }
-    pub fn create(&mut self, _create: bool) { }
-    pub fn create_new(&mut self, _create_new: bool) { }
+    pub fn read(&mut self, _read: bool) {}
+    pub fn write(&mut self, _write: bool) {}
+    pub fn append(&mut self, _append: bool) {}
+    pub fn truncate(&mut self, _truncate: bool) {}
+    pub fn create(&mut self, _create: bool) {}
+    pub fn create_new(&mut self, _create_new: bool) {}
 }
 
 impl File {
@@ -235,7 +233,7 @@ impl File {
 
 impl DirBuilder {
     pub fn new() -> DirBuilder {
-        DirBuilder { }
+        DirBuilder {}
     }
 
     pub fn mkdir(&self, _p: &Path) -> io::Result<()> {
diff --git a/src/libstd/sys/wasm/net.rs b/src/libstd/sys/wasm/net.rs
index d50f989d2bb..b7c3108f172 100644
--- a/src/libstd/sys/wasm/net.rs
+++ b/src/libstd/sys/wasm/net.rs
@@ -1,9 +1,9 @@
+use crate::convert::TryFrom;
 use crate::fmt;
 use crate::io::{self, IoSlice, IoSliceMut};
-use crate::net::{SocketAddr, Shutdown, Ipv4Addr, Ipv6Addr};
-use crate::time::Duration;
+use crate::net::{Ipv4Addr, Ipv6Addr, Shutdown, SocketAddr};
 use crate::sys::{unsupported, Void};
-use crate::convert::TryFrom;
+use crate::time::Duration;
 
 pub struct TcpStream(Void);
 
@@ -228,23 +228,19 @@ impl UdpSocket {
         match self.0 {}
     }
 
-    pub fn join_multicast_v4(&self, _: &Ipv4Addr, _: &Ipv4Addr)
-                         -> io::Result<()> {
+    pub fn join_multicast_v4(&self, _: &Ipv4Addr, _: &Ipv4Addr) -> io::Result<()> {
         match self.0 {}
     }
 
-    pub fn join_multicast_v6(&self, _: &Ipv6Addr, _: u32)
-                         -> io::Result<()> {
+    pub fn join_multicast_v6(&self, _: &Ipv6Addr, _: u32) -> io::Result<()> {
         match self.0 {}
     }
 
-    pub fn leave_multicast_v4(&self, _: &Ipv4Addr, _: &Ipv4Addr)
-                          -> io::Result<()> {
+    pub fn leave_multicast_v4(&self, _: &Ipv4Addr, _: &Ipv4Addr) -> io::Result<()> {
         match self.0 {}
     }
 
-    pub fn leave_multicast_v6(&self, _: &Ipv6Addr, _: u32)
-                          -> io::Result<()> {
+    pub fn leave_multicast_v6(&self, _: &Ipv6Addr, _: u32) -> io::Result<()> {
         match self.0 {}
     }
 
@@ -351,8 +347,7 @@ pub mod netc {
     }
 
     #[derive(Copy, Clone)]
-    pub struct sockaddr {
-    }
+    pub struct sockaddr {}
 
     pub type socklen_t = usize;
 }
diff --git a/src/libstd/sys/wasm/os.rs b/src/libstd/sys/wasm/os.rs
index 890049e8bfa..193c3892743 100644
--- a/src/libstd/sys/wasm/os.rs
+++ b/src/libstd/sys/wasm/os.rs
@@ -1,5 +1,5 @@
 use crate::error::Error as StdError;
-use crate::ffi::{OsString, OsStr};
+use crate::ffi::{OsStr, OsString};
 use crate::fmt;
 use crate::io;
 use crate::path::{self, PathBuf};
@@ -39,7 +39,9 @@ impl<'a> Iterator for SplitPaths<'a> {
 pub struct JoinPathsError;
 
 pub fn join_paths<I, T>(_paths: I) -> Result<OsString, JoinPathsError>
-    where I: Iterator<Item=T>, T: AsRef<OsStr>
+where
+    I: Iterator<Item = T>,
+    T: AsRef<OsStr>,
 {
     Err(JoinPathsError)
 }
diff --git a/src/libstd/sys/wasm/path.rs b/src/libstd/sys/wasm/path.rs
index 7a183956107..840a7ae0426 100644
--- a/src/libstd/sys/wasm/path.rs
+++ b/src/libstd/sys/wasm/path.rs
@@ -1,5 +1,5 @@
-use crate::path::Prefix;
 use crate::ffi::OsStr;
+use crate::path::Prefix;
 
 #[inline]
 pub fn is_sep_byte(b: u8) -> bool {
diff --git a/src/libstd/sys/wasm/pipe.rs b/src/libstd/sys/wasm/pipe.rs
index 9f07f054362..fb14dc59101 100644
--- a/src/libstd/sys/wasm/pipe.rs
+++ b/src/libstd/sys/wasm/pipe.rs
@@ -25,9 +25,6 @@ impl AnonPipe {
     }
 }
 
-pub fn read2(p1: AnonPipe,
-             _v1: &mut Vec<u8>,
-             _p2: AnonPipe,
-             _v2: &mut Vec<u8>) -> io::Result<()> {
+pub fn read2(p1: AnonPipe, _v1: &mut Vec<u8>, _p2: AnonPipe, _v2: &mut Vec<u8>) -> io::Result<()> {
     match p1.0 {}
 }
diff --git a/src/libstd/sys/wasm/process.rs b/src/libstd/sys/wasm/process.rs
index edf933d10e0..4702e5c5492 100644
--- a/src/libstd/sys/wasm/process.rs
+++ b/src/libstd/sys/wasm/process.rs
@@ -32,32 +32,28 @@ pub enum Stdio {
 
 impl Command {
     pub fn new(_program: &OsStr) -> Command {
-        Command {
-            env: Default::default()
-        }
+        Command { env: Default::default() }
     }
 
-    pub fn arg(&mut self, _arg: &OsStr) {
-    }
+    pub fn arg(&mut self, _arg: &OsStr) {}
 
     pub fn env_mut(&mut self) -> &mut CommandEnv {
         &mut self.env
     }
 
-    pub fn cwd(&mut self, _dir: &OsStr) {
-    }
+    pub fn cwd(&mut self, _dir: &OsStr) {}
 
-    pub fn stdin(&mut self, _stdin: Stdio) {
-    }
+    pub fn stdin(&mut self, _stdin: Stdio) {}
 
-    pub fn stdout(&mut self, _stdout: Stdio) {
-    }
+    pub fn stdout(&mut self, _stdout: Stdio) {}
 
-    pub fn stderr(&mut self, _stderr: Stdio) {
-    }
+    pub fn stderr(&mut self, _stderr: Stdio) {}
 
-    pub fn spawn(&mut self, _default: Stdio, _needs_stdin: bool)
-        -> io::Result<(Process, StdioPipes)> {
+    pub fn spawn(
+        &mut self,
+        _default: Stdio,
+        _needs_stdin: bool,
+    ) -> io::Result<(Process, StdioPipes)> {
         unsupported()
     }
 }
@@ -106,8 +102,7 @@ impl PartialEq for ExitStatus {
     }
 }
 
-impl Eq for ExitStatus {
-}
+impl Eq for ExitStatus {}
 
 impl fmt::Debug for ExitStatus {
     fn fmt(&self, _f: &mut fmt::Formatter<'_>) -> fmt::Result {
diff --git a/src/libstd/sys/wasm/stack_overflow.rs b/src/libstd/sys/wasm/stack_overflow.rs
index c0e7c824615..cbf62b6e5b7 100644
--- a/src/libstd/sys/wasm/stack_overflow.rs
+++ b/src/libstd/sys/wasm/stack_overflow.rs
@@ -6,8 +6,6 @@ impl Handler {
     }
 }
 
-pub unsafe fn init() {
-}
+pub unsafe fn init() {}
 
-pub unsafe fn cleanup() {
-}
+pub unsafe fn cleanup() {}
diff --git a/src/libstd/sys/wasm/thread.rs b/src/libstd/sys/wasm/thread.rs
index d06965f3278..0e0e78a8276 100644
--- a/src/libstd/sys/wasm/thread.rs
+++ b/src/libstd/sys/wasm/thread.rs
@@ -9,9 +9,7 @@ pub const DEFAULT_MIN_STACK_SIZE: usize = 4096;
 
 impl Thread {
     // unsafe: see thread::Builder::spawn_unchecked for safety requirements
-    pub unsafe fn new(_stack: usize, _p: Box<dyn FnOnce()>)
-        -> io::Result<Thread>
-    {
+    pub unsafe fn new(_stack: usize, _p: Box<dyn FnOnce()>) -> io::Result<Thread> {
         unsupported()
     }
 
@@ -55,8 +53,12 @@ impl Thread {
 
 pub mod guard {
     pub type Guard = !;
-    pub unsafe fn current() -> Option<Guard> { None }
-    pub unsafe fn init() -> Option<Guard> { None }
+    pub unsafe fn current() -> Option<Guard> {
+        None
+    }
+    pub unsafe fn init() -> Option<Guard> {
+        None
+    }
 }
 
 // This is only used by atomics primitives when the `atomics` feature is
@@ -84,9 +86,7 @@ pub fn my_id() -> u32 {
         if MY_ID == 0 {
             let mut cur = NEXT_ID.load(SeqCst);
             MY_ID = loop {
-                let next = cur.checked_add(1).unwrap_or_else(|| {
-                    crate::arch::wasm32::unreachable()
-                });
+                let next = cur.checked_add(1).unwrap_or_else(|| crate::arch::wasm32::unreachable());
                 match NEXT_ID.compare_exchange(cur, next, SeqCst, SeqCst) {
                     Ok(_) => break next,
                     Err(i) => cur = i,
diff --git a/src/libstd/sys/wasm/thread_local.rs b/src/libstd/sys/wasm/thread_local.rs
index 8a0ca6f3d25..f8be9863ed5 100644
--- a/src/libstd/sys/wasm/thread_local.rs
+++ b/src/libstd/sys/wasm/thread_local.rs
@@ -1,7 +1,7 @@
 pub type Key = usize;
 
 #[inline]
-pub unsafe fn create(_dtor: Option<unsafe extern fn(*mut u8)>) -> Key {
+pub unsafe fn create(_dtor: Option<unsafe extern "C" fn(*mut u8)>) -> Key {
     panic!("should not be used on the wasm target");
 }
 
diff --git a/src/libstd/sys/wasm/time.rs b/src/libstd/sys/wasm/time.rs
index dd9ad3760b0..d9edc7fdc44 100644
--- a/src/libstd/sys/wasm/time.rs
+++ b/src/libstd/sys/wasm/time.rs
@@ -39,8 +39,7 @@ impl SystemTime {
         panic!("time not implemented on wasm32-unknown-unknown")
     }
 
-    pub fn sub_time(&self, other: &SystemTime)
-                    -> Result<Duration, Duration> {
+    pub fn sub_time(&self, other: &SystemTime) -> Result<Duration, Duration> {
         self.0.checked_sub(other.0).ok_or_else(|| other.0 - self.0)
     }