diff options
-rw-r--r-- | crates/ra_proc_macro/src/lib.rs | 11 | ||||
-rw-r--r-- | crates/ra_proc_macro/src/process.rs | 19 |
2 files changed, 22 insertions, 8 deletions
diff --git a/crates/ra_proc_macro/src/lib.rs b/crates/ra_proc_macro/src/lib.rs index 14a675db2..b200fd126 100644 --- a/crates/ra_proc_macro/src/lib.rs +++ b/crates/ra_proc_macro/src/lib.rs | |||
@@ -12,6 +12,7 @@ pub mod msg; | |||
12 | use process::{ProcMacroProcessSrv, ProcMacroProcessThread}; | 12 | use process::{ProcMacroProcessSrv, ProcMacroProcessThread}; |
13 | use ra_tt::{SmolStr, Subtree}; | 13 | use ra_tt::{SmolStr, Subtree}; |
14 | use std::{ | 14 | use std::{ |
15 | ffi::OsStr, | ||
15 | path::{Path, PathBuf}, | 16 | path::{Path, PathBuf}, |
16 | sync::Arc, | 17 | sync::Arc, |
17 | }; | 18 | }; |
@@ -56,10 +57,14 @@ pub struct ProcMacroClient { | |||
56 | } | 57 | } |
57 | 58 | ||
58 | impl ProcMacroClient { | 59 | impl ProcMacroClient { |
59 | pub fn extern_process<T: AsRef<str>>( | 60 | pub fn extern_process<I, S>( |
60 | process_path: &Path, | 61 | process_path: &Path, |
61 | args: &[T], | 62 | args: I, |
62 | ) -> Result<ProcMacroClient, std::io::Error> { | 63 | ) -> Result<ProcMacroClient, std::io::Error> |
64 | where | ||
65 | I: IntoIterator<Item = S>, | ||
66 | S: AsRef<OsStr>, | ||
67 | { | ||
63 | let (thread, process) = ProcMacroProcessSrv::run(process_path, args)?; | 68 | let (thread, process) = ProcMacroProcessSrv::run(process_path, args)?; |
64 | Ok(ProcMacroClient { | 69 | Ok(ProcMacroClient { |
65 | kind: ProcMacroClientKind::Process { process: Arc::new(process), thread }, | 70 | kind: ProcMacroClientKind::Process { process: Arc::new(process), thread }, |
diff --git a/crates/ra_proc_macro/src/process.rs b/crates/ra_proc_macro/src/process.rs index b5e8493ac..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 | |||
9 | use io::{BufRead, BufReader}; | 9 | use io::{BufRead, BufReader}; |
10 | use std::{ | 10 | use 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,9 +45,13 @@ impl Drop for Process { | |||
44 | } | 45 | } |
45 | 46 | ||
46 | impl Process { | 47 | impl Process { |
47 | fn run<T: AsRef<str>>(process_path: &Path, args: &[T]) -> 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()) |
49 | .args(args.iter().map(|it| it.as_ref())) | 54 | .args(args) |
50 | .stdin(Stdio::piped()) | 55 | .stdin(Stdio::piped()) |
51 | .stdout(Stdio::piped()) | 56 | .stdout(Stdio::piped()) |
52 | .stderr(Stdio::null()) | 57 | .stderr(Stdio::null()) |
@@ -75,10 +80,14 @@ impl Process { | |||
75 | } | 80 | } |
76 | 81 | ||
77 | impl ProcMacroProcessSrv { | 82 | impl ProcMacroProcessSrv { |
78 | pub fn run<T: AsRef<str>>( | 83 | pub fn run<I, S>( |
79 | process_path: &Path, | 84 | process_path: &Path, |
80 | args: &[T], | 85 | args: I, |
81 | ) -> Result<(ProcMacroProcessThread, ProcMacroProcessSrv), io::Error> { | 86 | ) -> Result<(ProcMacroProcessThread, ProcMacroProcessSrv), io::Error> |
87 | where | ||
88 | I: IntoIterator<Item = S>, | ||
89 | S: AsRef<OsStr>, | ||
90 | { | ||
82 | let process = Process::run(process_path, args)?; | 91 | let process = Process::run(process_path, args)?; |
83 | 92 | ||
84 | let (task_tx, task_rx) = bounded(0); | 93 | let (task_tx, task_rx) = bounded(0); |