@@ -6,7 +6,6 @@ use std::{
6
6
io:: { self , BufRead , BufReader , Write } ,
7
7
path:: { Path , PathBuf } ,
8
8
process:: { Child , ChildStdin , ChildStdout , Command , Stdio } ,
9
- sync:: Mutex ,
10
9
} ;
11
10
12
11
use stdx:: JodChild ;
@@ -18,8 +17,9 @@ use crate::{
18
17
19
18
#[ derive( Debug ) ]
20
19
pub ( crate ) struct ProcMacroProcessSrv {
21
- process : Mutex < Process > ,
22
- stdio : Mutex < ( ChildStdin , BufReader < ChildStdout > ) > ,
20
+ process : Process ,
21
+ stdin : ChildStdin ,
22
+ stdout : BufReader < ChildStdout > ,
23
23
}
24
24
25
25
impl ProcMacroProcessSrv {
@@ -30,16 +30,13 @@ impl ProcMacroProcessSrv {
30
30
let mut process = Process :: run ( process_path, args) ?;
31
31
let ( stdin, stdout) = process. stdio ( ) . expect ( "couldn't access child stdio" ) ;
32
32
33
- let srv = ProcMacroProcessSrv {
34
- process : Mutex :: new ( process) ,
35
- stdio : Mutex :: new ( ( stdin, stdout) ) ,
36
- } ;
33
+ let srv = ProcMacroProcessSrv { process, stdin, stdout } ;
37
34
38
35
Ok ( srv)
39
36
}
40
37
41
38
pub ( crate ) fn find_proc_macros (
42
- & self ,
39
+ & mut self ,
43
40
dylib_path : & Path ,
44
41
) -> Result < Vec < ( String , ProcMacroKind ) > , tt:: ExpansionError > {
45
42
let task = ListMacrosTask { lib : dylib_path. to_path_buf ( ) } ;
@@ -48,22 +45,18 @@ impl ProcMacroProcessSrv {
48
45
Ok ( result. macros )
49
46
}
50
47
51
- pub ( crate ) fn send_task < R > ( & self , req : Request ) -> Result < R , tt:: ExpansionError >
48
+ pub ( crate ) fn send_task < R > ( & mut self , req : Request ) -> Result < R , tt:: ExpansionError >
52
49
where
53
50
R : TryFrom < Response , Error = & ' static str > ,
54
51
{
55
- let mut guard = self . stdio . lock ( ) . unwrap_or_else ( |e| e. into_inner ( ) ) ;
56
- let stdio = & mut * guard;
57
- let ( stdin, stdout) = ( & mut stdio. 0 , & mut stdio. 1 ) ;
58
-
59
52
let mut buf = String :: new ( ) ;
60
- let res = match send_request ( stdin, stdout, req, & mut buf) {
53
+ let res = match send_request ( & mut self . stdin , & mut self . stdout , req, & mut buf) {
61
54
Ok ( res) => res,
62
55
Err ( err) => {
63
- let mut process = self . process . lock ( ) . unwrap_or_else ( |e| e . into_inner ( ) ) ;
56
+ let result = self . process . child . try_wait ( ) ;
64
57
log:: error!(
65
58
"proc macro server crashed, server process state: {:?}, server request error: {:?}" ,
66
- process . child . try_wait ( ) ,
59
+ result ,
67
60
err
68
61
) ;
69
62
let res = Response :: Error ( ResponseError {
0 commit comments