Skip to content

Commit 7ea2b25

Browse files
authored
Merge pull request rust-lang#22540 from lnicola/sync-from-rust
minor: sync from downstream
2 parents f1b0fc7 + c726330 commit 7ea2b25

20 files changed

Lines changed: 50 additions & 47 deletions

File tree

.github/workflows/ci.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ jobs:
6969
run: echo "::add-matcher::.github/rust.json"
7070

7171
- name: Test
72-
run: cargo test --features sysroot-abi -p proc-macro-srv -p proc-macro-srv-cli -p proc-macro-api -- --quiet
72+
run: cargo test --features in-rust-tree -p proc-macro-srv -p proc-macro-srv-cli -p proc-macro-api -- --quiet
7373

7474
- name: Check salsa dependency
7575
run: "! (cargo tree -p proc-macro-srv-cli -p proc-macro-srv -p proc-macro-srv-cli -p proc-macro-api -i salsa)"

crates/load-cargo/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ vfs.workspace = true
3030
intern.workspace = true
3131

3232
[features]
33-
in-rust-tree = ["hir-expand/in-rust-tree"]
33+
in-rust-tree = ["hir-expand/in-rust-tree", "proc-macro-api/in-rust-tree"]
3434

3535
[lints]
3636
workspace = true

crates/proc-macro-api/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ semver.workspace = true
3434
rayon.workspace = true
3535

3636
[features]
37-
sysroot-abi = ["proc-macro-srv", "proc-macro-srv/sysroot-abi"]
37+
in-rust-tree = ["proc-macro-srv", "proc-macro-srv/in-rust-tree"]
3838
default = []
3939

4040
[lints]

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ mod tests {
384384
}
385385

