Skip to content

Commit 8e998c4

Browse files
committed
Fail spawning proc-macro servers when their api version is newer than r-a's
1 parent c40b089 commit 8e998c4

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

crates/proc-macro-api/src/msg.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use crate::ProcMacroKind;
1313
pub use crate::msg::flat::FlatTree;
1414

1515
pub const NO_VERSION_CHECK_VERSION: u32 = 0;
16-
pub const API_VERSION: u32 = 1;
16+
pub const CURRENT_API_VERSION: u32 = 1;
1717

1818
#[derive(Debug, Serialize, Deserialize)]
1919
pub enum Request {

crates/proc-macro-api/src/process.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use paths::{AbsPath, AbsPathBuf};
1010
use stdx::JodChild;
1111

1212
use crate::{
13-
msg::{Message, Request, Response},
13+
msg::{Message, Request, Response, CURRENT_API_VERSION},
1414
ProcMacroKind, ServerError,
1515
};
1616

@@ -36,6 +36,13 @@ impl ProcMacroProcessSrv {
3636
let mut srv = create_srv()?;
3737
tracing::info!("sending version check");
3838
match srv.version_check() {
39+
Ok(v) if v > CURRENT_API_VERSION => Err(io::Error::new(
40+
io::ErrorKind::Other,
41+
format!(
42+
"proc-macro server's api version ({}) is newer than rust-analyzer's ({})",
43+
v, CURRENT_API_VERSION
44+
),
45+
)),
3946
Ok(v) => {
4047
tracing::info!("got version {v}");
4148
srv.version = v;

crates/proc-macro-srv/src/cli.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ pub fn run() -> io::Result<()> {
1616
}
1717
msg::Request::ExpandMacro(task) => msg::Response::ExpandMacro(srv.expand(task)),
1818
msg::Request::ApiVersionCheck {} => {
19-
msg::Response::ApiVersionCheck(proc_macro_api::msg::API_VERSION)
19+
msg::Response::ApiVersionCheck(proc_macro_api::msg::CURRENT_API_VERSION)
2020
}
2121
};
2222
write_response(res)?

0 commit comments

Comments
 (0)