diff options
author | veetaha <[email protected]> | 2020-04-20 19:26:10 +0100 |
---|---|---|
committer | veetaha <[email protected]> | 2020-04-20 19:37:02 +0100 |
commit | d3019164dcbb46f8c369ed4efff79de5a42a95a8 (patch) | |
tree | ff0583b3fab68d9e6d0b7c020b9225e665c47b1f /crates/ra_proc_macro/src/lib.rs | |
parent | 36840bd6c71eaf18cdf418c92af51c24e547a4a7 (diff) |
ra_proc_macro: cleanups here and there
Diffstat (limited to 'crates/ra_proc_macro/src/lib.rs')
-rw-r--r-- | crates/ra_proc_macro/src/lib.rs | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/crates/ra_proc_macro/src/lib.rs b/crates/ra_proc_macro/src/lib.rs index b200fd126..004943b9e 100644 --- a/crates/ra_proc_macro/src/lib.rs +++ b/crates/ra_proc_macro/src/lib.rs | |||
@@ -2,7 +2,7 @@ | |||
2 | //! | 2 | //! |
3 | //! We separate proc-macro expanding logic to an extern program to allow | 3 | //! We separate proc-macro expanding logic to an extern program to allow |
4 | //! different implementations (e.g. wasm or dylib loading). And this crate | 4 | //! different implementations (e.g. wasm or dylib loading). And this crate |
5 | //! is used to provide basic infrastructure for communication between two | 5 | //! is used to provide basic infrastructure for communication between two |
6 | //! processes: Client (RA itself), Server (the external program) | 6 | //! processes: Client (RA itself), Server (the external program) |
7 | 7 | ||
8 | mod rpc; | 8 | mod rpc; |
@@ -13,6 +13,7 @@ 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 | ffi::OsStr, |
16 | io, | ||
16 | path::{Path, PathBuf}, | 17 | path::{Path, PathBuf}, |
17 | sync::Arc, | 18 | sync::Arc, |
18 | }; | 19 | }; |
@@ -57,14 +58,10 @@ pub struct ProcMacroClient { | |||
57 | } | 58 | } |
58 | 59 | ||
59 | impl ProcMacroClient { | 60 | impl ProcMacroClient { |
60 | pub fn extern_process<I, S>( | 61 | pub fn extern_process( |
61 | process_path: &Path, | 62 | process_path: PathBuf, |
62 | args: I, | 63 | args: impl IntoIterator<Item = impl AsRef<OsStr>>, |
63 | ) -> Result<ProcMacroClient, std::io::Error> | 64 | ) -> io::Result<ProcMacroClient> { |
64 | where | ||
65 | I: IntoIterator<Item = S>, | ||
66 | S: AsRef<OsStr>, | ||
67 | { | ||
68 | let (thread, process) = ProcMacroProcessSrv::run(process_path, args)?; | 65 | let (thread, process) = ProcMacroProcessSrv::run(process_path, args)?; |
69 | Ok(ProcMacroClient { | 66 | Ok(ProcMacroClient { |
70 | kind: ProcMacroClientKind::Process { process: Arc::new(process), thread }, | 67 | kind: ProcMacroClientKind::Process { process: Arc::new(process), thread }, |
@@ -84,7 +81,7 @@ impl ProcMacroClient { | |||
84 | ProcMacroClientKind::Process { process, .. } => { | 81 | ProcMacroClientKind::Process { process, .. } => { |
85 | let macros = match process.find_proc_macros(dylib_path) { | 82 | let macros = match process.find_proc_macros(dylib_path) { |
86 | Err(err) => { | 83 | Err(err) => { |
87 | eprintln!("Fail to find proc macro. Error: {:#?}", err); | 84 | eprintln!("Failed to find proc macros. Error: {:#?}", err); |
88 | return vec![]; | 85 | return vec![]; |
89 | } | 86 | } |
90 | Ok(macros) => macros, | 87 | Ok(macros) => macros, |