Improve error message on missing serde_derive exe

This commit is contained in:
David Tolnay 2023-07-26 00:52:09 -07:00
parent b978854258
commit d2d7bad04a
No known key found for this signature in database
GPG Key ID: F9BA143B95FF6D82

View File

@ -8,6 +8,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::path::Path;
use std::process::{Command, ExitStatus, Stdio};
use std::str::FromStr;
@ -31,11 +32,17 @@ fn derive(select: u8, input: TokenStream) -> TokenStream {
memory.linearize_token(token, &mut buf);
}
let path = concat!(
let exe_path = Path::new(concat!(
env!("CARGO_MANIFEST_DIR"),
"/serde_derive-x86_64-unknown-linux-gnu",
);
let mut child = Command::new(path)
));
if !exe_path.exists() {
panic!(
"file missing from serde_derive manifest directory during macro expansion: {}",
exe_path.display(),
);
}
let mut child = Command::new(exe_path)
.stdin(Stdio::piped())
.stdout(Stdio::piped())
.spawn()