386386
#[test]
387-
#[cfg(feature = "sysroot-abi")]
387+
#[cfg(feature = "in-rust-tree")]
388388
fn test_proc_macro_rpc_works_ts() {
389389
for tt in [
390390
fixture_token_tree_top_many_none,

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
//! as we don't have bincode in Cargo.toml yet, lets stick with serde_json for
3535
//! the time being.
3636
37-
#[cfg(feature = "sysroot-abi")]
37+
#[cfg(feature = "in-rust-tree")]
3838
use proc_macro_srv::TokenStream;
3939

4040
use std::collections::VecDeque;
@@ -195,7 +195,7 @@ impl FlatTree {
195195
}
196196
}
197197

198-
#[cfg(feature = "sysroot-abi")]
198+
#[cfg(feature = "in-rust-tree")]
199199
impl FlatTree {
200200
pub fn from_tokenstream(
201201
tokenstream: proc_macro_srv::TokenStream<Span>,
@@ -591,7 +591,7 @@ impl<'a, T: SpanTransformer, U> Writer<'a, '_, T, U> {
591591
T::token_id_of(self.span_data_table, span)
592592
}
593593

594-
#[cfg(feature = "sysroot-abi")]
594+
#[cfg(feature = "in-rust-tree")]
595595
pub(crate) fn intern(&mut self, text: &'a str) -> u32 {
596596
let table = &mut self.text;
597597
*self.string_table.entry(text.into()).or_insert_with(|| {
@@ -611,7 +611,7 @@ impl<'a, T: SpanTransformer, U> Writer<'a, '_, T, U> {
611611
}
612612
}
613613

614-
#[cfg(feature = "sysroot-abi")]
614+
#[cfg(feature = "in-rust-tree")]
615615
impl<'a, T: SpanTransformer>
616616
Writer<'a, '_, T, Option<proc_macro_srv::TokenStreamIter<'a, T::Span>>>
617617
{
@@ -852,7 +852,7 @@ impl<T: SpanTransformer<Span = span::Span>> Reader<'_, T> {
852852
}
853853
}
854854

855-
#[cfg(feature = "sysroot-abi")]
855+
#[cfg(feature = "in-rust-tree")]
856856
impl<T: SpanTransformer> Reader<'_, T> {
857857
pub(crate) fn read_tokenstream(
858858
self,

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@
55
//! is used to provide basic infrastructure for communication between two
66
//! processes: Client (RA itself), Server (the external program)
77
8-
#![cfg_attr(not(feature = "sysroot-abi"), allow(unused_crate_dependencies))]
8+
#![cfg_attr(not(feature = "in-rust-tree"), allow(unused_crate_dependencies))]
99
#![cfg_attr(
10-
feature = "sysroot-abi",
10+
feature = "in-rust-tree",
1111
feature(proc_macro_internals, proc_macro_diagnostic, proc_macro_span, rustc_private)
1212
)]
1313
#![allow(internal_features, unused_features)]
1414

15-
#[cfg(feature = "sysroot-abi")]
15+
#[cfg(feature = "in-rust-tree")]
1616
extern crate rustc_driver as _;
1717

1818
pub mod bidirectional_protocol;

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ proc-macro-test.path = "../proc-macro-srv/proc-macro-test"
3131

3232
[features]
3333
default = []
34-
# default = ["sysroot-abi"]
35-
sysroot-abi = ["proc-macro-srv/sysroot-abi", "proc-macro-api/sysroot-abi"]
34+
# default = ["in-rust-tree"]
35+
in-rust-tree = ["proc-macro-srv/in-rust-tree", "proc-macro-api/in-rust-tree"]
3636

3737

3838
[[bin]]

crates/proc-macro-srv-cli/README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ rust-analyzer uses a RPC (via stdio) client-server architecture for procedural m
99
1. Proc macros are dynamic libraries that can segfault, bringing down the entire process, so running them out of process allows rust-analyzer to recover from fatal errors.
1010
2. Proc macro dylibs are compiled against a specific rustc version and require matching internal APIs to load and execute, as such having this binary shipped as a rustup component allows us to always match the rustc version irrespective of the rust-analyzer version used.
1111

12-
## The `sysroot-abi` Feature
12+
## The `in-rust-tree` Feature
1313

14-
**The `sysroot-abi` feature is required for the binary to actually function.** Without it, the binary will return an error:
14+
**The `in-rust-tree` feature is required for the binary to actually function.** Without it, the binary will return an error:
1515

1616
```
17-
proc-macro-srv-cli needs to be compiled with the `sysroot-abi` feature to function
17+
proc-macro-srv-cli needs to be compiled with the `in-rust-tree` feature to function
1818
```
1919

2020
This feature is necessary because the proc-macro server needs access to unstable rustc internals (`proc_macro_internals`, `proc_macro_diagnostic`, `proc_macro_span`) which are only available on nightly or with `RUSTC_BOOTSTRAP=1`.
@@ -24,10 +24,10 @@ rust-analyzer is a stable toolchain project though, so the feature flag is used
2424

2525
```bash
2626
# Using nightly toolchain
27-
cargo build -p proc-macro-srv-cli --features sysroot-abi
27+
cargo build -p proc-macro-srv-cli --features in-rust-tree
2828

2929
# Or with RUSTC_BOOTSTRAP on stable
30-
RUSTC_BOOTSTRAP=1 cargo build -p proc-macro-srv-cli --features sysroot-abi
30+
RUSTC_BOOTSTRAP=1 cargo build -p proc-macro-srv-cli --features in-rust-tree
3131
```
3232

3333
### Installing the proc-macro server
@@ -42,7 +42,7 @@ cargo xtask install --proc-macro-server
4242
## Testing
4343

4444
```bash
45-
cargo test --features sysroot-abi -p proc-macro-srv -p proc-macro-srv-cli -p proc-macro-api
45+
cargo test --features in-rust-tree -p proc-macro-srv -p proc-macro-srv-cli -p proc-macro-api
4646
```
4747

4848
The tests use a test proc macro dylib built by the `proc-macro-test` crate, which compiles a small proc macro implementation during build time.

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//!
33
//! This module exposes the server main loop and protocol format for integration testing.
44
5-
#![cfg(feature = "sysroot-abi")]
5+
#![cfg(feature = "in-rust-tree")]
66
#![feature(rustc_private)]
77

88
extern crate rustc_driver as _;

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
//! A standalone binary for `proc-macro-srv`.
22
//! Driver for proc macro server
3-
#![cfg_attr(feature = "sysroot-abi", feature(rustc_private))]
4-
#![cfg_attr(not(feature = "sysroot-abi"), allow(unused_crate_dependencies))]
3+
#![cfg_attr(feature = "in-rust-tree", feature(rustc_private))]
4+
#![cfg_attr(not(feature = "in-rust-tree"), allow(unused_crate_dependencies))]
55
#![allow(clippy::print_stdout, clippy::print_stderr)]
66

7-
#[cfg(feature = "sysroot-abi")]
7+
#[cfg(feature = "in-rust-tree")]
88
extern crate rustc_driver as _;
99

1010
mod version;
1111

1212
use clap::{Command, ValueEnum};
1313
use proc_macro_api::ProtocolFormat;
1414

15-
#[cfg(feature = "sysroot-abi")]
15+
#[cfg(feature = "in-rust-tree")]
1616
use proc_macro_srv_cli::main_loop::run;
1717

1818
fn main() -> std::io::Result<()> {
@@ -91,15 +91,15 @@ impl ValueEnum for ProtocolFormatArg {
9191
}
9292
}
9393

94-
#[cfg(not(feature = "sysroot-abi"))]
94+
#[cfg(not(feature = "in-rust-tree"))]
9595
fn run(
9696
_: &mut std::io::BufReader<std::io::Stdin>,
9797
_: &mut std::io::Stdout,
9898
_: ProtocolFormat,
9999
) -> std::io::Result<()> {
100100
Err(std::io::Error::new(
101101
std::io::ErrorKind::Unsupported,
102-
"proc-macro-srv-cli needs to be compiled with the `sysroot-abi` feature to function"
102+
"proc-macro-srv-cli needs to be compiled with the `in-rust-tree` feature to function"
103103
.to_owned(),
104104
))
105105
}

0 commit comments

Comments
 (0)