aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_proc_macro/src/process.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_proc_macro/src/process.rs')
-rw-r--r--crates/ra_proc_macro/src/process.rs31
1 files changed, 13 insertions, 18 deletions
diff --git a/crates/ra_proc_macro/src/process.rs b/crates/ra_proc_macro/src/process.rs
index f851570bc..e24944af4 100644
--- a/crates/ra_proc_macro/src/process.rs
+++ b/crates/ra_proc_macro/src/process.rs
@@ -45,24 +45,23 @@ impl Drop for Process {
45} 45}
46 46
47impl Process { 47impl Process {
48 fn run<I, S>(process_path: &Path, args: I) -> Result<Process, io::Error> 48 fn run(
49 where 49 process_path: PathBuf,
50 I: IntoIterator<Item = S>, 50 args: impl IntoIterator<Item = impl AsRef<OsStr>>,
51 S: AsRef<OsStr>, 51 ) -> io::Result<Process> {
52 { 52 let child = Command::new(&process_path)
53 let child = Command::new(process_path.clone())
54 .args(args) 53 .args(args)
55 .stdin(Stdio::piped()) 54 .stdin(Stdio::piped())
56 .stdout(Stdio::piped()) 55 .stdout(Stdio::piped())
57 .stderr(Stdio::null()) 56 .stderr(Stdio::null())
58 .spawn()?; 57 .spawn()?;
59 58
60 Ok(Process { path: process_path.into(), child }) 59 Ok(Process { path: process_path, child })
61 } 60 }
62 61
63 fn restart(&mut self) -> Result<(), io::Error> { 62 fn restart(&mut self) -> io::Result<()> {
64 let _ = self.child.kill(); 63 let _ = self.child.kill();
65 self.child = Command::new(self.path.clone()) 64 self.child = Command::new(&self.path)
66 .stdin(Stdio::piped()) 65 .stdin(Stdio::piped())
67 .stdout(Stdio::piped()) 66 .stdout(Stdio::piped())
68 .stderr(Stdio::null()) 67 .stderr(Stdio::null())
@@ -80,14 +79,10 @@ impl Process {
80} 79}
81 80
82impl ProcMacroProcessSrv { 81impl ProcMacroProcessSrv {
83 pub fn run<I, S>( 82 pub fn run(
84 process_path: &Path, 83 process_path: PathBuf,
85 args: I, 84 args: impl IntoIterator<Item = impl AsRef<OsStr>>,
86 ) -> Result<(ProcMacroProcessThread, ProcMacroProcessSrv), io::Error> 85 ) -> io::Result<(ProcMacroProcessThread, ProcMacroProcessSrv)> {
87 where
88 I: IntoIterator<Item = S>,
89 S: AsRef<OsStr>,
90 {
91 let process = Process::run(process_path, args)?; 86 let process = Process::run(process_path, args)?;
92 87
93 let (task_tx, task_rx) = bounded(0); 88 let (task_tx, task_rx) = bounded(0);
@@ -201,7 +196,7 @@ fn send_request(
201 mut writer: &mut impl Write, 196 mut writer: &mut impl Write,
202 mut reader: &mut impl BufRead, 197 mut reader: &mut impl BufRead,
203 req: Request, 198 req: Request,
204) -> Result<Option<Response>, io::Error> { 199) -> io::Result<Option<Response>> {
205 req.write(&mut writer)?; 200 req.write(&mut writer)?;
206 Ok(Response::read(&mut reader)?) 201 Ok(Response::read(&mut reader)?)
207} 202}