Skip to content

Commit cc4e880

Browse files
authored
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
2 parents 2f3d64f + afbfe60 commit cc4e880

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

src/libstd/sys/unix/process/process_unix.rs

+3-7
Original file line numberDiff line numberDiff line change
@@ -84,12 +84,12 @@ impl Command {
8484
Ok(0) => return Ok((p, ours)),
8585
Ok(8) => {
8686
let (errno, footer) = bytes.split_at(4);
87-
assert!(
88-
combine(CLOEXEC_MSG_FOOTER) == combine(footer.try_into().unwrap()),
87+
assert_eq!(
88+
CLOEXEC_MSG_FOOTER, footer,
8989
"Validation on the CLOEXEC pipe failed: {:?}",
9090
bytes
9191
);
92-
let errno = combine(errno.try_into().unwrap());
92+
let errno = i32::from_be_bytes(errno.try_into().unwrap());
9393
assert!(p.wait().is_ok(), "wait() should either return Ok or panic");
9494
return Err(Error::from_raw_os_error(errno));
9595
}
@@ -105,10 +105,6 @@ impl Command {
105105
}
106106
}
107107
}
108-
109-
fn combine(arr: [u8; 4]) -> i32 {
110-
i32::from_be_bytes(arr)
111-
}
112108
}
113109

114110
pub fn exec(&mut self, default: Stdio) -> io::Error {

0 commit comments

Comments
 (0)