about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2023-02-09 10:29:28 +0000
committerbors <bors@rust-lang.org>2023-02-09 10:29:28 +0000
commit7e17b98d17f2496dd00331ebd481d343f37654b2 (patch)
treeb75687038e3800b7f7110c9a589f4ad069141c85
parent313a48057aa0f628bd268a8d0305001197e27f7e (diff)
parent8828f3494e307e715bea9c0d4d993ad4e550314b (diff)
downloadrust-7e17b98d17f2496dd00331ebd481d343f37654b2.tar.gz
rust-7e17b98d17f2496dd00331ebd481d343f37654b2.zip
Auto merge of #14111 - lnicola:squash-proc-macro-server-warning, r=Veykril
fix: Hide proc macro server version detection errors

These are harmless, but users tend to blame other things on them.
-rw-r--r--crates/proc-macro-api/src/process.rs15
1 files changed, 9 insertions, 6 deletions
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 @@ impl ProcMacroProcessSrv {
         process_path: AbsPathBuf,
         args: impl IntoIterator<Item = impl AsRef<OsStr>> + Clone,
     ) -> io::Result<ProcMacroProcessSrv> {
-        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 @@ impl ProcMacroProcessSrv {
             )),
             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<Item = impl AsRef<OsStr>>,
+        null_stderr: bool,
     ) -> io::Result<Process> {
         let args: Vec<OsString> = 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 @@ impl Process {
 fn mk_child(
     path: &AbsPath,
     args: impl IntoIterator<Item = impl AsRef<OsStr>>,
+    null_stderr: bool,
 ) -> io::Result<Child> {
     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()
 }