about summary refs log tree commit diff
path: root/src/libstd/sys/wasi
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/wasi
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/wasi')
-rw-r--r--src/libstd/sys/wasi/alloc.rs2
-rw-r--r--src/libstd/sys/wasi/ext/mod.rs18
-rw-r--r--src/libstd/sys/wasi/net.rs55
-rw-r--r--src/libstd/sys/wasi/os.rs42
-rw-r--r--src/libstd/sys/wasi/path.rs2
-rw-r--r--src/libstd/sys/wasi/pipe.rs5
-rw-r--r--src/libstd/sys/wasi/process.rs31
7 files changed, 63 insertions, 92 deletions
diff --git a/src/libstd/sys/wasi/alloc.rs b/src/libstd/sys/wasi/alloc.rs
index c8529937bbd..e9760d050e1 100644
--- a/src/libstd/sys/wasi/alloc.rs
+++ b/src/libstd/sys/wasi/alloc.rs
@@ -1,6 +1,6 @@
 use crate::alloc::{GlobalAlloc, Layout, System};
 use crate::ptr;
-use crate::sys_common::alloc::{MIN_ALIGN, realloc_fallback};
+use crate::sys_common::alloc::{realloc_fallback, MIN_ALIGN};
 use libc;
 
 #[stable(feature = "alloc_system_type", since = "1.28.0")]
diff --git a/src/libstd/sys/wasi/ext/mod.rs b/src/libstd/sys/wasi/ext/mod.rs
index 1c24b244b8c..5f8b1cbfa0b 100644
--- a/src/libstd/sys/wasi/ext/mod.rs
+++ b/src/libstd/sys/wasi/ext/mod.rs
@@ -7,12 +7,16 @@ pub mod io;
 /// Includes all extension traits, and some important type definitions.
 #[stable(feature = "rust1", since = "1.0.0")]
 pub mod prelude {
-    #[doc(no_inline)] #[stable(feature = "rust1", since = "1.0.0")]
-    pub use crate::sys::ext::ffi::{OsStringExt, OsStrExt};
-    #[doc(no_inline)] #[stable(feature = "rust1", since = "1.0.0")]
-    pub use crate::sys::ext::fs::{FileExt, DirEntryExt, MetadataExt, OpenOptionsExt};
-    #[doc(no_inline)] #[stable(feature = "rust1", since = "1.0.0")]
+    #[doc(no_inline)]
+    #[stable(feature = "rust1", since = "1.0.0")]
+    pub use crate::sys::ext::ffi::{OsStrExt, OsStringExt};
+    #[doc(no_inline)]
+    #[stable(feature = "rust1", since = "1.0.0")]
     pub use crate::sys::ext::fs::FileTypeExt;
-    #[doc(no_inline)] #[stable(feature = "rust1", since = "1.0.0")]
-    pub use crate::sys::ext::io::{AsRawFd, IntoRawFd, FromRawFd};
+    #[doc(no_inline)]
+    #[stable(feature = "rust1", since = "1.0.0")]
+    pub use crate::sys::ext::fs::{DirEntryExt, FileExt, MetadataExt, OpenOptionsExt};
+    #[doc(no_inline)]
+    #[stable(feature = "rust1", since = "1.0.0")]
+    pub use crate::sys::ext::io::{AsRawFd, FromRawFd, IntoRawFd};
 }
diff --git a/src/libstd/sys/wasi/net.rs b/src/libstd/sys/wasi/net.rs
index 80f633a8e1f..8a69028ff1d 100644
--- a/src/libstd/sys/wasi/net.rs
+++ b/src/libstd/sys/wasi/net.rs
@@ -1,11 +1,11 @@
+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::fd::WasiFd;
 use crate::sys::{unsupported, Void};
-use crate::convert::TryFrom;
-use crate::sys::fd::{WasiFd};
 use crate::sys_common::FromInner;
