diff --git a/crates/proc-macro-api/src/process.rs b/crates/proc-macro-api/src/process.rs index e70b3850d66..1ccbd780fdd 100644 --- a/crates/proc-macro-api/src/process.rs +++ b/crates/proc-macro-api/src/process.rs @@ -27,13 +27,13 @@ pub(crate) fn run( process_path: AbsPathBuf, args: impl IntoIterator> + Clone, ) -> io::Result { - let create_srv = || { - let mut process = Process::run(process_path.clone(), args.clone())?; + let create_srv = |null_stderr| { + let mut process = Process::run(process_path.clone(), args.clone(), null_stderr)?; let (stdin, stdout) = process.stdio().expect("couldn't access child stdio"); io::Result::Ok(ProcMacroProcessSrv { _process: process, stdin, stdout, version: 0 }) }; - let mut srv = create_srv()?; + let mut srv = create_srv(true)?; tracing::info!("sending version check"); match srv.version_check() { Ok(v) if v > CURRENT_API_VERSION => Err(io::Error::new( @@ -45,12 +45,13 @@ pub(crate) fn run( )), Ok(v) => { tracing::info!("got version {v}"); + srv = create_srv(false)?; srv.version = v; Ok(srv) } Err(e) => { tracing::info!(%e, "proc-macro version check failed, restarting and assuming version 0"); - create_srv() + create_srv(false) } } } @@ -98,9 +99,10 @@ impl Process { fn run( path: AbsPathBuf, args: impl IntoIterator>, + null_stderr: bool, ) -> io::Result { let args: Vec = args.into_iter().map(|s| s.as_ref().into()).collect(); - let child = JodChild(mk_child(&path, args)?); + let child = JodChild(mk_child(&path, args, null_stderr)?); Ok(Process { child }) } @@ -116,13 +118,14 @@ fn stdio(&mut self) -> Option<(ChildStdin, BufReader)> { fn mk_child( path: &AbsPath, args: impl IntoIterator>, + null_stderr: bool, ) -> io::Result { Command::new(path.as_os_str()) .args(args) .env("RUST_ANALYZER_INTERNALS_DO_NOT_USE", "this is unstable") .stdin(Stdio::piped()) .stdout(Stdio::piped()) - .stderr(Stdio::inherit()) + .stderr(if null_stderr { Stdio::null() } else { Stdio::inherit() }) .spawn() }