Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/proc-macro-srv-cli/src/main.rs')
-rw-r--r--crates/proc-macro-srv-cli/src/main.rs30
1 files changed, 28 insertions, 2 deletions
diff --git a/crates/proc-macro-srv-cli/src/main.rs b/crates/proc-macro-srv-cli/src/main.rs
index f9689712ad..f6f6fdc864 100644
--- a/crates/proc-macro-srv-cli/src/main.rs
+++ b/crates/proc-macro-srv-cli/src/main.rs
@@ -8,6 +8,8 @@ extern crate rustc_driver as _;
use std::io;
+use proc_macro_api::msg::ServerConfig;
+
fn main() -> std::io::Result<()> {
let v = std::env::var("RUST_ANALYZER_INTERNALS_DO_NOT_USE");
match v.as_deref() {
@@ -26,8 +28,32 @@ fn main() -> std::io::Result<()> {
#[cfg(not(any(feature = "sysroot-abi", rust_analyzer)))]
fn run() -> io::Result<()> {
- eprintln!("proc-macro-srv-cli requires the `sysroot-abi` feature to be enabled");
- std::process::exit(70);
+ let err = "proc-macro-srv-cli needs to be compiled with the `sysroot-abi` feature to function";
+ eprintln!("{err}");
+ use proc_macro_api::msg::{self, Message};
+
+ let read_request = |buf: &mut String| msg::Request::read(&mut io::stdin().lock(), buf);
+
+ let write_response = |msg: msg::Response| msg.write(&mut io::stdout().lock());
+
+ let mut buf = String::new();
+
+ while let Some(req) = read_request(&mut buf)? {
+ let res = match req {
+ msg::Request::ListMacros { .. } => msg::Response::ListMacros(Err(err.to_owned())),
+ msg::Request::ExpandMacro(_) => {
+ msg::Response::ExpandMacro(Err(msg::PanicMessage(err.to_owned())))
+ }
+ msg::Request::ApiVersionCheck {} => {
+ msg::Response::ApiVersionCheck(proc_macro_api::msg::CURRENT_API_VERSION)
+ }
+ msg::Request::SetConfig(_) => {
+ msg::Response::SetConfig(ServerConfig { span_mode: msg::SpanMode::Id })
+ }
+ };
+ write_response(res)?
+ }
+ Ok(())
}
#[cfg(any(feature = "sysroot-abi", rust_analyzer))]