@@ -27,13 +27,13 @@ impl ProcMacroProcessSrv {
27
27
process_path : AbsPathBuf ,
28
28
args : impl IntoIterator < Item = impl AsRef < OsStr > > + Clone ,
29
29
) -> 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 ) ?;
32
32
let ( stdin, stdout) = process. stdio ( ) . expect ( "couldn't access child stdio" ) ;
33
33
34
34
io:: Result :: Ok ( ProcMacroProcessSrv { _process : process, stdin, stdout, version : 0 } )
35
35
} ;
36
- let mut srv = create_srv ( ) ?;
36
+ let mut srv = create_srv ( true ) ?;
37
37
tracing:: info!( "sending version check" ) ;
38
38
match srv. version_check ( ) {
39
39
Ok ( v) if v > CURRENT_API_VERSION => Err ( io:: Error :: new (
@@ -45,12 +45,13 @@ impl ProcMacroProcessSrv {
45
45
) ) ,
46
46
Ok ( v) => {
47
47
tracing:: info!( "got version {v}" ) ;
48
+ srv = create_srv ( false ) ?;
48
49
srv. version = v;
49
50
Ok ( srv)
50
51
}
51
52
Err ( e) => {
52
53
tracing:: info!( %e, "proc-macro version check failed, restarting and assuming version 0" ) ;
53
- create_srv ( )
54
+ create_srv ( false )
54
55
}
55
56
}
56
57
}
@@ -98,9 +99,10 @@ impl Process {
98
99
fn run (
99
100
path : AbsPathBuf ,
100
101
args : impl IntoIterator < Item = impl AsRef < OsStr > > ,
102
+ null_stderr : bool ,
101
103
) -> io:: Result < Process > {
102
104
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 ) ?) ;
104
106
Ok ( Process { child } )
105
107
}
106
108
@@ -116,13 +118,14 @@ impl Process {
116
118
fn mk_child (
117
119
path : & AbsPath ,
118
120
args : impl IntoIterator < Item = impl AsRef < OsStr > > ,
121
+ null_stderr : bool ,
119
122
) -> io:: Result < Child > {
120
123
Command :: new ( path. as_os_str ( ) )
121
124
. args ( args)
122
125
. env ( "RUST_ANALYZER_INTERNALS_DO_NOT_USE" , "this is unstable" )
123
126
. stdin ( Stdio :: piped ( ) )
124
127
. stdout ( Stdio :: piped ( ) )
125
- . stderr ( Stdio :: inherit ( ) )
128
+ . stderr ( if null_stderr { Stdio :: null ( ) } else { Stdio :: inherit ( ) } )
126
129
. spawn ( )
127
130
}
128
131
0 commit comments