From e536e810b4d5640df3e81c39265c173390991967 Mon Sep 17 00:00:00 2001 From: Christiaan Dirkx Date: Fri, 23 Oct 2020 22:14:57 +0200 Subject: [PATCH] Make the `hermit` target typecheck Adds the missing types: - `std::sys::mutex::MovableMutex` (`Box`) - `std::sys::process::CommandArgs` (`std::iter::Empty<&OsStr>`) Adds stub implementations to `std::sys::process::Command` for the following missing methods: - `get_args` - `get_current_dir` - `get_program` - `get_envs` --- library/std/src/sys/hermit/mutex.rs | 2 ++ library/std/src/sys/hermit/process.rs | 29 +++++++++++++++++++++++---- 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/library/std/src/sys/hermit/mutex.rs b/library/std/src/sys/hermit/mutex.rs index 3d4813209cbc4..08b51d1e3711f 100644 --- a/library/std/src/sys/hermit/mutex.rs +++ b/library/std/src/sys/hermit/mutex.rs @@ -6,6 +6,8 @@ pub struct Mutex { inner: *const c_void, } +pub type MovableMutex = Box; + unsafe impl Send for Mutex {} unsafe impl Sync for Mutex {} diff --git a/library/std/src/sys/hermit/process.rs b/library/std/src/sys/hermit/process.rs index 4702e5c549228..f26b2db1c8eb2 100644 --- a/library/std/src/sys/hermit/process.rs +++ b/library/std/src/sys/hermit/process.rs @@ -1,10 +1,12 @@ -use crate::ffi::OsStr; +use crate::ffi::{OsStr, OsString}; use crate::fmt; use crate::io; +use crate::iter::Empty; +use crate::path::Path; use crate::sys::fs::File; use crate::sys::pipe::AnonPipe; use crate::sys::{unsupported, Void}; -use crate::sys_common::process::CommandEnv; +use crate::sys_common::process::{CommandEnv, CommandEnvs}; pub use crate::ffi::OsString as EnvKey; @@ -13,9 +15,12 @@ pub use crate::ffi::OsString as EnvKey; //////////////////////////////////////////////////////////////////////////////// pub struct Command { + program: OsString, env: CommandEnv, } +pub type CommandArgs<'a> = Empty<&'a OsStr>; + // passed back to std::process with the pipes connected to the child, if any // were requested pub struct StdioPipes { @@ -31,8 +36,8 @@ pub enum Stdio { } impl Command { - pub fn new(_program: &OsStr) -> Command { - Command { env: Default::default() } + pub fn new(program: &OsStr) -> Command { + Command { program: program.into(), env: Default::default() } } pub fn arg(&mut self, _arg: &OsStr) {} @@ -49,6 +54,22 @@ impl Command { pub fn stderr(&mut self, _stderr: Stdio) {} + pub fn get_args(&self) -> CommandArgs<'_> { + Default::default() + } + + pub fn get_current_dir(&self) -> Option<&Path> { + None + } + + pub fn get_program(&self) -> &OsStr { + &self.program + } + + pub fn get_envs(&self) -> CommandEnvs<'_> { + self.env.iter() + } + pub fn spawn( &mut self, _default: Stdio,