Skip to content

Commit b4c5ee3

Browse files
committed
Fix extern_process args
1 parent 177bece commit b4c5ee3

File tree

2 files changed

+22
-8
lines changed

2 files changed

+22
-8
lines changed

crates/ra_proc_macro/src/lib.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ pub mod msg;
1212
use process::{ProcMacroProcessSrv, ProcMacroProcessThread};
1313
use ra_tt::{SmolStr, Subtree};
1414
use std::{
15+
ffi::OsStr,
1516
path::{Path, PathBuf},
1617
sync::Arc,
1718
};
@@ -56,10 +57,14 @@ pub struct ProcMacroClient {
5657
}
5758

5859
impl ProcMacroClient {
59-
pub fn extern_process<T: AsRef<str>>(
60+
pub fn extern_process<I, S>(
6061
process_path: &Path,
61-
args: &[T],
62-
) -> Result<ProcMacroClient, std::io::Error> {
62+
args: I,
63+
) -> Result<ProcMacroClient, std::io::Error>
64+
where
65+
I: IntoIterator<Item = S>,
66+
S: AsRef<OsStr>,
67+
{
6368
let (thread, process) = ProcMacroProcessSrv::run(process_path, args)?;
6469
Ok(ProcMacroClient {
6570
kind: ProcMacroClientKind::Process { process: Arc::new(process), thread },

crates/ra_proc_macro/src/process.rs

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ use crate::rpc::{ExpansionResult, ExpansionTask, ListMacrosResult, ListMacrosTas
99
use io::{BufRead, BufReader};
1010
use std::{
1111
convert::{TryFrom, TryInto},
12+
ffi::OsStr,
1213
io::{self, Write},
1314
path::{Path, PathBuf},
1415
process::{Child, Command, Stdio},
@@ -44,9 +45,13 @@ impl Drop for Process {
4445
}
4546

4647
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+
{
4853
let child = Command::new(process_path.clone())
49-
.args(args.iter().map(|it| it.as_ref()))
54+
.args(args)
5055
.stdin(Stdio::piped())
5156
.stdout(Stdio::piped())
5257
.stderr(Stdio::null())
@@ -75,10 +80,14 @@ impl Process {
7580
}
7681

7782
impl ProcMacroProcessSrv {
78-
pub fn run<T: AsRef<str>>(
83+
pub fn run<I, S>(
7984
process_path: &Path,
80-
args: &[T],
81-
) -> Result<(ProcMacroProcessThread, ProcMacroProcessSrv), io::Error> {
85+
args: I,
86+
) -> Result<(ProcMacroProcessThread, ProcMacroProcessSrv), io::Error>
87+
where
88+
I: IntoIterator<Item = S>,
89+
S: AsRef<OsStr>,
90+
{
8291
let process = Process::run(process_path, args)?;
8392

8493
let (task_tx, task_rx) = bounded(0);

0 commit comments

Comments
 (0)