diff options
Diffstat (limited to 'crates')
-rw-r--r-- | crates/proc_macro_api/src/process.rs | 20 |
1 files changed, 5 insertions, 15 deletions
diff --git a/crates/proc_macro_api/src/process.rs b/crates/proc_macro_api/src/process.rs index 907cb3db7..b66613c38 100644 --- a/crates/proc_macro_api/src/process.rs +++ b/crates/proc_macro_api/src/process.rs | |||
@@ -19,7 +19,7 @@ use crate::{ | |||
19 | 19 | ||
20 | #[derive(Debug, Default)] | 20 | #[derive(Debug, Default)] |
21 | pub(crate) struct ProcMacroProcessSrv { | 21 | pub(crate) struct ProcMacroProcessSrv { |
22 | inner: Option<Weak<Sender<Task>>>, | 22 | inner: Weak<Sender<Task>>, |
23 | } | 23 | } |
24 | 24 | ||
25 | #[derive(Debug)] | 25 | #[derive(Debug)] |
@@ -42,7 +42,7 @@ impl ProcMacroProcessSrv { | |||
42 | }); | 42 | }); |
43 | 43 | ||
44 | let task_tx = Arc::new(task_tx); | 44 | let task_tx = Arc::new(task_tx); |
45 | let srv = ProcMacroProcessSrv { inner: Some(Arc::downgrade(&task_tx)) }; | 45 | let srv = ProcMacroProcessSrv { inner: Arc::downgrade(&task_tx) }; |
46 | let thread = ProcMacroProcessThread { handle, sender: task_tx }; | 46 | let thread = ProcMacroProcessThread { handle, sender: task_tx }; |
47 | 47 | ||
48 | Ok((thread, srv)) | 48 | Ok((thread, srv)) |
@@ -79,13 +79,8 @@ impl ProcMacroProcessSrv { | |||
79 | where | 79 | where |
80 | R: TryFrom<Response, Error = &'static str>, | 80 | R: TryFrom<Response, Error = &'static str>, |
81 | { | 81 | { |
82 | let sender = match &self.inner { | ||
83 | None => return Err(tt::ExpansionError::Unknown("No sender is found.".to_string())), | ||
84 | Some(it) => it, | ||
85 | }; | ||
86 | |||
87 | let (result_tx, result_rx) = bounded(0); | 82 | let (result_tx, result_rx) = bounded(0); |
88 | let sender = match sender.upgrade() { | 83 | let sender = match self.inner.upgrade() { |
89 | None => { | 84 | None => { |
90 | return Err(tt::ExpansionError::Unknown("Proc macro process is closed.".into())) | 85 | return Err(tt::ExpansionError::Unknown("Proc macro process is closed.".into())) |
91 | } | 86 | } |
@@ -109,14 +104,9 @@ impl ProcMacroProcessSrv { | |||
109 | } | 104 | } |
110 | 105 | ||
111 | fn client_loop(task_rx: Receiver<Task>, mut process: Process) { | 106 | fn client_loop(task_rx: Receiver<Task>, mut process: Process) { |
112 | let (mut stdin, mut stdout) = match process.stdio() { | 107 | let (mut stdin, mut stdout) = process.stdio().expect("couldn't access child stdio"); |
113 | None => return, | ||
114 | Some(it) => it, | ||
115 | }; | ||
116 | |||
117 | for task in task_rx { | ||
118 | let Task { req, result_tx } = task; | ||
119 | 108 | ||
109 | for Task { req, result_tx } in task_rx { | ||
120 | match send_request(&mut stdin, &mut stdout, req) { | 110 | match send_request(&mut stdin, &mut stdout, req) { |
121 | Ok(res) => result_tx.send(res).unwrap(), | 111 | Ok(res) => result_tx.send(res).unwrap(), |
122 | Err(_err) => { | 112 | Err(_err) => { |