rust_analyzer_proc_macro_srv/
main.rs

1//! A standalone binary for `proc-macro-srv`.
2//! Driver for proc macro server
3#![cfg_attr(feature = "in-rust-tree", feature(rustc_private))]
4#![cfg_attr(not(feature = "sysroot-abi"), allow(unused_crate_dependencies))]
5#![allow(clippy::print_stderr)]
6
7#[cfg(feature = "in-rust-tree")]
8extern crate rustc_driver as _;
9
10#[cfg(any(feature = "sysroot-abi", rust_analyzer))]
11mod main_loop;
12#[cfg(any(feature = "sysroot-abi", rust_analyzer))]
13use main_loop::run;
14
15fn main() -> std::io::Result<()> {
16    let v = std::env::var("RUST_ANALYZER_INTERNALS_DO_NOT_USE");
17    if v.is_err() {
18        eprintln!(
19            "This is an IDE implementation detail, you can use this tool by exporting RUST_ANALYZER_INTERNALS_DO_NOT_USE."
20        );
21        eprintln!(
22            "Note that this tool's API is highly unstable and may break without prior notice"
23        );
24        std::process::exit(122);
25    }
26
27    run()
28}
29
30#[cfg(not(any(feature = "sysroot-abi", rust_analyzer)))]
31fn run() -> std::io::Result<()> {
32    Err(std::io::Error::new(
33        std::io::ErrorKind::Unsupported,
34        "proc-macro-srv-cli needs to be compiled with the `sysroot-abi` feature to function"
35            .to_owned(),
36    ))
37}