Skip to content

Commit e3e324d

Browse files
committed
Auto merge of #14432 - Veykril:proc-macro-srv, r=lnicola
Drop support for non-syroot proc macro ABIs This makes some bigger changes to how we handle the proc-macro-srv things, for one it is now an empty crate if built without the `sysroot-abi` feature, this simplifies some things dropping the need to put the feature cfg in various places. The cli wrapper now actually depends on the server, instead of being part of the server that is just exported, that way we can have a true dummy server that just errors on each request if no sysroot support was specified.
2 parents ea22d24 + 33e649d commit e3e324d

File tree

32 files changed

+255
-4687
lines changed

32 files changed

+255
-4687
lines changed

.github/workflows/ci.yaml

+6-3
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ jobs:
2424
runs-on: ${{ matrix.os }}
2525
env:
2626
CC: deny_c
27+
# we want to build r-a on stable to check that it keeps building on stable,
28+
# but we also want to test our proc-macro-srv which depends on nightly features
29+
RUSTC_BOOTSTRAP: 1
2730

2831
strategy:
2932
fail-fast: false
@@ -50,15 +53,15 @@ jobs:
5053
run: sed -i '/\[profile.dev]/a opt-level=1' Cargo.toml
5154

5255
- name: Compile (tests)
53-
run: cargo test --no-run --locked
56+
run: cargo test --no-run --locked --features sysroot-abi
5457

5558
# It's faster to `test` before `build` ¯\_(ツ)_/¯
5659
- name: Compile (rust-analyzer)
5760
if: matrix.os == 'ubuntu-latest'
58-
run: cargo build --quiet
61+
run: cargo build --quiet --features sysroot-abi
5962

6063
- name: Test
61-
run: cargo test -- --nocapture --quiet
64+
run: cargo test --features sysroot-abi -- --nocapture --quiet
6265

6366
- name: Run analysis-stats on rust-analyzer
6467
if: matrix.os == 'ubuntu-latest'

Cargo.lock

+2-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/proc-macro-srv-cli/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ rust-version.workspace = true
1010

1111
[dependencies]
1212
proc-macro-srv.workspace = true
13+
proc-macro-api.workspace = true
1314

1415
[features]
1516
sysroot-abi = ["proc-macro-srv/sysroot-abi"]

crates/proc-macro-srv/src/cli.rs renamed to crates/proc-macro-srv-cli/src/lib.rs

+23-3
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,9 @@ use std::io;
33

44
use proc_macro_api::msg::{self, Message};
55

6-
use crate::ProcMacroSrv;
7-
6+
#[cfg(feature = "sysroot-abi")]
87
pub fn run() -> io::Result<()> {
9-
let mut srv = ProcMacroSrv::default();
8+
let mut srv = proc_macro_srv::ProcMacroSrv::default();
109
let mut buf = String::new();
1110

1211
while let Some(req) = read_request(&mut buf)? {
@@ -24,6 +23,27 @@ pub fn run() -> io::Result<()> {
2423

2524
Ok(())
2625
}
26+
#[cfg(not(feature = "sysroot-abi"))]
27+
pub fn run() -> io::Result<()> {
28+
let mut buf = String::new();
29+
30+
while let Some(req) = read_request(&mut buf)? {
31+
let res = match req {
32+
msg::Request::ListMacros { .. } => {
33+
msg::Response::ListMacros(Err("server is built without sysroot support".to_owned()))
34+
}
35+
msg::Request::ExpandMacro(..) => msg::Response::ExpandMacro(Err(msg::PanicMessage(
36+
"server is built without sysroot support".to_owned(),
37+
))),
38+
msg::Request::ApiVersionCheck {} => {
39+
msg::Response::ApiVersionCheck(proc_macro_api::msg::CURRENT_API_VERSION)
40+
}
41+
};
42+
write_response(res)?
43+
}
44+
45+
Ok(())
46+
}
2747

2848
fn read_request(buf: &mut String) -> io::Result<Option<msg::Request>> {
2949
msg::Request::read(&mut io::stdin().lock(), buf)

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

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
//! A standalone binary for `proc-macro-srv`.
2-
3-
use proc_macro_srv::cli;
2+
//! Driver for proc macro server
43
54
fn main() -> std::io::Result<()> {
65
let v = std::env::var("RUST_ANALYZER_INTERNALS_DO_NOT_USE");
@@ -15,5 +14,5 @@ fn main() -> std::io::Result<()> {
1514
}
1615
}
1716

18-
cli::run()
17+
proc_macro_srv_cli::run()
1918
}

crates/proc-macro-srv/src/abis/abi_1_63/mod.rs

-106
This file was deleted.

crates/proc-macro-srv/src/abis/abi_1_63/proc_macro/bridge/buffer.rs

-156
This file was deleted.

0 commit comments

Comments
 (0)