diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2021-06-22 21:01:34 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2021-06-22 21:01:34 +0100 |
commit | 38da41ea6e58255223686104b3fbca27392d8162 (patch) | |
tree | c848d19087658a68772ce5b1f836a3d6c32a63b4 /crates/stdx | |
parent | 9b29573a4bfcecfcd3c48ada589f6129323a559c (diff) | |
parent | c61fee6d55c011e6f5eec29788101667ee62631c (diff) |
Merge #9381
9381: Fix compilation on WASM r=matklad a=flodiebold
Fixes #9214.
Fixes #9210.
Co-authored-by: Florian Diebold <[email protected]>
Diffstat (limited to 'crates/stdx')
-rw-r--r-- | crates/stdx/src/lib.rs | 7 | ||||
-rw-r--r-- | crates/stdx/src/process.rs | 16 |
2 files changed, 21 insertions, 2 deletions
diff --git a/crates/stdx/src/lib.rs b/crates/stdx/src/lib.rs index 18d5fadb9..2963484fa 100644 --- a/crates/stdx/src/lib.rs +++ b/crates/stdx/src/lib.rs | |||
@@ -110,7 +110,7 @@ pub fn defer<F: FnOnce()>(f: F) -> impl Drop { | |||
110 | D(Some(f)) | 110 | D(Some(f)) |
111 | } | 111 | } |
112 | 112 | ||
113 | #[repr(transparent)] | 113 | #[cfg_attr(not(target_arch = "wasm32"), repr(transparent))] |
114 | pub struct JodChild(pub std::process::Child); | 114 | pub struct JodChild(pub std::process::Child); |
115 | 115 | ||
116 | impl ops::Deref for JodChild { | 116 | impl ops::Deref for JodChild { |
@@ -135,7 +135,10 @@ impl Drop for JodChild { | |||
135 | 135 | ||
136 | impl JodChild { | 136 | impl JodChild { |
137 | pub fn into_inner(self) -> std::process::Child { | 137 | pub fn into_inner(self) -> std::process::Child { |
138 | // SAFETY: repr transparent | 138 | if cfg!(target_arch = "wasm32") { |
139 | panic!("no processes on wasm"); | ||
140 | } | ||
141 | // SAFETY: repr transparent, except on WASM | ||
139 | unsafe { std::mem::transmute::<JodChild, std::process::Child>(self) } | 142 | unsafe { std::mem::transmute::<JodChild, std::process::Child>(self) } |
140 | } | 143 | } |
141 | } | 144 | } |
diff --git a/crates/stdx/src/process.rs b/crates/stdx/src/process.rs index 692a2ab3d..b290ba2f0 100644 --- a/crates/stdx/src/process.rs +++ b/crates/stdx/src/process.rs | |||
@@ -236,3 +236,19 @@ mod imp { | |||
236 | slice::from_raw_parts_mut(v.as_mut_ptr().add(v.len()), v.capacity() - v.len()) | 236 | slice::from_raw_parts_mut(v.as_mut_ptr().add(v.len()), v.capacity() - v.len()) |
237 | } | 237 | } |
238 | } | 238 | } |
239 | |||
240 | #[cfg(target_arch = "wasm32")] | ||
241 | mod imp { | ||
242 | use std::{ | ||
243 | io, | ||
244 | process::{ChildStderr, ChildStdout}, | ||
245 | }; | ||
246 | |||
247 | pub(crate) fn read2( | ||
248 | _out_pipe: ChildStdout, | ||
249 | _err_pipe: ChildStderr, | ||
250 | _data: &mut dyn FnMut(bool, &mut Vec<u8>, bool), | ||
251 | ) -> io::Result<()> { | ||
252 | panic!("no processes on wasm") | ||
253 | } | ||
254 | } | ||