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
This commit is contained in:
Manish Goregaokar 2020-07-19 07:02:24 -07:00 committed by GitHub
commit cc4e880c62
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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 {