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.rs19
1 files changed, 15 insertions, 4 deletions
diff --git a/crates/ra_proc_macro/src/process.rs b/crates/ra_proc_macro/src/process.rs
index e8c85be38..f851570bc 100644
--- a/crates/ra_proc_macro/src/process.rs
+++ b/crates/ra_proc_macro/src/process.rs
@@ -9,6 +9,7 @@ use crate::rpc::{ExpansionResult, ExpansionTask, ListMacrosResult, ListMacrosTas
9use io::{BufRead, BufReader}; 9use io::{BufRead, BufReader};
10use std::{ 10use std::{
11 convert::{TryFrom, TryInto}, 11 convert::{TryFrom, TryInto},
12 ffi::OsStr,
12 io::{self, Write}, 13 io::{self, Write},
13 path::{Path, PathBuf}, 14 path::{Path, PathBuf},
14 process::{Child, Command, Stdio}, 15 process::{Child, Command, Stdio},
@@ -44,8 +45,13 @@ impl Drop for Process {
44} 45}
45 46
46impl Process { 47impl Process {
47 fn run(process_path: &Path) -> Result<Process, io::Error> { 48 fn run<I, S>(process_path: &Path, args: I) -> Result<Process, io::Error>
49 where
50 I: IntoIterator<Item = S>,
51 S: AsRef<OsStr>,
52 {
48 let child = Command::new(process_path.clone()) 53 let child = Command::new(process_path.clone())
54 .args(args)
49 .stdin(Stdio::piped()) 55 .stdin(Stdio::piped())
50 .stdout(Stdio::piped()) 56 .stdout(Stdio::piped())
51 .stderr(Stdio::null()) 57 .stderr(Stdio::null())
@@ -74,10 +80,15 @@ impl Process {
74} 80}
75 81
76impl ProcMacroProcessSrv { 82impl ProcMacroProcessSrv {
77 pub fn run( 83 pub fn run<I, S>(
78 process_path: &Path, 84 process_path: &Path,
79 ) -> Result<(ProcMacroProcessThread, ProcMacroProcessSrv), io::Error> { 85 args: I,
80 let process = Process::run(process_path)?; 86 ) -> Result<(ProcMacroProcessThread, ProcMacroProcessSrv), io::Error>
87 where
88 I: IntoIterator<Item = S>,
89 S: AsRef<OsStr>,
90 {
91 let process = Process::run(process_path, args)?;
81 92
82 let (task_tx, task_rx) = bounded(0); 93 let (task_tx, task_rx) = bounded(0);
83 let handle = jod_thread::spawn(move || { 94 let handle = jod_thread::spawn(move || {