aboutsummaryrefslogtreecommitdiff
path: root/crates/proc_macro_api
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2020-12-04 17:09:12 +0000
committerGitHub <[email protected]>2020-12-04 17:09:12 +0000
commit6943b530235df98c1ceec27d7f80a974511d3c7e (patch)
treecea2580dd236403e6dbf3f6d9a9a69322f06275c /crates/proc_macro_api
parentb988c6f84e06bdc5562c70f28586b9eeaae3a39c (diff)
parentb85714972081ac7d19d98008b7466d37f6d38432 (diff)
Merge #6722
6722: Minor proc macro cleanups r=jonas-schievink a=jonas-schievink bors r+ Co-authored-by: Jonas Schievink <[email protected]>
Diffstat (limited to 'crates/proc_macro_api')
-rw-r--r--crates/proc_macro_api/src/process.rs20
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)]
21pub(crate) struct ProcMacroProcessSrv { 21pub(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
111fn client_loop(task_rx: Receiver<Task>, mut process: Process) { 106fn 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) => {