Unnamed repository; edit this file 'description' to name the repository.
| -rw-r--r-- | crates/proc-macro-api/src/bidirectional_protocol.rs | 9 | ||||
| -rw-r--r-- | crates/proc-macro-api/src/bidirectional_protocol/msg.rs | 1 | ||||
| -rw-r--r-- | crates/proc-macro-api/src/legacy_protocol.rs | 8 | ||||
| -rw-r--r-- | crates/proc-macro-api/src/lib.rs | 3 | ||||
| -rw-r--r-- | crates/proc-macro-api/src/process.rs | 45 | ||||
| -rw-r--r-- | crates/proc-macro-srv-cli/src/main.rs | 5 | ||||
| -rw-r--r-- | crates/proc-macro-srv-cli/src/main_loop.rs | 1 |
7 files changed, 16 insertions, 56 deletions
diff --git a/crates/proc-macro-api/src/bidirectional_protocol.rs b/crates/proc-macro-api/src/bidirectional_protocol.rs index e44723a6a3..5996f88298 100644 --- a/crates/proc-macro-api/src/bidirectional_protocol.rs +++ b/crates/proc-macro-api/src/bidirectional_protocol.rs @@ -212,14 +212,7 @@ fn run_request( if let Some(err) = srv.exited() { return Err(err.clone()); } - - match srv.use_postcard() { - true => srv.run_bidirectional::<PostcardProtocol>(msg, callback), - false => Err(ServerError { - message: "bidirectional messaging does not support JSON".to_owned(), - io: None, - }), - } + srv.run_bidirectional::<PostcardProtocol>(msg, callback) } pub fn reject_subrequests(req: SubRequest) -> Result<SubResponse, ServerError> { diff --git a/crates/proc-macro-api/src/bidirectional_protocol/msg.rs b/crates/proc-macro-api/src/bidirectional_protocol/msg.rs index 57e7b1ee8f..c56ed51916 100644 --- a/crates/proc-macro-api/src/bidirectional_protocol/msg.rs +++ b/crates/proc-macro-api/src/bidirectional_protocol/msg.rs @@ -70,7 +70,6 @@ pub struct ExpandMacro { pub lib: Utf8PathBuf, pub env: Vec<(String, String)>, pub current_dir: Option<String>, - #[serde(flatten)] pub data: ExpandMacroData, } diff --git a/crates/proc-macro-api/src/legacy_protocol.rs b/crates/proc-macro-api/src/legacy_protocol.rs index 4524d1b66b..aabe5a0118 100644 --- a/crates/proc-macro-api/src/legacy_protocol.rs +++ b/crates/proc-macro-api/src/legacy_protocol.rs @@ -19,7 +19,7 @@ use crate::{ }, process::ProcMacroServerProcess, transport::codec::Codec, - transport::codec::{json::JsonProtocol, postcard::PostcardProtocol}, + transport::codec::json::JsonProtocol, version, }; @@ -148,11 +148,7 @@ fn send_task(srv: &ProcMacroServerProcess, req: Request) -> Result<Response, Ser return Err(server_error.clone()); } - if srv.use_postcard() { - srv.send_task::<_, _, PostcardProtocol>(send_request::<PostcardProtocol>, req) - } else { - srv.send_task::<_, _, JsonProtocol>(send_request::<JsonProtocol>, req) - } + srv.send_task::<_, _, JsonProtocol>(send_request::<JsonProtocol>, req) } /// Sends a request to the server and reads the response. diff --git a/crates/proc-macro-api/src/lib.rs b/crates/proc-macro-api/src/lib.rs index 822809943a..01195c10fe 100644 --- a/crates/proc-macro-api/src/lib.rs +++ b/crates/proc-macro-api/src/lib.rs @@ -49,8 +49,6 @@ pub mod version { pub enum ProtocolFormat { /// JSON-based legacy protocol (newline-delimited JSON). JsonLegacy, - /// Postcard-based legacy protocol (COBS-encoded postcard). - PostcardLegacy, /// Bidirectional postcard protocol with sub-request support. BidirectionalPostcardPrototype, } @@ -59,7 +57,6 @@ impl fmt::Display for ProtocolFormat { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { ProtocolFormat::JsonLegacy => write!(f, "json-legacy"), - ProtocolFormat::PostcardLegacy => write!(f, "postcard-legacy"), ProtocolFormat::BidirectionalPostcardPrototype => { write!(f, "bidirectional-postcard-prototype") } diff --git a/crates/proc-macro-api/src/process.rs b/crates/proc-macro-api/src/process.rs index 4f87621587..cd387dad0d 100644 --- a/crates/proc-macro-api/src/process.rs +++ b/crates/proc-macro-api/src/process.rs @@ -43,7 +43,6 @@ impl std::fmt::Debug for ProcMacroServerProcess { #[derive(Debug, Clone)] pub(crate) enum Protocol { LegacyJson { mode: SpanMode }, - LegacyPostcard { mode: SpanMode }, BidirectionalPostcardPrototype { mode: SpanMode }, } @@ -136,7 +135,6 @@ impl ProcMacroServerProcess { { &[ Some(ProtocolFormat::BidirectionalPostcardPrototype), - Some(ProtocolFormat::PostcardLegacy), Some(ProtocolFormat::JsonLegacy), ] } else { @@ -155,9 +153,6 @@ impl ProcMacroServerProcess { Some(ProtocolFormat::BidirectionalPostcardPrototype) => { Protocol::BidirectionalPostcardPrototype { mode: SpanMode::Id } } - Some(ProtocolFormat::PostcardLegacy) => { - Protocol::LegacyPostcard { mode: SpanMode::Id } - } Some(ProtocolFormat::JsonLegacy) | None => { Protocol::LegacyJson { mode: SpanMode::Id } } @@ -185,7 +180,6 @@ impl ProcMacroServerProcess { { match &mut srv.protocol { Protocol::LegacyJson { mode } - | Protocol::LegacyPostcard { mode } | Protocol::BidirectionalPostcardPrototype { mode } => *mode = new_mode, } } @@ -208,10 +202,6 @@ impl ProcMacroServerProcess { self.exited.get().map(|it| &it.0) } - pub(crate) fn use_postcard(&self) -> bool { - matches!(self.protocol, Protocol::LegacyPostcard { .. }) - } - /// Retrieves the API version of the proc-macro server. pub(crate) fn version(&self) -> u32 { self.version @@ -221,7 +211,6 @@ impl ProcMacroServerProcess { pub(crate) fn rust_analyzer_spans(&self) -> bool { match self.protocol { Protocol::LegacyJson { mode } => mode == SpanMode::RustAnalyzer, - Protocol::LegacyPostcard { mode } => mode == SpanMode::RustAnalyzer, Protocol::BidirectionalPostcardPrototype { mode } => mode == SpanMode::RustAnalyzer, } } @@ -229,9 +218,7 @@ impl ProcMacroServerProcess { /// Checks the API version of the running proc-macro server. fn version_check(&self, callback: Option<SubCallback<'_>>) -> Result<u32, ServerError> { match self.protocol { - Protocol::LegacyJson { .. } | Protocol::LegacyPostcard { .. } => { - legacy_protocol::version_check(self) - } + Protocol::LegacyJson { .. } => legacy_protocol::version_check(self), Protocol::BidirectionalPostcardPrototype { .. } => { let cb = callback.expect("callback required for bidirectional protocol"); bidirectional_protocol::version_check(self, cb) @@ -245,9 +232,7 @@ impl ProcMacroServerProcess { callback: Option<SubCallback<'_>>, ) -> Result<SpanMode, ServerError> { match self.protocol { - Protocol::LegacyJson { .. } | Protocol::LegacyPostcard { .. } => { - legacy_protocol::enable_rust_analyzer_spans(self) - } + Protocol::LegacyJson { .. } => legacy_protocol::enable_rust_analyzer_spans(self), Protocol::BidirectionalPostcardPrototype { .. } => { let cb = callback.expect("callback required for bidirectional protocol"); bidirectional_protocol::enable_rust_analyzer_spans(self, cb) @@ -262,9 +247,7 @@ impl ProcMacroServerProcess { callback: Option<SubCallback<'_>>, ) -> Result<Result<Vec<(String, ProcMacroKind)>, String>, ServerError> { match self.protocol { - Protocol::LegacyJson { .. } | Protocol::LegacyPostcard { .. } => { - legacy_protocol::find_proc_macros(self, dylib_path) - } + Protocol::LegacyJson { .. } => legacy_protocol::find_proc_macros(self, dylib_path), Protocol::BidirectionalPostcardPrototype { .. } => { let cb = callback.expect("callback required for bidirectional protocol"); bidirectional_protocol::find_proc_macros(self, dylib_path, cb) @@ -285,18 +268,16 @@ impl ProcMacroServerProcess { callback: Option<SubCallback<'_>>, ) -> Result<Result<tt::TopSubtree, String>, ServerError> { match self.protocol { - Protocol::LegacyJson { .. } | Protocol::LegacyPostcard { .. } => { - legacy_protocol::expand( - proc_macro, - subtree, - attr, - env, - def_site, - call_site, - mixed_site, - current_dir, - ) - } + Protocol::LegacyJson { .. } => legacy_protocol::expand( + proc_macro, + subtree, + attr, + env, + def_site, + call_site, + mixed_site, + current_dir, + ), Protocol::BidirectionalPostcardPrototype { .. } => bidirectional_protocol::expand( proc_macro, subtree, diff --git a/crates/proc-macro-srv-cli/src/main.rs b/crates/proc-macro-srv-cli/src/main.rs index a246d4d3f2..928753659f 100644 --- a/crates/proc-macro-srv-cli/src/main.rs +++ b/crates/proc-macro-srv-cli/src/main.rs @@ -67,7 +67,6 @@ impl ValueEnum for ProtocolFormatArg { fn value_variants<'a>() -> &'a [Self] { &[ ProtocolFormatArg(ProtocolFormat::JsonLegacy), - ProtocolFormatArg(ProtocolFormat::PostcardLegacy), ProtocolFormatArg(ProtocolFormat::BidirectionalPostcardPrototype), ] } @@ -75,9 +74,6 @@ impl ValueEnum for ProtocolFormatArg { fn to_possible_value(&self) -> Option<clap::builder::PossibleValue> { match self.0 { ProtocolFormat::JsonLegacy => Some(clap::builder::PossibleValue::new("json-legacy")), - ProtocolFormat::PostcardLegacy => { - Some(clap::builder::PossibleValue::new("postcard-legacy")) - } ProtocolFormat::BidirectionalPostcardPrototype => { Some(clap::builder::PossibleValue::new("bidirectional-postcard-prototype")) } @@ -87,7 +83,6 @@ impl ValueEnum for ProtocolFormatArg { fn from_str(input: &str, _ignore_case: bool) -> Result<Self, String> { match input { "json-legacy" => Ok(ProtocolFormatArg(ProtocolFormat::JsonLegacy)), - "postcard-legacy" => Ok(ProtocolFormatArg(ProtocolFormat::PostcardLegacy)), "bidirectional-postcard-prototype" => { Ok(ProtocolFormatArg(ProtocolFormat::BidirectionalPostcardPrototype)) } diff --git a/crates/proc-macro-srv-cli/src/main_loop.rs b/crates/proc-macro-srv-cli/src/main_loop.rs index 5180ede9fb..70e1e091c1 100644 --- a/crates/proc-macro-srv-cli/src/main_loop.rs +++ b/crates/proc-macro-srv-cli/src/main_loop.rs @@ -41,7 +41,6 @@ pub fn run( ) -> io::Result<()> { match format { ProtocolFormat::JsonLegacy => run_old::<JsonProtocol>(stdin, stdout), - ProtocolFormat::PostcardLegacy => run_old::<PostcardProtocol>(stdin, stdout), ProtocolFormat::BidirectionalPostcardPrototype => { run_new::<PostcardProtocol>(stdin, stdout) } |