Remove proc-macro server command from the rust-analyzer binary

This commit is contained in:
Lukas Wirth 2023-04-26 08:06:15 +02:00
parent 943d2a8a1c
commit c21860bd6a
15 changed files with 109 additions and 162 deletions

View file

@ -13,7 +13,6 @@ mod version;
use paths::AbsPathBuf;
use std::{
ffi::OsStr,
fmt, io,
sync::{Arc, Mutex},
};
@ -103,11 +102,8 @@ pub struct MacroPanic {
impl ProcMacroServer {
/// Spawns an external process as the proc macro server and returns a client connected to it.
pub fn spawn(
process_path: AbsPathBuf,
args: impl IntoIterator<Item = impl AsRef<OsStr>> + Clone,
) -> io::Result<ProcMacroServer> {
let process = ProcMacroProcessSrv::run(process_path, args)?;
pub fn spawn(process_path: AbsPathBuf) -> io::Result<ProcMacroServer> {
let process = ProcMacroProcessSrv::run(process_path)?;
Ok(ProcMacroServer { process: Arc::new(Mutex::new(process)) })
}

View file

@ -1,7 +1,6 @@
//! Handle process life-time and message passing for proc-macro client
use std::{
ffi::{OsStr, OsString},
io::{self, BufRead, BufReader, Write},
process::{Child, ChildStdin, ChildStdout, Command, Stdio},
};
@ -23,12 +22,9 @@ pub(crate) struct ProcMacroProcessSrv {
}
impl ProcMacroProcessSrv {
pub(crate) fn run(
process_path: AbsPathBuf,
args: impl IntoIterator<Item = impl AsRef<OsStr>> + Clone,
) -> io::Result<ProcMacroProcessSrv> {
pub(crate) fn run(process_path: AbsPathBuf) -> io::Result<ProcMacroProcessSrv> {
let create_srv = |null_stderr| {
let mut process = Process::run(process_path.clone(), args.clone(), null_stderr)?;
let mut process = Process::run(process_path.clone(), null_stderr)?;
let (stdin, stdout) = process.stdio().expect("couldn't access child stdio");
io::Result::Ok(ProcMacroProcessSrv { _process: process, stdin, stdout, version: 0 })
@ -100,13 +96,8 @@ struct Process {
}
impl Process {
fn run(
path: AbsPathBuf,
args: impl IntoIterator<Item = impl AsRef<OsStr>>,
null_stderr: bool,
) -> io::Result<Process> {
let args: Vec<OsString> = args.into_iter().map(|s| s.as_ref().into()).collect();
let child = JodChild(mk_child(&path, args, null_stderr)?);
fn run(path: AbsPathBuf, null_stderr: bool) -> io::Result<Process> {
let child = JodChild(mk_child(&path, null_stderr)?);
Ok(Process { child })
}
@ -119,13 +110,8 @@ impl Process {
}
}
fn mk_child(
path: &AbsPath,
args: impl IntoIterator<Item = impl AsRef<OsStr>>,
null_stderr: bool,
) -> io::Result<Child> {
fn mk_child(path: &AbsPath, null_stderr: bool) -> io::Result<Child> {
Command::new(path.as_os_str())
.args(args)
.env("RUST_ANALYZER_INTERNALS_DO_NOT_USE", "this is unstable")
.stdin(Stdio::piped())
.stdout(Stdio::piped())