about summary refs log tree commit diff
path: root/src/libstd/sys
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2019-12-20 11:17:47 +0000
committerbors <bors@rust-lang.org>2019-12-20 11:17:47 +0000
commit6b561b4917e803c4be4ca44d8e552b680cb9e380 (patch)
treefed1db0704735b342d9dec0223eddda023ee514c /src/libstd/sys
parent696735f71b4408302ba166d148e9d474c51416d2 (diff)
parent3a336c48c3e115ea13c53fc117b95bd9f66f1658 (diff)
downloadrust-6b561b4917e803c4be4ca44d8e552b680cb9e380.tar.gz
rust-6b561b4917e803c4be4ca44d8e552b680cb9e380.zip
Auto merge of #67449 - Centril:rollup-04hvg57, r=Centril
Rollup of 7 pull requests

Successful merges:

 - #66755 (Remove a const-if-hack in RawVec)
 - #67127 (Use structured suggestion for disambiguating method calls)
 - #67219 (Fix up Command Debug output when arg0 is specified.)
 - #67285 (Indicate origin of where type parameter for uninferred types )
 - #67328 (Remove now-redundant range check on u128 -> f32 casts)
 - #67367 (Move command line option definitions into a dedicated file)
 - #67442 (Remove `SOCK_CLOEXEC` dummy variable on platforms that don't use it.)

Failed merges:

r? @ghost
Diffstat (limited to 'src/libstd/sys')
-rw-r--r--src/libstd/sys/unix/net.rs25
-rw-r--r--src/libstd/sys/unix/process/process_common.rs8
-rw-r--r--src/libstd/sys/vxworks/net.rs2
3 files changed, 15 insertions, 20 deletions
diff --git a/src/libstd/sys/unix/net.rs b/src/libstd/sys/unix/net.rs
index 5d101ed1f2e..4c23aabf497 100644
--- a/src/libstd/sys/unix/net.rs
+++ b/src/libstd/sys/unix/net.rs
@@ -18,16 +18,6 @@ pub extern crate libc as netc;
 
 pub type wrlen_t = size_t;
 
-// See below for the usage of SOCK_CLOEXEC, but this constant is only defined on
-// Linux currently (e.g., support doesn't exist on other platforms). In order to
-// get name resolution to work and things to compile we just define a dummy
-// SOCK_CLOEXEC here for other platforms. Note that the dummy constant isn't
-// actually ever used (the blocks below are wrapped in `if cfg!` as well.
-#[cfg(target_os = "linux")]
-use libc::SOCK_CLOEXEC;
-#[cfg(not(target_os = "linux"))]
-const SOCK_CLOEXEC: c_int = 0;
-
 pub struct Socket(FileDesc);
 
 pub fn init() {}
@@ -69,8 +59,9 @@ impl Socket {
             // this option, however, was added in 2.6.27, and we still support
             // 2.6.18 as a kernel, so if the returned error is EINVAL we
             // fallthrough to the fallback.
-            if cfg!(target_os = "linux") {
-                match cvt(libc::socket(fam, ty | SOCK_CLOEXEC, 0)) {
+            #[cfg(target_os = "linux")]
+            {
+                match cvt(libc::socket(fam, ty | libc::SOCK_CLOEXEC, 0)) {
                     Ok(fd) => return Ok(Socket(FileDesc::new(fd))),
                     Err(ref e) if e.raw_os_error() == Some(libc::EINVAL) => {}
                     Err(e) => return Err(e),
@@ -96,8 +87,9 @@ impl Socket {
             let mut fds = [0, 0];
 
             // Like above, see if we can set cloexec atomically
-            if cfg!(target_os = "linux") {
-                match cvt(libc::socketpair(fam, ty | SOCK_CLOEXEC, 0, fds.as_mut_ptr())) {
+            #[cfg(target_os = "linux")]
+            {
+                match cvt(libc::socketpair(fam, ty | libc::SOCK_CLOEXEC, 0, fds.as_mut_ptr())) {
                     Ok(_) => {
                         return Ok((Socket(FileDesc::new(fds[0])), Socket(FileDesc::new(fds[1]))));
                     }
@@ -187,7 +179,8 @@ impl Socket {
         // atomically set the CLOEXEC flag is to use the `accept4` syscall on
         // Linux. This was added in 2.6.28, however, and because we support
         // 2.6.18 we must detect this support dynamically.
-        if cfg!(target_os = "linux") {
+        #[cfg(target_os = "linux")]
+        {
             syscall! {
                 fn accept4(
                     fd: c_int,
@@ -196,7 +189,7 @@ impl Socket {
                     flags: c_int
                 ) -> c_int
             }
-            let res = cvt_r(|| unsafe { accept4(self.0.raw(), storage, len, SOCK_CLOEXEC) });
+            let res = cvt_r(|| unsafe { accept4(self.0.raw(), storage, len, libc::SOCK_CLOEXEC) });
             match res {
                 Ok(fd) => return Ok(Socket(FileDesc::new(fd))),
                 Err(ref e) if e.raw_os_error() == Some(libc::ENOSYS) => {}
diff --git a/src/libstd/sys/unix/process/process_common.rs b/src/libstd/sys/unix/process/process_common.rs
index c9109b0c9d4..e66d6fdc56a 100644
--- a/src/libstd/sys/unix/process/process_common.rs
+++ b/src/libstd/sys/unix/process/process_common.rs
@@ -375,8 +375,12 @@ impl ChildStdio {
 
 impl fmt::Debug for Command {
     fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
-        write!(f, "{:?}", self.program)?;
-        for arg in &self.args {
+        if self.program != self.args[0] {
+            write!(f, "[{:?}] ", self.program)?;
+        }
+        write!(f, "{:?}", self.args[0])?;
+
+        for arg in &self.args[1..] {
             write!(f, " {:?}", arg)?;
         }
         Ok(())
diff --git a/src/libstd/sys/vxworks/net.rs b/src/libstd/sys/vxworks/net.rs
index 54466ff2c2e..74cbd246fe8 100644
--- a/src/libstd/sys/vxworks/net.rs
+++ b/src/libstd/sys/vxworks/net.rs
@@ -18,8 +18,6 @@ pub extern crate libc as netc;
 
 pub type wrlen_t = size_t;
 
-const SOCK_CLOEXEC: c_int = 0;
-
 pub struct Socket(FileDesc);
 
 pub fn init() {}