@@ -81,15 +81,16 @@ impl ProcMacroProcessSrv {
8181 {
8282 let ( result_tx, result_rx) = bounded ( 0 ) ;
8383 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 ( ) ) ) ,
8785 Some ( it) => it,
8886 } ;
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+
9091 let res = result_rx
9192 . recv ( )
92- . map_err ( |_| tt:: ExpansionError :: Unknown ( "Proc macro thread is closed. " . into ( ) ) ) ?;
93+ . map_err ( |_| tt:: ExpansionError :: Unknown ( "proc macro server crashed " . into ( ) ) ) ?;
9394
9495 match res {
9596 Some ( Response :: Error ( err) ) => {
@@ -110,21 +111,17 @@ fn client_loop(task_rx: Receiver<Task>, mut process: Process) {
110111 match send_request ( & mut stdin, & mut stdout, req) {
111112 Ok ( res) => result_tx. send ( res) . unwrap ( ) ,
112113 Err ( _err) => {
114+ log:: error!(
115+ "proc macro server crashed, server process state: {:?}" ,
116+ process. child. try_wait( )
117+ ) ;
113118 let res = Response :: Error ( ResponseError {
114119 code : ErrorCode :: ServerErrorEnd ,
115- message : "Server closed " . into ( ) ,
120+ message : "proc macro server crashed " . into ( ) ,
116121 } ) ;
117122 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 ;
128125 }
129126 }
130127 }
@@ -136,8 +133,6 @@ struct Task {
136133}
137134
138135struct Process {
139- path : PathBuf ,
140- args : Vec < OsString > ,
141136 child : Child ,
142137}
143138
@@ -152,15 +147,9 @@ impl Process {
152147 path : PathBuf ,
153148 args : impl IntoIterator < Item = impl AsRef < OsStr > > ,
154149 ) -> 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 ( ) ;
156151 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 } )
164153 }
165154
166155 fn stdio ( & mut self ) -> Option < ( impl Write , impl BufRead ) > {
0 commit comments