mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-30 04:56:25 +03:00
Fix extern_process args
This commit is contained in:
@@ -12,6 +12,7 @@
|
||||
use process::{ProcMacroProcessSrv, ProcMacroProcessThread};
|
||||
use ra_tt::{SmolStr, Subtree};
|
||||
use std::{
|
||||
ffi::OsStr,
|
||||
path::{Path, PathBuf},
|
||||
sync::Arc,
|
||||
};
|
||||
@@ -56,10 +57,14 @@ pub struct ProcMacroClient {
|
||||
}
|
||||
|
||||
impl ProcMacroClient {
|
||||
pub fn extern_process<T: AsRef<str>>(
|
||||
pub fn extern_process<I, S>(
|
||||
process_path: &Path,
|
||||
args: &[T],
|
||||
) -> Result<ProcMacroClient, std::io::Error> {
|
||||
args: I,
|
||||
) -> Result<ProcMacroClient, std::io::Error>
|
||||
where
|
||||
I: IntoIterator<Item = S>,
|
||||
S: AsRef<OsStr>,
|
||||
{
|
||||
let (thread, process) = ProcMacroProcessSrv::run(process_path, args)?;
|
||||
Ok(ProcMacroClient {
|
||||
kind: ProcMacroClientKind::Process { process: Arc::new(process), thread },
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
use io::{BufRead, BufReader};
|
||||
use std::{
|
||||
convert::{TryFrom, TryInto},
|
||||
ffi::OsStr,
|
||||
io::{self, Write},
|
||||
path::{Path, PathBuf},
|
||||
process::{Child, Command, Stdio},
|
||||
@@ -44,9 +45,13 @@ fn drop(&mut self) {
|
||||
}
|
||||
|
||||
impl Process {
|
||||
fn run<T: AsRef<str>>(process_path: &Path, args: &[T]) -> Result<Process, io::Error> {
|
||||
fn run<I, S>(process_path: &Path, args: I) -> Result<Process, io::Error>
|
||||
where
|
||||
I: IntoIterator<Item = S>,
|
||||
S: AsRef<OsStr>,
|
||||
{
|
||||
let child = Command::new(process_path.clone())
|
||||
.args(args.iter().map(|it| it.as_ref()))
|
||||
.args(args)
|
||||
.stdin(Stdio::piped())
|
||||
.stdout(Stdio::piped())
|
||||
.stderr(Stdio::null())
|
||||
@@ -75,10 +80,14 @@ fn stdio(&mut self) -> Option<(impl Write, impl BufRead)> {
|
||||
}
|
||||
|
||||
impl ProcMacroProcessSrv {
|
||||
pub fn run<T: AsRef<str>>(
|
||||
pub fn run<I, S>(
|
||||
process_path: &Path,
|
||||
args: &[T],
|
||||
) -> Result<(ProcMacroProcessThread, ProcMacroProcessSrv), io::Error> {
|
||||
args: I,
|
||||
) -> Result<(ProcMacroProcessThread, ProcMacroProcessSrv), io::Error>
|
||||
where
|
||||
I: IntoIterator<Item = S>,
|
||||
S: AsRef<OsStr>,
|
||||
{
|
||||
let process = Process::run(process_path, args)?;
|
||||
|
||||
let (task_tx, task_rx) = bounded(0);
|
||||
|
||||
Reference in New Issue
Block a user