@@ -81,15 +81,16 @@ impl ProcMacroProcessSrv {
81
81
{
82
82
let ( result_tx, result_rx) = bounded ( 0 ) ;
83
83
let sender = match self . inner . upgrade ( ) {
84
- None => {
85
- return Err ( tt:: ExpansionError :: Unknown ( "Proc macro process is closed." . into ( ) ) )
86
- }
84
+ None => return Err ( tt:: ExpansionError :: Unknown ( "proc macro process is closed" . into ( ) ) ) ,
87
85
Some ( it) => it,
88
86
} ;
89
- sender. send ( Task { req, result_tx } ) . unwrap ( ) ;
87
+ sender
88
+ . send ( Task { req, result_tx } )
89
+ . map_err ( |_| tt:: ExpansionError :: Unknown ( "proc macro server crashed" . into ( ) ) ) ?;
90
+
90
91
let res = result_rx
91
92
. recv ( )
92
- . map_err ( |_| tt:: ExpansionError :: Unknown ( "Proc macro thread is closed. " . into ( ) ) ) ?;
93
+ . map_err ( |_| tt:: ExpansionError :: Unknown ( "proc macro server crashed " . into ( ) ) ) ?;
93
94
94
95
match res {
95
96
Some ( Response :: Error ( err) ) => {
@@ -110,21 +111,17 @@ fn client_loop(task_rx: Receiver<Task>, mut process: Process) {
110
111
match send_request ( & mut stdin, & mut stdout, req) {
111
112
Ok ( res) => result_tx. send ( res) . unwrap ( ) ,
112
113
Err ( _err) => {
114
+ log:: error!(
115
+ "proc macro server crashed, server process state: {:?}" ,
116
+ process. child. try_wait( )
117
+ ) ;
113
118
let res = Response :: Error ( ResponseError {
114
119
code : ErrorCode :: ServerErrorEnd ,
115
- message : "Server closed " . into ( ) ,
120
+ message : "proc macro server crashed " . into ( ) ,
116
121
} ) ;
117
122
result_tx. send ( res. into ( ) ) . unwrap ( ) ;
118
- // Restart the process
119
- if process. restart ( ) . is_err ( ) {
120
- break ;
121
- }
122
- let stdio = match process. stdio ( ) {
123
- None => break ,
124
- Some ( it) => it,
125
- } ;
126
- stdin = stdio. 0 ;
127
- stdout = stdio. 1 ;
123
+ // Exit the thread.
124
+ break ;
128
125
}
129
126
}
130
127
}
@@ -136,8 +133,6 @@ struct Task {
136
133
}
137
134
138
135
struct Process {
139
- path : PathBuf ,
140
- args : Vec < OsString > ,
141
136
child : Child ,
142
137
}
143
138
@@ -152,15 +147,9 @@ impl Process {
152
147
path : PathBuf ,
153
148
args : impl IntoIterator < Item = impl AsRef < OsStr > > ,
154
149
) -> io:: Result < Process > {
155
- let args = args. into_iter ( ) . map ( |s| s. as_ref ( ) . into ( ) ) . collect ( ) ;
150
+ let args: Vec < OsString > = args. into_iter ( ) . map ( |s| s. as_ref ( ) . into ( ) ) . collect ( ) ;
156
151
let child = mk_child ( & path, & args) ?;
157
- Ok ( Process { path, args, child } )
158
- }
159
-
160
- fn restart ( & mut self ) -> io:: Result < ( ) > {
161
- let _ = self . child . kill ( ) ;
162
- self . child = mk_child ( & self . path , & self . args ) ?;
163
- Ok ( ( ) )
152
+ Ok ( Process { child } )
164
153
}
165
154
166
155
fn stdio ( & mut self ) -> Option < ( impl Write , impl BufRead ) > {
0 commit comments