+use crate::time::Duration;
 
 pub struct TcpStream {
     fd: WasiFd,
@@ -107,24 +107,18 @@ impl TcpStream {
 
 impl FromInner<u32> for TcpStream {
     fn from_inner(fd: u32) -> TcpStream {
-        unsafe {
-            TcpStream {
-                fd: WasiFd::from_raw(fd),
-            }
-        }
+        unsafe { TcpStream { fd: WasiFd::from_raw(fd) } }
     }
 }
 
 impl fmt::Debug for TcpStream {
     fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
-        f.debug_struct("TcpStream")
-            .field("fd", &self.fd.as_raw())
-            .finish()
+        f.debug_struct("TcpStream").field("fd", &self.fd.as_raw()).finish()
     }
 }
 
 pub struct TcpListener {
-    fd: WasiFd
+    fd: WasiFd,
 }
 
 impl TcpListener {
@@ -179,19 +173,13 @@ impl TcpListener {
 
 impl FromInner<u32> for TcpListener {
     fn from_inner(fd: u32) -> TcpListener {
-        unsafe {
-            TcpListener {
-                fd: WasiFd::from_raw(fd),
-            }
-        }
+        unsafe { TcpListener { fd: WasiFd::from_raw(fd) } }
     }
 }
 
 impl fmt::Debug for TcpListener {
     fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
-        f.debug_struct("TcpListener")
-            .field("fd", &self.fd.as_raw())
-            .finish()
+        f.debug_struct("TcpListener").field("fd", &self.fd.as_raw()).finish()
     }
 }
 
@@ -276,23 +264,19 @@ impl UdpSocket {
         unsupported()
     }
 
-    pub fn join_multicast_v4(&self, _: &Ipv4Addr, _: &Ipv4Addr)
-                         -> io::Result<()> {
+    pub fn join_multicast_v4(&self, _: &Ipv4Addr, _: &Ipv4Addr) -> io::Result<()> {
         unsupported()
     }
 
-    pub fn join_multicast_v6(&self, _: &Ipv6Addr, _: u32)
-                         -> io::Result<()> {
+    pub fn join_multicast_v6(&self, _: &Ipv6Addr, _: u32) -> io::Result<()> {
         unsupported()
     }
 
-    pub fn leave_multicast_v4(&self, _: &Ipv4Addr, _: &Ipv4Addr)
-                          -> io::Result<()> {
+    pub fn leave_multicast_v4(&self, _: &Ipv4Addr, _: &Ipv4Addr) -> io::Result<()> {
         unsupported()
     }
 
-    pub fn leave_multicast_v6(&self, _: &Ipv6Addr, _: u32)
-                          -> io::Result<()> {
+    pub fn leave_multicast_v6(&self, _: &Ipv6Addr, _: u32) -> io::Result<()> {
         unsupported()
     }
 
@@ -339,19 +323,13 @@ impl UdpSocket {
 
 impl FromInner<u32> for UdpSocket {
     fn from_inner(fd: u32) -> UdpSocket {
-        unsafe {
-            UdpSocket {
-                fd: WasiFd::from_raw(fd),
-            }
-        }
+        unsafe { UdpSocket { fd: WasiFd::from_raw(fd) } }
     }
 }
 
 impl fmt::Debug for UdpSocket {
     fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
-        f.debug_struct("UdpSocket")
-            .field("fd", &self.fd.as_raw())
-            .finish()
+        f.debug_struct("UdpSocket").field("fd", &self.fd.as_raw()).finish()
     }
 }
 
@@ -419,8 +397,7 @@ pub mod netc {
     }
 
     #[derive(Copy, Clone)]
-    pub struct sockaddr {
-    }
+    pub struct sockaddr {}
 
     pub type socklen_t = usize;
 }
diff --git a/src/libstd/sys/wasi/os.rs b/src/libstd/sys/wasi/os.rs
index feee8407825..338fbe89765 100644
--- a/src/libstd/sys/wasi/os.rs
+++ b/src/libstd/sys/wasi/os.rs
@@ -1,6 +1,6 @@
 use crate::any::Any;
 use crate::error::Error as StdError;
-use crate::ffi::{OsString, OsStr, CString, CStr};
+use crate::ffi::{CStr, CString, OsStr, OsString};
 use crate::fmt;
 use crate::io;
 use crate::marker::PhantomData;
@@ -19,7 +19,7 @@ pub unsafe fn env_lock() -> impl Any {
 }
 
 pub fn errno() -> i32 {
-    extern {
+    extern "C" {
         #[thread_local]
         static errno: libc::c_int;
     }
@@ -64,7 +64,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)
 }
@@ -91,11 +93,14 @@ pub struct Env {
 
 impl Iterator for Env {
     type Item = (OsString, OsString);
-    fn next(&mut self) -> Option<(OsString, OsString)> { self.iter.next() }
-    fn size_hint(&self) -> (usize, Option<usize>) { self.iter.size_hint() }
+    fn next(&mut self) -> Option<(OsString, OsString)> {
+        self.iter.next()
+    }
+    fn size_hint(&self) -> (usize, Option<usize>) {
+        self.iter.size_hint()
+    }
 }
 
-
 pub fn env() -> Env {
     unsafe {
         let _guard = env_lock();
@@ -107,10 +112,7 @@ pub fn env() -> Env {
             }
             environ = environ.offset(1);
         }
-        return Env {
-            iter: result.into_iter(),
-            _dont_send_or_sync_me: PhantomData,
-        }
+        return Env { iter: result.into_iter(), _dont_send_or_sync_me: PhantomData };
     }
 
     // See src/libstd/sys/unix/os.rs, same as that
@@ -119,10 +121,12 @@ pub fn env() -> Env {
             return None;
         }
         let pos = memchr::memchr(b'=', &input[1..]).map(|p| p + 1);
-        pos.map(|p| (
-            OsStringExt::from_vec(input[..p].to_vec()),
-            OsStringExt::from_vec(input[p+1..].to_vec()),
-        ))
+        pos.map(|p| {
+            (
+                OsStringExt::from_vec(input[..p].to_vec()),
+                OsStringExt::from_vec(input[p + 1..].to_vec()),
+            )
+        })
     }
 }
 
@@ -168,9 +172,7 @@ pub fn home_dir() -> Option<PathBuf> {
 }
 
 pub fn exit(code: i32) -> ! {
-    unsafe {
-        libc::exit(code)
-    }
+    unsafe { libc::exit(code) }
 }
 
 pub fn getpid() -> u32 {
@@ -193,9 +195,5 @@ macro_rules! impl_is_minus_one {
 impl_is_minus_one! { i8 i16 i32 i64 isize }
 
 fn cvt<T: IsMinusOne>(t: T) -> io::Result<T> {
-    if t.is_minus_one() {
-        Err(io::Error::last_os_error())
-    } else {
-        Ok(t)
-    }
+    if t.is_minus_one() { Err(io::Error::last_os_error()) } else { Ok(t) }
 }
diff --git a/src/libstd/sys/wasi/path.rs b/src/libstd/sys/wasi/path.rs
index 7a183956107..840a7ae0426 100644
--- a/src/libstd/sys/wasi/path.rs
+++ b/src/libstd/sys/wasi/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/wasi/pipe.rs b/src/libstd/sys/wasi/pipe.rs
index 9f07f054362..fb14dc59101 100644
--- a/src/libstd/sys/wasi/pipe.rs
+++ b/src/libstd/sys/wasi/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/wasi/process.rs b/src/libstd/sys/wasi/process.rs
index 1c4d028b761..7156c9ab92f 100644
--- a/src/libstd/sys/wasi/process.rs
+++ b/src/libstd/sys/wasi/process.rs
@@ -13,7 +13,7 @@ pub use crate::ffi::OsString as EnvKey;
 ////////////////////////////////////////////////////////////////////////////////
 
 pub struct Command {
-    env: CommandEnv
+    env: CommandEnv,
 }
 
 // passed back to std::process with the pipes connected to the child, if any
@@ -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 {