Unnamed repository; edit this file 'description' to name the repository.
Merge ref '43a4909ee98e' from rust-lang/rust
Pull recent changes from https://github.com/rust-lang/rust via Josh. Upstream ref: rust-lang/rust@43a4909ee98ed4d006d9d773f5d94dc58e34f846 Filtered ref: rust-lang/rust-analyzer@5935dd54659200fd2eb1b5b17863edf611e4bda3 Upstream diff: https://github.com/rust-lang/rust/compare/ba0949ab745985a442e274ba52e8fb348cb0c662...43a4909ee98ed4d006d9d773f5d94dc58e34f846 This merge was created using https://github.com/rust-lang/josh-sync.
Laurențiu Nicola 6 weeks ago
parent 35df119 · parent 5935dd5 · commit c726330
-rw-r--r--.github/workflows/ci.yaml2
-rw-r--r--crates/load-cargo/Cargo.toml2
-rw-r--r--crates/proc-macro-api/Cargo.toml2
-rw-r--r--crates/proc-macro-api/src/legacy_protocol/msg.rs2
-rw-r--r--crates/proc-macro-api/src/legacy_protocol/msg/flat.rs10
-rw-r--r--crates/proc-macro-api/src/lib.rs6
-rw-r--r--crates/proc-macro-srv-cli/Cargo.toml4
-rw-r--r--crates/proc-macro-srv-cli/README.md12
-rw-r--r--crates/proc-macro-srv-cli/src/lib.rs2
-rw-r--r--crates/proc-macro-srv-cli/src/main.rs12
-rw-r--r--crates/proc-macro-srv-cli/tests/bidirectional_postcard.rs2
-rw-r--r--crates/proc-macro-srv-cli/tests/common/utils.rs8
-rw-r--r--crates/proc-macro-srv-cli/tests/legacy_json.rs2
-rw-r--r--crates/proc-macro-srv/Cargo.toml4
-rw-r--r--crates/proc-macro-srv/src/lib.rs2
-rw-r--r--crates/proc-macro-srv/src/tests/utils.rs13
-rw-r--r--crates/rust-analyzer/Cargo.toml1
-rw-r--r--crates/span/src/hygiene.rs7
-rw-r--r--xtask/src/install.rs2
19 files changed, 49 insertions, 46 deletions
diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml
index 48bce9eb19..ca9e9719ad 100644
--- a/.github/workflows/ci.yaml
+++ b/.github/workflows/ci.yaml
@@ -69,7 +69,7 @@ jobs:
run: echo "::add-matcher::.github/rust.json"
- name: Test
- run: cargo test --features sysroot-abi -p proc-macro-srv -p proc-macro-srv-cli -p proc-macro-api -- --quiet
+ run: cargo test --features in-rust-tree -p proc-macro-srv -p proc-macro-srv-cli -p proc-macro-api -- --quiet
- name: Check salsa dependency
run: "! (cargo tree -p proc-macro-srv-cli -p proc-macro-srv -p proc-macro-srv-cli -p proc-macro-api -i salsa)"
diff --git a/crates/load-cargo/Cargo.toml b/crates/load-cargo/Cargo.toml
index 91b012e050..7b5e51fba5 100644
--- a/crates/load-cargo/Cargo.toml
+++ b/crates/load-cargo/Cargo.toml
@@ -30,7 +30,7 @@ vfs.workspace = true
intern.workspace = true
[features]
-in-rust-tree = ["hir-expand/in-rust-tree"]
+in-rust-tree = ["hir-expand/in-rust-tree", "proc-macro-api/in-rust-tree"]
[lints]
workspace = true
diff --git a/crates/proc-macro-api/Cargo.toml b/crates/proc-macro-api/Cargo.toml
index 2cb76ef6b7..7342e0ecdc 100644
--- a/crates/proc-macro-api/Cargo.toml
+++ b/crates/proc-macro-api/Cargo.toml
@@ -34,7 +34,7 @@ semver.workspace = true
rayon.workspace = true
[features]
-sysroot-abi = ["proc-macro-srv", "proc-macro-srv/sysroot-abi"]
+in-rust-tree = ["proc-macro-srv", "proc-macro-srv/in-rust-tree"]
default = []
[lints]
diff --git a/crates/proc-macro-api/src/legacy_protocol/msg.rs b/crates/proc-macro-api/src/legacy_protocol/msg.rs
index b647e6cf8a..9b71a8b70c 100644
--- a/crates/proc-macro-api/src/legacy_protocol/msg.rs
+++ b/crates/proc-macro-api/src/legacy_protocol/msg.rs
@@ -384,7 +384,7 @@ mod tests {
}
#[test]
- #[cfg(feature = "sysroot-abi")]
+ #[cfg(feature = "in-rust-tree")]
fn test_proc_macro_rpc_works_ts() {
for tt in [
fixture_token_tree_top_many_none,
diff --git a/crates/proc-macro-api/src/legacy_protocol/msg/flat.rs b/crates/proc-macro-api/src/legacy_protocol/msg/flat.rs
index 248de70f0e..3015bd0c0e 100644
--- a/crates/proc-macro-api/src/legacy_protocol/msg/flat.rs
+++ b/crates/proc-macro-api/src/legacy_protocol/msg/flat.rs
@@ -34,7 +34,7 @@
//! as we don't have bincode in Cargo.toml yet, lets stick with serde_json for
//! the time being.
-#[cfg(feature = "sysroot-abi")]
+#[cfg(feature = "in-rust-tree")]
use proc_macro_srv::TokenStream;
use std::collections::VecDeque;
@@ -195,7 +195,7 @@ impl FlatTree {
}
}
-#[cfg(feature = "sysroot-abi")]
+#[cfg(feature = "in-rust-tree")]
impl FlatTree {
pub fn from_tokenstream(
tokenstream: proc_macro_srv::TokenStream<Span>,
@@ -591,7 +591,7 @@ impl<'a, T: SpanTransformer, U> Writer<'a, '_, T, U> {
T::token_id_of(self.span_data_table, span)
}
- #[cfg(feature = "sysroot-abi")]
+ #[cfg(feature = "in-rust-tree")]
pub(crate) fn intern(&mut self, text: &'a str) -> u32 {
let table = &mut self.text;
*self.string_table.entry(text.into()).or_insert_with(|| {
@@ -611,7 +611,7 @@ impl<'a, T: SpanTransformer, U> Writer<'a, '_, T, U> {
}
}
-#[cfg(feature = "sysroot-abi")]
+#[cfg(feature = "in-rust-tree")]
impl<'a, T: SpanTransformer>
Writer<'a, '_, T, Option<proc_macro_srv::TokenStreamIter<'a, T::Span>>>
{
@@ -852,7 +852,7 @@ impl<T: SpanTransformer<Span = span::Span>> Reader<'_, T> {
}
}
-#[cfg(feature = "sysroot-abi")]
+#[cfg(feature = "in-rust-tree")]
impl<T: SpanTransformer> Reader<'_, T> {
pub(crate) fn read_tokenstream(
self,
diff --git a/crates/proc-macro-api/src/lib.rs b/crates/proc-macro-api/src/lib.rs
index a3d6ac5dd6..149f6e44f9 100644
--- a/crates/proc-macro-api/src/lib.rs
+++ b/crates/proc-macro-api/src/lib.rs
@@ -5,14 +5,14 @@
//! is used to provide basic infrastructure for communication between two
//! processes: Client (RA itself), Server (the external program)
-#![cfg_attr(not(feature = "sysroot-abi"), allow(unused_crate_dependencies))]
+#![cfg_attr(not(feature = "in-rust-tree"), allow(unused_crate_dependencies))]
#![cfg_attr(
- feature = "sysroot-abi",
+ feature = "in-rust-tree",
feature(proc_macro_internals, proc_macro_diagnostic, proc_macro_span, rustc_private)
)]
#![allow(internal_features, unused_features)]
-#[cfg(feature = "sysroot-abi")]
+#[cfg(feature = "in-rust-tree")]
extern crate rustc_driver as _;
pub mod bidirectional_protocol;
diff --git a/crates/proc-macro-srv-cli/Cargo.toml b/crates/proc-macro-srv-cli/Cargo.toml
index 4641f08783..44e19f2d3c 100644
--- a/crates/proc-macro-srv-cli/Cargo.toml
+++ b/crates/proc-macro-srv-cli/Cargo.toml
@@ -31,8 +31,8 @@ proc-macro-test.path = "../proc-macro-srv/proc-macro-test"
[features]
default = []
-# default = ["sysroot-abi"]
-sysroot-abi = ["proc-macro-srv/sysroot-abi", "proc-macro-api/sysroot-abi"]
+# default = ["in-rust-tree"]
+in-rust-tree = ["proc-macro-srv/in-rust-tree", "proc-macro-api/in-rust-tree"]
[[bin]]
diff --git a/crates/proc-macro-srv-cli/README.md b/crates/proc-macro-srv-cli/README.md
index 02a67ac3ec..93a3c7ffc2 100644
--- a/crates/proc-macro-srv-cli/README.md
+++ b/crates/proc-macro-srv-cli/README.md
@@ -9,12 +9,12 @@ rust-analyzer uses a RPC (via stdio) client-server architecture for procedural m
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.
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.
-## The `sysroot-abi` Feature
+## The `in-rust-tree` Feature
-**The `sysroot-abi` feature is required for the binary to actually function.** Without it, the binary will return an error:
+**The `in-rust-tree` feature is required for the binary to actually function.** Without it, the binary will return an error:
```
-proc-macro-srv-cli needs to be compiled with the `sysroot-abi` feature to function
+proc-macro-srv-cli needs to be compiled with the `in-rust-tree` feature to function
```
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
```bash
# Using nightly toolchain
-cargo build -p proc-macro-srv-cli --features sysroot-abi
+cargo build -p proc-macro-srv-cli --features in-rust-tree
# Or with RUSTC_BOOTSTRAP on stable
-RUSTC_BOOTSTRAP=1 cargo build -p proc-macro-srv-cli --features sysroot-abi
+RUSTC_BOOTSTRAP=1 cargo build -p proc-macro-srv-cli --features in-rust-tree
```
### Installing the proc-macro server
@@ -42,7 +42,7 @@ cargo xtask install --proc-macro-server
## Testing
```bash
-cargo test --features sysroot-abi -p proc-macro-srv -p proc-macro-srv-cli -p proc-macro-api
+cargo test --features in-rust-tree -p proc-macro-srv -p proc-macro-srv-cli -p proc-macro-api
```
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.
diff --git a/crates/proc-macro-srv-cli/src/lib.rs b/crates/proc-macro-srv-cli/src/lib.rs
index d540146c78..c330928fbc 100644
--- a/crates/proc-macro-srv-cli/src/lib.rs
+++ b/crates/proc-macro-srv-cli/src/lib.rs
@@ -2,7 +2,7 @@
//!
//! This module exposes the server main loop and protocol format for integration testing.
-#![cfg(feature = "sysroot-abi")]
+#![cfg(feature = "in-rust-tree")]
#![feature(rustc_private)]
extern crate rustc_driver as _;
diff --git a/crates/proc-macro-srv-cli/src/main.rs b/crates/proc-macro-srv-cli/src/main.rs
index 20b1c73ebf..926633df62 100644
--- a/crates/proc-macro-srv-cli/src/main.rs
+++ b/crates/proc-macro-srv-cli/src/main.rs
@@ -1,10 +1,10 @@
//! A standalone binary for `proc-macro-srv`.
//! Driver for proc macro server
-#![cfg_attr(feature = "sysroot-abi", feature(rustc_private))]
-#![cfg_attr(not(feature = "sysroot-abi"), allow(unused_crate_dependencies))]
+#![cfg_attr(feature = "in-rust-tree", feature(rustc_private))]
+#![cfg_attr(not(feature = "in-rust-tree"), allow(unused_crate_dependencies))]
#![allow(clippy::print_stdout, clippy::print_stderr)]
-#[cfg(feature = "sysroot-abi")]
+#[cfg(feature = "in-rust-tree")]
extern crate rustc_driver as _;
mod version;
@@ -12,7 +12,7 @@ mod version;
use clap::{Command, ValueEnum};
use proc_macro_api::ProtocolFormat;
-#[cfg(feature = "sysroot-abi")]
+#[cfg(feature = "in-rust-tree")]
use proc_macro_srv_cli::main_loop::run;
fn main() -> std::io::Result<()> {
@@ -91,7 +91,7 @@ impl ValueEnum for ProtocolFormatArg {
}
}
-#[cfg(not(feature = "sysroot-abi"))]
+#[cfg(not(feature = "in-rust-tree"))]
fn run(
_: &mut std::io::BufReader<std::io::Stdin>,
_: &mut std::io::Stdout,
@@ -99,7 +99,7 @@ fn run(
) -> std::io::Result<()> {
Err(std::io::Error::new(
std::io::ErrorKind::Unsupported,
- "proc-macro-srv-cli needs to be compiled with the `sysroot-abi` feature to function"
+ "proc-macro-srv-cli needs to be compiled with the `in-rust-tree` feature to function"
.to_owned(),
))
}
diff --git a/crates/proc-macro-srv-cli/tests/bidirectional_postcard.rs b/crates/proc-macro-srv-cli/tests/bidirectional_postcard.rs
index 4c50f06f4a..9c55eed08e 100644
--- a/crates/proc-macro-srv-cli/tests/bidirectional_postcard.rs
+++ b/crates/proc-macro-srv-cli/tests/bidirectional_postcard.rs
@@ -1,4 +1,4 @@
-#![cfg(feature = "sysroot-abi")]
+#![cfg(feature = "in-rust-tree")]
#![feature(rustc_private)]
extern crate rustc_driver as _;
diff --git a/crates/proc-macro-srv-cli/tests/common/utils.rs b/crates/proc-macro-srv-cli/tests/common/utils.rs
index 051f28aee2..b78e107452 100644
--- a/crates/proc-macro-srv-cli/tests/common/utils.rs
+++ b/crates/proc-macro-srv-cli/tests/common/utils.rs
@@ -135,6 +135,11 @@ pub(crate) fn proc_macro_test_dylib_path() -> Utf8PathBuf {
path.into()
}
+fn make_ctx() -> SyntaxContext {
+ // SAFETY: Tests do not use a Database, so this won't ever be used within salsa.
+ unsafe { SyntaxContext::from_u32(0) }
+}
+
/// Creates a simple empty token tree suitable for testing.
pub(crate) fn create_empty_token_tree(
version: u32,
@@ -144,8 +149,7 @@ pub(crate) fn create_empty_token_tree(
file_id: EditionedFileId::new(FileId::from_raw(0), Edition::CURRENT),
ast_id: span::ROOT_ERASED_FILE_AST_ID,
};
- let span =
- Span { range: TextRange::empty(0.into()), anchor, ctx: SyntaxContext::from_u32_safe(0) };
+ let span = Span { range: TextRange::empty(0.into()), anchor, ctx: make_ctx() };
let builder = TopSubtreeBuilder::new(Delimiter {
open: span,
diff --git a/crates/proc-macro-srv-cli/tests/legacy_json.rs b/crates/proc-macro-srv-cli/tests/legacy_json.rs
index b807fd46d4..f5cbaa7421 100644
--- a/crates/proc-macro-srv-cli/tests/legacy_json.rs
+++ b/crates/proc-macro-srv-cli/tests/legacy_json.rs
@@ -3,7 +3,7 @@
//! These tests exercise the full client-server RPC procedure using in-memory
//! channels without needing to spawn the actual server and client processes.
-#![cfg(feature = "sysroot-abi")]
+#![cfg(feature = "in-rust-tree")]
#![feature(rustc_private)]
extern crate rustc_driver as _;
diff --git a/crates/proc-macro-srv/Cargo.toml b/crates/proc-macro-srv/Cargo.toml
index 4667542090..a161d79693 100644
--- a/crates/proc-macro-srv/Cargo.toml
+++ b/crates/proc-macro-srv/Cargo.toml
@@ -36,8 +36,8 @@ proc-macro-test.path = "./proc-macro-test"
[features]
default = []
-# default = ["sysroot-abi"]
-sysroot-abi = []
+# default = ["in-rust-tree"]
+in-rust-tree = []
[lints]
workspace = true
diff --git a/crates/proc-macro-srv/src/lib.rs b/crates/proc-macro-srv/src/lib.rs
index e989eb62dd..7562a2e664 100644
--- a/crates/proc-macro-srv/src/lib.rs
+++ b/crates/proc-macro-srv/src/lib.rs
@@ -8,7 +8,7 @@
//! * We use `tt` for proc-macro `TokenStream` server, it is easier to manipulate and interact with
//! RA than `proc-macro2` token stream.
-#![cfg(feature = "sysroot-abi")]
+#![cfg(feature = "in-rust-tree")]
#![feature(proc_macro_internals, proc_macro_diagnostic, proc_macro_span, rustc_private)]
#![expect(unreachable_pub, internal_features, clippy::disallowed_types, clippy::print_stderr)]
#![allow(unused_features, unused_crate_dependencies)]
diff --git a/crates/proc-macro-srv/src/tests/utils.rs b/crates/proc-macro-srv/src/tests/utils.rs
index 394cbefc12..9780bcf348 100644
--- a/crates/proc-macro-srv/src/tests/utils.rs
+++ b/crates/proc-macro-srv/src/tests/utils.rs
@@ -11,6 +11,11 @@ use crate::{
token_stream::TokenStream,
};
+fn make_ctx() -> SyntaxContext {
+ // SAFETY: Tests do not use a Database, so this won't ever be used within salsa.
+ unsafe { SyntaxContext::from_u32(0) }
+}
+
fn parse_string(call_site: SpanId, src: &str) -> TokenStream<SpanId> {
TokenStream::from_str(src, call_site).unwrap()
}
@@ -86,7 +91,7 @@ fn assert_expand_impl(
file_id: EditionedFileId::current_edition(FileId::from_raw(41)),
ast_id: ROOT_ERASED_FILE_AST_ID,
},
- ctx: SyntaxContext::from_u32_safe(0),
+ ctx: make_ctx(),
};
let call_site = Span {
range: TextRange::new(0.into(), 100.into()),
@@ -94,7 +99,7 @@ fn assert_expand_impl(
file_id: EditionedFileId::current_edition(FileId::from_raw(42)),
ast_id: ROOT_ERASED_FILE_AST_ID,
},
- ctx: SyntaxContext::from_u32_safe(0),
+ ctx: make_ctx(),
};
let mixed_site = call_site;
@@ -189,7 +194,7 @@ pub fn assert_expand_with_callback(
file_id: EditionedFileId::current_edition(FileId::from_raw(41)),
ast_id: ROOT_ERASED_FILE_AST_ID,
},
- ctx: SyntaxContext::from_u32_safe(0),
+ ctx: make_ctx(),
};
let call_site = Span {
range: TextRange::new(0.into(), 100.into()),
@@ -197,7 +202,7 @@ pub fn assert_expand_with_callback(
file_id: EditionedFileId::current_edition(FileId::from_raw(42)),
ast_id: ROOT_ERASED_FILE_AST_ID,
},
- ctx: SyntaxContext::from_u32_safe(0),
+ ctx: make_ctx(),
};
let mixed_site = call_site;
diff --git a/crates/rust-analyzer/Cargo.toml b/crates/rust-analyzer/Cargo.toml
index 1745384843..27d9576e29 100644
--- a/crates/rust-analyzer/Cargo.toml
+++ b/crates/rust-analyzer/Cargo.toml
@@ -108,6 +108,7 @@ in-rust-tree = [
"ide/in-rust-tree",
"load-cargo/in-rust-tree",
"parser/in-rust-tree",
+ "proc-macro-api/in-rust-tree",
"syntax/in-rust-tree",
]
dhat = ["dep:dhat"]
diff --git a/crates/span/src/hygiene.rs b/crates/span/src/hygiene.rs
index 2d9757b5ae..70b0447569 100644
--- a/crates/span/src/hygiene.rs
+++ b/crates/span/src/hygiene.rs
@@ -460,13 +460,6 @@ impl SyntaxContext {
pub const unsafe fn from_u32(u32: u32) -> Self {
Self(u32)
}
-
- /// Alternative to [`from_u32`] that is safe to call.
- ///
- /// The split exists to keep API parity.
- pub const fn from_u32_safe(u32: u32) -> Self {
- Self(u32)
- }
}
/// A property of a macro expansion that determines how identifiers
diff --git a/xtask/src/install.rs b/xtask/src/install.rs
index a803b4e943..bbb6d9aeac 100644
--- a/xtask/src/install.rs
+++ b/xtask/src/install.rs
@@ -179,7 +179,7 @@ fn install_proc_macro_server(sh: &Shell, opts: ProcMacroServerOpt) -> anyhow::Re
let mut cmd = cmd!(
sh,
- "cargo install --path crates/proc-macro-srv-cli --profile={profile} --locked --force --features sysroot-abi"
+ "cargo install --path crates/proc-macro-srv-cli --profile={profile} --locked --force --features in-rust-tree"
);
if std::env::var_os("RUSTUP_TOOLCHAIN").is_none() {
cmd = cmd.env("RUSTUP_TOOLCHAIN", "nightly");