diff options
| author | bors <bors@rust-lang.org> | 2021-10-04 07:25:50 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2021-10-04 07:25:50 +0000 |
| commit | 44593aeb1387b1be355aeaf0040d5927bd80f060 (patch) | |
| tree | b1bd69742d3986c25b61d05b43fbd1cde28d3a4e /library/std/src/sys/unix/process/process_unix.rs | |
| parent | d25de31a0eeb14ab0c8c4613496fe2d3d9a085dd (diff) | |
| parent | 5c5dde8f0a1e7a3f735dce63d6b81680d24c56d9 (diff) | |
| download | rust-44593aeb1387b1be355aeaf0040d5927bd80f060.tar.gz rust-44593aeb1387b1be355aeaf0040d5927bd80f060.zip | |
Auto merge of #89512 - Manishearth:rollup-meh9x7r, r=Manishearth
Rollup of 14 pull requests Successful merges: - #86434 (Add `Ipv6Addr::is_benchmarking`) - #86828 (const fn for option copied, take & replace) - #87679 (BTree: refine some comments) - #87910 (Mark unsafe methods NonZero*::unchecked_(add|mul) as const.) - #88286 (Remove unnecessary unsafe block in `process_unix`) - #88305 (Manual Debug for Unix ExitCode ExitStatus ExitStatusError) - #88353 (Partially stabilize `array_methods`) - #88370 (Add missing `# Panics` section to `Vec` method) - #88481 (Remove some feature gates) - #89138 (Fix link in Ipv6Addr::to_ipv4 docs) - #89401 (Add truncate note to Vec::resize) - #89467 (Fix typos in rustdoc/lints) - #89472 (Only register `WSACleanup` if `WSAStartup` is actually ever called) - #89505 (Add regression test for spurious const error with NLL) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'library/std/src/sys/unix/process/process_unix.rs')
| -rw-r--r-- | library/std/src/sys/unix/process/process_unix.rs | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/library/std/src/sys/unix/process/process_unix.rs b/library/std/src/sys/unix/process/process_unix.rs index 12edf04a4e2..8c33051cfa4 100644 --- a/library/std/src/sys/unix/process/process_unix.rs +++ b/library/std/src/sys/unix/process/process_unix.rs @@ -552,8 +552,7 @@ impl Process { use crate::os::unix::io::FromRawFd; use crate::sys_common::FromInner; // Safety: If `pidfd` is nonnegative, we assume it's valid and otherwise unowned. - let pidfd = (pidfd >= 0) - .then(|| PidFd::from_inner(unsafe { sys::fd::FileDesc::from_raw_fd(pidfd) })); + let pidfd = (pidfd >= 0).then(|| PidFd::from_inner(sys::fd::FileDesc::from_raw_fd(pidfd))); Process { pid, status: None, pidfd } } @@ -607,9 +606,15 @@ impl Process { } /// Unix exit statuses -#[derive(PartialEq, Eq, Clone, Copy, Debug)] +#[derive(PartialEq, Eq, Clone, Copy)] pub struct ExitStatus(c_int); +impl fmt::Debug for ExitStatus { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_tuple("unix_wait_status").field(&self.0).finish() + } +} + impl ExitStatus { pub fn new(status: c_int) -> ExitStatus { ExitStatus(status) @@ -683,7 +688,7 @@ impl fmt::Display for ExitStatus { } } -#[derive(PartialEq, Eq, Clone, Copy, Debug)] +#[derive(PartialEq, Eq, Clone, Copy)] pub struct ExitStatusError(NonZero_c_int); impl Into<ExitStatus> for ExitStatusError { @@ -692,6 +697,12 @@ impl Into<ExitStatus> for ExitStatusError { } } +impl fmt::Debug for ExitStatusError { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_tuple("unix_wait_status").field(&self.0).finish() + } +} + impl ExitStatusError { pub fn code(self) -> Option<NonZeroI32> { ExitStatus(self.0.into()).code().map(|st| st.try_into().unwrap()) |
