about summary refs log tree commit diff
path: root/src/libstd
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2020-01-24 23:04:54 +0000
committerbors <bors@rust-lang.org>2020-01-24 23:04:54 +0000
commit8647aa1a2ce279f8ec7cc5252d10b8cb9ea504eb (patch)
treeea761455fe8821274ff5db691e789a91a206631d /src/libstd
parentc2d141df59703393c0c683abc259f9a8c3be041a (diff)
parentf998e275cae5320e75871c626c0f88eaef83d5e4 (diff)
downloadrust-8647aa1a2ce279f8ec7cc5252d10b8cb9ea504eb.tar.gz
rust-8647aa1a2ce279f8ec7cc5252d10b8cb9ea504eb.zip
Auto merge of #68526 - JohnTitor:rollup-3mmljof, r=JohnTitor
Rollup of 6 pull requests

Successful merges:

 - #68111 (Print constants in `type_name` for const generics)
 - #68374 (Fix invalid link to the C++ Exception Handling ABI documentation)
 - #68504 (Use check-pass mode for lint tests and nll tests)
 - #68509 (Clean up error codes E0223 and E0225 explanations)
 - #68511 (Remove unused ignore-license directives)
 - #68515 (Support feature process_set_argv0 for VxWorks)

Failed merges:

r? @ghost
Diffstat (limited to 'src/libstd')
-rw-r--r--src/libstd/sys/cloudabi/abi/bitflags.rs3
-rw-r--r--src/libstd/sys/cloudabi/abi/cloudabi.rs1
-rw-r--r--src/libstd/sys/vxworks/ext/process.rs18
-rw-r--r--src/libstd/sys/vxworks/process/process_common.rs24
-rw-r--r--src/libstd/sys/vxworks/process/process_vxworks.rs2
5 files changed, 39 insertions, 9 deletions
diff --git a/src/libstd/sys/cloudabi/abi/bitflags.rs b/src/libstd/sys/cloudabi/abi/bitflags.rs
index 306936213ed..2383277ad72 100644
--- a/src/libstd/sys/cloudabi/abi/bitflags.rs
+++ b/src/libstd/sys/cloudabi/abi/bitflags.rs
@@ -21,9 +21,6 @@
 // OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 // SUCH DAMAGE.
 
-// Appease Rust's tidy.
-// ignore-license
-
 #[cfg(feature = "bitflags")]
 use bitflags::bitflags;
 
diff --git a/src/libstd/sys/cloudabi/abi/cloudabi.rs b/src/libstd/sys/cloudabi/abi/cloudabi.rs
index d113a7b3d60..b02faf1830c 100644
--- a/src/libstd/sys/cloudabi/abi/cloudabi.rs
+++ b/src/libstd/sys/cloudabi/abi/cloudabi.rs
@@ -26,7 +26,6 @@
 // Source: https://github.com/NuxiNL/cloudabi
 
 // Appease Rust's tidy.
-// ignore-license
 // ignore-tidy-linelength
 
 //! **PLEASE NOTE: This entire crate including this
diff --git a/src/libstd/sys/vxworks/ext/process.rs b/src/libstd/sys/vxworks/ext/process.rs
index e535c4aa122..31e691dd136 100644
--- a/src/libstd/sys/vxworks/ext/process.rs
+++ b/src/libstd/sys/vxworks/ext/process.rs
@@ -2,6 +2,7 @@
 
 #![stable(feature = "rust1", since = "1.0.0")]
 
+use crate::ffi::OsStr;
 use crate::io;
 use crate::process;
 use crate::sys;
@@ -105,6 +106,15 @@ pub trait CommandExt {
     /// cross-platform `spawn` instead.
     #[stable(feature = "process_exec2", since = "1.9.0")]
     fn exec(&mut self) -> io::Error;
+
+    /// Set executable argument
+    ///
+    /// Set the first process argument, `argv[0]`, to something other than the
+    /// default executable path.
+    #[unstable(feature = "process_set_argv0", issue = "66510")]
+    fn arg0<S>(&mut self, arg: S) -> &mut process::Command
+    where
+        S: AsRef<OsStr>;
 }
 
 #[stable(feature = "rust1", since = "1.0.0")]
@@ -130,6 +140,14 @@ impl CommandExt for process::Command {
     fn exec(&mut self) -> io::Error {
         self.as_inner_mut().exec(sys::process::Stdio::Inherit)
     }
+
+    fn arg0<S>(&mut self, arg: S) -> &mut process::Command
+    where
+        S: AsRef<OsStr>,
+    {
+        self.as_inner_mut().set_arg_0(arg.as_ref());
+        self
+    }
 }
 
 /// Unix-specific extensions to [`process::ExitStatus`].
diff --git a/src/libstd/sys/vxworks/process/process_common.rs b/src/libstd/sys/vxworks/process/process_common.rs
index a8139a27537..6d5506bec5f 100644
--- a/src/libstd/sys/vxworks/process/process_common.rs
+++ b/src/libstd/sys/vxworks/process/process_common.rs
@@ -90,8 +90,8 @@ impl Command {
         let program = os2c(program, &mut saw_nul);
         Command {
             argv: Argv(vec![program.as_ptr(), ptr::null()]),
+            args: vec![program.clone()],
             program,
-            args: Vec::new(),
             env: Default::default(),
             cwd: None,
             uid: None,
@@ -104,11 +104,19 @@ impl Command {
         }
     }
 
+    pub fn set_arg_0(&mut self, arg: &OsStr) {
+        // Set a new arg0
+        let arg = os2c(arg, &mut self.saw_nul);
+        debug_assert!(self.argv.0.len() > 1);
+        self.argv.0[0] = arg.as_ptr();
+        self.args[0] = arg;
+    }
+
     pub fn arg(&mut self, arg: &OsStr) {
         // Overwrite the trailing NULL pointer in `argv` and then add a new null
         // pointer.
         let arg = os2c(arg, &mut self.saw_nul);
-        self.argv.0[self.args.len() + 1] = arg.as_ptr();
+        self.argv.0[self.args.len()] = arg.as_ptr();
         self.argv.0.push(ptr::null());
 
         // Also make sure we keep track of the owned value to schedule a
@@ -133,6 +141,10 @@ impl Command {
         &self.argv.0
     }
 
+    pub fn get_program(&self) -> &CStr {
+        &*self.program
+    }
+
     #[allow(dead_code)]
     pub fn get_cwd(&self) -> &Option<CString> {
         &self.cwd
@@ -315,8 +327,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/process/process_vxworks.rs b/src/libstd/sys/vxworks/process/process_vxworks.rs
index ced70dea27f..f7e84ae3de9 100644
--- a/src/libstd/sys/vxworks/process/process_vxworks.rs
+++ b/src/libstd/sys/vxworks/process/process_vxworks.rs
@@ -67,7 +67,7 @@ impl Command {
             let _lock = sys::os::env_lock();
 
             let ret = libc::rtpSpawn(
-                self.get_argv()[0],                             // executing program
+                self.get_program().as_ptr(),
                 self.get_argv().as_ptr() as *mut *const c_char, // argv
                 c_envp as *mut *const c_char,
                 100 as c_int, // initial priority