From 6c0e838a7ce326ae0d3d0c8b34a3695c40592fc0 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Wed, 19 Jul 2023 16:13:02 -0700 Subject: [PATCH] Always consider empty output to be unsuccessful --- precompiled/serde_derive/src/lib_precompiled.rs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/precompiled/serde_derive/src/lib_precompiled.rs b/precompiled/serde_derive/src/lib_precompiled.rs index 92fe44080..db74b2ef3 100644 --- a/precompiled/serde_derive/src/lib_precompiled.rs +++ b/precompiled/serde_derive/src/lib_precompiled.rs @@ -6,7 +6,7 @@ use crate::bytecode::Bytecode; use proc_macro::{Delimiter, Group, Ident, Literal, Punct, Spacing, Span, TokenStream, TokenTree}; use std::io::{Read, Write}; use std::iter::FromIterator; -use std::process::{Command, Stdio}; +use std::process::{Command, ExitStatus, Stdio}; use std::str::FromStr; #[proc_macro_derive(Serialize, attributes(serde))] @@ -48,11 +48,8 @@ fn derive(select: u8, input: TokenStream) -> TokenStream { buf.clear(); stdout.read_to_end(&mut buf).unwrap(); - let success = match child.wait() { - Ok(exit_status) => exit_status.success(), - Err(_) => !buf.is_empty(), - }; - if !success { + let success = child.wait().as_ref().map_or(true, ExitStatus::success); + if !success || buf.is_empty() { panic!(); }