mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-05 08:00:48 +00:00
Drop support for non-syroot proc macro ABIs
This commit is contained in:
parent
8ea1afce28
commit
7498ec730e
28 changed files with 140 additions and 4617 deletions
54
crates/proc-macro-srv-cli/src/lib.rs
Normal file
54
crates/proc-macro-srv-cli/src/lib.rs
Normal file
|
@ -0,0 +1,54 @@
|
|||
//! Driver for proc macro server
|
||||
use std::io;
|
||||
|
||||
use proc_macro_api::msg::{self, Message};
|
||||
|
||||
#[cfg(feature = "sysroot-abi")]
|
||||
pub fn run() -> io::Result<()> {
|
||||
let mut srv = proc_macro_srv::ProcMacroSrv::default();
|
||||
let mut buf = String::new();
|
||||
|
||||
while let Some(req) = read_request(&mut buf)? {
|
||||
let res = match req {
|
||||
msg::Request::ListMacros { dylib_path } => {
|
||||
msg::Response::ListMacros(srv.list_macros(&dylib_path))
|
||||
}
|
||||
msg::Request::ExpandMacro(task) => msg::Response::ExpandMacro(srv.expand(task)),
|
||||
msg::Request::ApiVersionCheck {} => {
|
||||
msg::Response::ApiVersionCheck(proc_macro_api::msg::CURRENT_API_VERSION)
|
||||
}
|
||||
};
|
||||
write_response(res)?
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
#[cfg(not(feature = "sysroot-abi"))]
|
||||
pub fn run() -> io::Result<()> {
|
||||
let mut buf = String::new();
|
||||
|
||||
while let Some(req) = read_request(&mut buf)? {
|
||||
let res = match req {
|
||||
msg::Request::ListMacros { .. } => {
|
||||
msg::Response::ListMacros(Err("server is built without sysroot support".to_owned()))
|
||||
}
|
||||
msg::Request::ExpandMacro(..) => msg::Response::ExpandMacro(Err(msg::PanicMessage(
|
||||
"server is built without sysroot support".to_owned(),
|
||||
))),
|
||||
msg::Request::ApiVersionCheck {} => {
|
||||
msg::Response::ApiVersionCheck(proc_macro_api::msg::CURRENT_API_VERSION)
|
||||
}
|
||||
};
|
||||
write_response(res)?
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn read_request(buf: &mut String) -> io::Result<Option<msg::Request>> {
|
||||
msg::Request::read(&mut io::stdin().lock(), buf)
|
||||
}
|
||||
|
||||
fn write_response(msg: msg::Response) -> io::Result<()> {
|
||||
msg.write(&mut io::stdout().lock())
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue