@@ -8,6 +8,8 @@ extern crate rustc_driver as _;
8
8
9
9
use std:: io;
10
10
11
+ use proc_macro_api:: msg:: ServerConfig ;
12
+
11
13
fn main ( ) -> std:: io:: Result < ( ) > {
12
14
let v = std:: env:: var ( "RUST_ANALYZER_INTERNALS_DO_NOT_USE" ) ;
13
15
match v. as_deref ( ) {
@@ -26,8 +28,32 @@ fn main() -> std::io::Result<()> {
26
28
27
29
#[ cfg( not( any( feature = "sysroot-abi" , rust_analyzer) ) ) ]
28
30
fn 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 ( ( ) )
31
57
}
32
58
33
59
#[ cfg( any( feature = "sysroot-abi" , rust_analyzer) ) ]
0 commit comments