@@ -27,13 +27,13 @@ impl ProcMacroProcessSrv {
2727 process_path : AbsPathBuf ,
2828 args : impl IntoIterator < Item = impl AsRef < OsStr > > + Clone ,
2929 ) -> io:: Result < ProcMacroProcessSrv > {
30- let create_srv = || {
31- let mut process = Process :: run ( process_path. clone ( ) , args. clone ( ) ) ?;
30+ let create_srv = |null_stderr | {
31+ let mut process = Process :: run ( process_path. clone ( ) , args. clone ( ) , null_stderr ) ?;
3232 let ( stdin, stdout) = process. stdio ( ) . expect ( "couldn't access child stdio" ) ;
3333
3434 io:: Result :: Ok ( ProcMacroProcessSrv { _process : process, stdin, stdout, version : 0 } )
3535 } ;
36- let mut srv = create_srv ( ) ?;
36+ let mut srv = create_srv ( true ) ?;
3737 tracing:: info!( "sending version check" ) ;
3838 match srv. version_check ( ) {
3939 Ok ( v) if v > CURRENT_API_VERSION => Err ( io:: Error :: new (
@@ -45,12 +45,13 @@ impl ProcMacroProcessSrv {
4545 ) ) ,
4646 Ok ( v) => {
4747 tracing:: info!( "got version {v}" ) ;
48+ srv = create_srv ( false ) ?;
4849 srv. version = v;
4950 Ok ( srv)
5051 }
5152 Err ( e) => {
5253 tracing:: info!( %e, "proc-macro version check failed, restarting and assuming version 0" ) ;
53- create_srv ( )
54+ create_srv ( false )
5455 }
5556 }
5657 }
@@ -98,9 +99,10 @@ impl Process {
9899 fn run (
99100 path : AbsPathBuf ,
100101 args : impl IntoIterator < Item = impl AsRef < OsStr > > ,
102+ null_stderr : bool ,
101103 ) -> io:: Result < Process > {
102104 let args: Vec < OsString > = args. into_iter ( ) . map ( |s| s. as_ref ( ) . into ( ) ) . collect ( ) ;
103- let child = JodChild ( mk_child ( & path, args) ?) ;
105+ let child = JodChild ( mk_child ( & path, args, null_stderr ) ?) ;
104106 Ok ( Process { child } )
105107 }
106108
@@ -116,13 +118,14 @@ impl Process {
116118fn mk_child (
117119 path : & AbsPath ,
118120 args : impl IntoIterator < Item = impl AsRef < OsStr > > ,
121+ null_stderr : bool ,
119122) -> io:: Result < Child > {
120123 Command :: new ( path. as_os_str ( ) )
121124 . args ( args)
122125 . env ( "RUST_ANALYZER_INTERNALS_DO_NOT_USE" , "this is unstable" )
123126 . stdin ( Stdio :: piped ( ) )
124127 . stdout ( Stdio :: piped ( ) )
125- . stderr ( Stdio :: inherit ( ) )
128+ . stderr ( if null_stderr { Stdio :: null ( ) } else { Stdio :: inherit ( ) } )
126129 . spawn ( )
127130}
128131
0 commit comments