@@ -8,6 +8,8 @@ extern crate rustc_driver as _;
88
99use std:: io;
1010
11+ use proc_macro_api:: msg:: ServerConfig ;
12+
1113fn main ( ) -> std:: io:: Result < ( ) > {
1214 let v = std:: env:: var ( "RUST_ANALYZER_INTERNALS_DO_NOT_USE" ) ;
1315 match v. as_deref ( ) {
@@ -26,8 +28,32 @@ fn main() -> std::io::Result<()> {
2628
2729#[ cfg( not( any( feature = "sysroot-abi" , rust_analyzer) ) ) ]
2830fn run ( ) -> io:: Result < ( ) > {
29- eprintln ! ( "proc-macro-srv-cli requires the `sysroot-abi` feature to be enabled" ) ;
30- std:: process:: exit ( 70 ) ;
31+ let err = "proc-macro-srv-cli needs to be compiled with the `sysroot-abi` feature to function" ;
32+ eprintln ! ( "{err}" ) ;
33+ use proc_macro_api:: msg:: { self , Message } ;
34+
35+ let read_request = |buf : & mut String | msg:: Request :: read ( & mut io:: stdin ( ) . lock ( ) , buf) ;
36+
37+ let write_response = |msg : msg:: Response | msg. write ( & mut io:: stdout ( ) . lock ( ) ) ;
38+
39+ let mut buf = String :: new ( ) ;
40+
41+ while let Some ( req) = read_request ( & mut buf) ? {
42+ let res = match req {
43+ msg:: Request :: ListMacros { .. } => msg:: Response :: ListMacros ( Err ( err. to_owned ( ) ) ) ,
44+ msg:: Request :: ExpandMacro ( _) => {
45+ msg:: Response :: ExpandMacro ( Err ( msg:: PanicMessage ( err. to_owned ( ) ) ) )
46+ }
47+ msg:: Request :: ApiVersionCheck { } => {
48+ msg:: Response :: ApiVersionCheck ( proc_macro_api:: msg:: CURRENT_API_VERSION )
49+ }
50+ msg:: Request :: SetConfig ( _) => {
51+ msg:: Response :: SetConfig ( ServerConfig { span_mode : msg:: SpanMode :: Id } )
52+ }
53+ } ;
54+ write_response ( res) ?
55+ }
56+ Ok ( ( ) )
3157}
3258
3359#[ cfg( any( feature = "sysroot-abi" , rust_analyzer) ) ]
0 commit comments