about summary refs log tree commit diff
diff options
context:
space:
mode:
authorManish Goregaokar <manishsmail@gmail.com>2020-07-19 07:02:24 -0700
committerGitHub <noreply@github.com>2020-07-19 07:02:24 -0700
commitcc4e880c62605a490ca846a86d7b0f8bb50fb8a5 (patch)
treeae225a49b6ac6c5980c9af4097fde1e6d7768524
parent2f3d64fc2f4df95645366825952a4c976bcb2336 (diff)
parentafbfe603fc1c288a0cff63b3b1cad43902a66e9b (diff)
downloadrust-cc4e880c62605a490ca846a86d7b0f8bb50fb8a5.tar.gz
rust-cc4e880c62605a490ca846a86d7b0f8bb50fb8a5.zip
Rollup merge of #74356 - lzutao:rm_combine, r=LukasKalbertodt
Remove combine function

Comparing two array directly helps generate better assert message.
Resolve https://github.com/rust-lang/rust/pull/74271/files#r454538514
-rw-r--r--src/libstd/sys/unix/process/process_unix.rs10
1 files changed, 3 insertions, 7 deletions
diff --git a/src/libstd/sys/unix/process/process_unix.rs b/src/libstd/sys/unix/process/process_unix.rs
index 371291b9f76..0f349dfa302 100644
--- a/src/libstd/sys/unix/process/process_unix.rs
+++ b/src/libstd/sys/unix/process/process_unix.rs
@@ -84,12 +84,12 @@ impl Command {
                 Ok(0) => return Ok((p, ours)),
                 Ok(8) => {
                     let (errno, footer) = bytes.split_at(4);
-                    assert!(
-                        combine(CLOEXEC_MSG_FOOTER) == combine(footer.try_into().unwrap()),
+                    assert_eq!(
+                        CLOEXEC_MSG_FOOTER, footer,
                         "Validation on the CLOEXEC pipe failed: {:?}",
                         bytes
                     );
-                    let errno = combine(errno.try_into().unwrap());
+                    let errno = i32::from_be_bytes(errno.try_into().unwrap());
                     assert!(p.wait().is_ok(), "wait() should either return Ok or panic");
                     return Err(Error::from_raw_os_error(errno));
                 }
@@ -105,10 +105,6 @@ impl Command {
                 }
             }
         }
-
-        fn combine(arr: [u8; 4]) -> i32 {
-            i32::from_be_bytes(arr)
-        }
     }
 
     pub fn exec(&mut self, default: Stdio) -> io::Error {