From acb575c6abbe489ea2678c59baa20abb49a1bc15 Mon Sep 17 00:00:00 2001 From: Jieyou Xu Date: Sun, 5 Oct 2025 17:28:56 +0800 Subject: [PATCH 1/4] rust-analyzer: prep crates for testing against in-tree `rustc_private` --- crates/base-db/Cargo.toml | 4 ++++ crates/base-db/src/lib.rs | 5 +++++ crates/cfg/Cargo.toml | 4 ++++ crates/cfg/src/lib.rs | 5 +++++ crates/ide-completion/Cargo.toml | 4 ++++ crates/ide-completion/src/lib.rs | 5 +++++ crates/ide-db/Cargo.toml | 4 ++++ crates/ide-db/src/lib.rs | 5 +++++ crates/ide-diagnostics/Cargo.toml | 4 ++++ crates/ide-diagnostics/src/lib.rs | 5 +++++ crates/ide-ssr/Cargo.toml | 4 ++++ crates/ide-ssr/src/lib.rs | 5 +++++ crates/load-cargo/src/lib.rs | 6 ++++++ crates/parser/src/lib.rs | 2 ++ crates/proc-macro-api/Cargo.toml | 2 ++ crates/proc-macro-api/src/lib.rs | 5 +++++ crates/project-model/Cargo.toml | 4 ++++ crates/project-model/src/lib.rs | 5 +++++ crates/rust-analyzer/Cargo.toml | 10 +++++++--- crates/rust-analyzer/src/lib.rs | 5 +++++ crates/rust-analyzer/tests/slow-tests/main.rs | 4 ++++ crates/span/Cargo.toml | 1 + crates/span/src/lib.rs | 6 ++++++ crates/syntax-bridge/src/lib.rs | 5 +++++ crates/syntax/Cargo.toml | 1 + crates/syntax/src/lib.rs | 5 +++++ crates/test-fixture/Cargo.toml | 4 ++++ crates/test-fixture/src/lib.rs | 6 ++++++ crates/tt/Cargo.toml | 1 + crates/tt/src/lib.rs | 3 +++ 30 files changed, 126 insertions(+), 3 deletions(-) diff --git a/crates/base-db/Cargo.toml b/crates/base-db/Cargo.toml index ea06fd9c48fc..55dfcbc7e508 100644 --- a/crates/base-db/Cargo.toml +++ b/crates/base-db/Cargo.toml @@ -31,5 +31,9 @@ vfs.workspace = true span.workspace = true intern.workspace = true +[features] +default = [] +in-rust-tree = [] + [lints] workspace = true diff --git a/crates/base-db/src/lib.rs b/crates/base-db/src/lib.rs index 97938924100b..b6e346521187 100644 --- a/crates/base-db/src/lib.rs +++ b/crates/base-db/src/lib.rs @@ -1,5 +1,10 @@ //! base_db defines basic database traits. The concrete DB is defined by ide. +#![cfg_attr(feature = "in-rust-tree", feature(rustc_private))] + +#[cfg(feature = "in-rust-tree")] +extern crate rustc_driver as _; + pub use salsa; pub use salsa_macros; diff --git a/crates/cfg/Cargo.toml b/crates/cfg/Cargo.toml index 9e2a95dbf32c..7207cfcf7dba 100644 --- a/crates/cfg/Cargo.toml +++ b/crates/cfg/Cargo.toml @@ -33,5 +33,9 @@ syntax.workspace = true # tt is needed for testing cfg = { path = ".", default-features = false, features = ["tt"] } +[features] +default = [] +in-rust-tree = [] + [lints] workspace = true diff --git a/crates/cfg/src/lib.rs b/crates/cfg/src/lib.rs index b1ec4c273a85..3e3d67cb4aaf 100644 --- a/crates/cfg/src/lib.rs +++ b/crates/cfg/src/lib.rs @@ -1,5 +1,10 @@ //! cfg defines conditional compiling options, `cfg` attribute parser and evaluator +#![cfg_attr(feature = "in-rust-tree", feature(rustc_private))] + +#[cfg(feature = "in-rust-tree")] +extern crate rustc_driver as _; + mod cfg_expr; mod dnf; #[cfg(test)] diff --git a/crates/ide-completion/Cargo.toml b/crates/ide-completion/Cargo.toml index 277d5dfa495c..6abc009241cf 100644 --- a/crates/ide-completion/Cargo.toml +++ b/crates/ide-completion/Cargo.toml @@ -37,5 +37,9 @@ expect-test = "1.5.1" test-utils.workspace = true test-fixture.workspace = true +[features] +default = [] +in-rust-tree = [] + [lints] workspace = true diff --git a/crates/ide-completion/src/lib.rs b/crates/ide-completion/src/lib.rs index 31e33db104c7..c9d5971cd0e3 100644 --- a/crates/ide-completion/src/lib.rs +++ b/crates/ide-completion/src/lib.rs @@ -3,6 +3,11 @@ // It's useful to refer to code that is private in doc comments. #![allow(rustdoc::private_intra_doc_links)] +#![cfg_attr(feature = "in-rust-tree", feature(rustc_private))] + +#[cfg(feature = "in-rust-tree")] +extern crate rustc_driver as _; + mod completions; mod config; mod context; diff --git a/crates/ide-db/Cargo.toml b/crates/ide-db/Cargo.toml index f1f9d85cf964..fca06b69d1bb 100644 --- a/crates/ide-db/Cargo.toml +++ b/crates/ide-db/Cargo.toml @@ -52,5 +52,9 @@ line-index.workspace = true [dev-dependencies] expect-test = "1.5.1" +[features] +default = [] +in-rust-tree = [] + [lints] workspace = true diff --git a/crates/ide-db/src/lib.rs b/crates/ide-db/src/lib.rs index 0301b5020862..338c42325457 100644 --- a/crates/ide-db/src/lib.rs +++ b/crates/ide-db/src/lib.rs @@ -2,6 +2,11 @@ //! //! It is mainly a `HirDatabase` for semantic analysis, plus a `SymbolsDatabase`, for fuzzy search. +#![cfg_attr(feature = "in-rust-tree", feature(rustc_private))] + +#[cfg(feature = "in-rust-tree")] +extern crate rustc_driver as _; + extern crate self as ide_db; mod apply_change; diff --git a/crates/ide-diagnostics/Cargo.toml b/crates/ide-diagnostics/Cargo.toml index 6f1e66948f42..ddf5999036d2 100644 --- a/crates/ide-diagnostics/Cargo.toml +++ b/crates/ide-diagnostics/Cargo.toml @@ -34,5 +34,9 @@ expect-test = "1.5.1" test-utils.workspace = true test-fixture.workspace = true +[features] +default = [] +in-rust-tree = [] + [lints] workspace = true diff --git a/crates/ide-diagnostics/src/lib.rs b/crates/ide-diagnostics/src/lib.rs index fe04bd175c96..e001f4b3e438 100644 --- a/crates/ide-diagnostics/src/lib.rs +++ b/crates/ide-diagnostics/src/lib.rs @@ -23,6 +23,11 @@ //! There are also a couple of ad-hoc diagnostics implemented directly here, we //! don't yet have a great pattern for how to do them properly. +#![cfg_attr(feature = "in-rust-tree", feature(rustc_private))] + +#[cfg(feature = "in-rust-tree")] +extern crate rustc_driver as _; + mod handlers { pub(crate) mod await_outside_of_async; pub(crate) mod bad_rtn; diff --git a/crates/ide-ssr/Cargo.toml b/crates/ide-ssr/Cargo.toml index 0620bd26fefd..1900b069e00f 100644 --- a/crates/ide-ssr/Cargo.toml +++ b/crates/ide-ssr/Cargo.toml @@ -30,5 +30,9 @@ triomphe.workspace = true test-utils.workspace = true test-fixture.workspace = true +[features] +default = [] +in-rust-tree = [] + [lints] workspace = true diff --git a/crates/ide-ssr/src/lib.rs b/crates/ide-ssr/src/lib.rs index 977dfb7466e4..958a26324fff 100644 --- a/crates/ide-ssr/src/lib.rs +++ b/crates/ide-ssr/src/lib.rs @@ -63,6 +63,11 @@ // // foo($a, $b) ==>> ($a).foo($b) // ``` +#![cfg_attr(feature = "in-rust-tree", feature(rustc_private))] + +#[cfg(feature = "in-rust-tree")] +extern crate rustc_driver as _; + mod fragments; mod from_comment; mod matching; diff --git a/crates/load-cargo/src/lib.rs b/crates/load-cargo/src/lib.rs index a486219efa20..28fbfecfde80 100644 --- a/crates/load-cargo/src/lib.rs +++ b/crates/load-cargo/src/lib.rs @@ -2,6 +2,12 @@ //! for incorporating changes. // Note, don't remove any public api from this. This API is consumed by external tools // to run rust-analyzer as a library. + +#![cfg_attr(feature = "in-rust-tree", feature(rustc_private))] + +#[cfg(feature = "in-rust-tree")] +extern crate rustc_driver as _; + use std::{any::Any, collections::hash_map::Entry, mem, path::Path, sync}; use crossbeam_channel::{Receiver, unbounded}; diff --git a/crates/parser/src/lib.rs b/crates/parser/src/lib.rs index b15bf0cd0105..81cdc188012c 100644 --- a/crates/parser/src/lib.rs +++ b/crates/parser/src/lib.rs @@ -25,6 +25,8 @@ extern crate ra_ap_rustc_lexer as rustc_lexer; #[cfg(feature = "in-rust-tree")] extern crate rustc_lexer; +#[cfg(feature = "in-rust-tree")] +extern crate rustc_driver as _; mod event; mod frontmatter; diff --git a/crates/proc-macro-api/Cargo.toml b/crates/proc-macro-api/Cargo.toml index 18a2408c4035..4de1a3e5dd7d 100644 --- a/crates/proc-macro-api/Cargo.toml +++ b/crates/proc-macro-api/Cargo.toml @@ -34,6 +34,8 @@ semver.workspace = true [features] sysroot-abi = ["proc-macro-srv", "proc-macro-srv/sysroot-abi"] +default = [] +in-rust-tree = [] [lints] workspace = true diff --git a/crates/proc-macro-api/src/lib.rs b/crates/proc-macro-api/src/lib.rs index f0c7ce7efd1c..8e1faca00a1b 100644 --- a/crates/proc-macro-api/src/lib.rs +++ b/crates/proc-macro-api/src/lib.rs @@ -12,6 +12,11 @@ )] #![allow(internal_features)] +#![cfg_attr(feature = "in-rust-tree", feature(rustc_private))] + +#[cfg(feature = "in-rust-tree")] +extern crate rustc_driver as _; + mod codec; mod framing; pub mod legacy_protocol; diff --git a/crates/project-model/Cargo.toml b/crates/project-model/Cargo.toml index 7e0b1f75f72c..f825a456dea7 100644 --- a/crates/project-model/Cargo.toml +++ b/crates/project-model/Cargo.toml @@ -39,5 +39,9 @@ toolchain.workspace = true [dev-dependencies] expect-test = "1.5.1" +[features] +default = [] +in-rust-tree = [] + [lints] workspace = true diff --git a/crates/project-model/src/lib.rs b/crates/project-model/src/lib.rs index 8eee3d1455c1..0d89e13ed374 100644 --- a/crates/project-model/src/lib.rs +++ b/crates/project-model/src/lib.rs @@ -18,6 +18,11 @@ // It's useful to refer to code that is private in doc comments. #![allow(rustdoc::private_intra_doc_links)] +#![cfg_attr(feature = "in-rust-tree", feature(rustc_private))] + +#[cfg(feature = "in-rust-tree")] +extern crate rustc_driver as _; + pub mod project_json; pub mod toolchain_info { pub mod rustc_cfg; diff --git a/crates/rust-analyzer/Cargo.toml b/crates/rust-analyzer/Cargo.toml index 2e48c5a5a66c..d1283ca59e8c 100644 --- a/crates/rust-analyzer/Cargo.toml +++ b/crates/rust-analyzer/Cargo.toml @@ -98,12 +98,16 @@ syntax-bridge.workspace = true jemalloc = ["jemallocator", "profile/jemalloc"] force-always-assert = ["stdx/force-always-assert"] in-rust-tree = [ - "syntax/in-rust-tree", - "parser/in-rust-tree", - "hir/in-rust-tree", + "cfg/in-rust-tree", "hir-def/in-rust-tree", "hir-ty/in-rust-tree", + "hir/in-rust-tree", + "ide-ssr/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/rust-analyzer/src/lib.rs b/crates/rust-analyzer/src/lib.rs index 3dea21e56485..a6cd43139229 100644 --- a/crates/rust-analyzer/src/lib.rs +++ b/crates/rust-analyzer/src/lib.rs @@ -9,6 +9,11 @@ //! The `cli` submodule implements some batch-processing analysis, primarily as //! a debugging aid. +#![cfg_attr(feature = "in-rust-tree", feature(rustc_private))] + +#[cfg(feature = "in-rust-tree")] +extern crate rustc_driver as _; + extern crate ra_ap_rustc_type_ir as rustc_type_ir; /// Any toolchain less than this version will likely not work with rust-analyzer built from this revision. diff --git a/crates/rust-analyzer/tests/slow-tests/main.rs b/crates/rust-analyzer/tests/slow-tests/main.rs index 5a4ad6f380f9..48433342d51d 100644 --- a/crates/rust-analyzer/tests/slow-tests/main.rs +++ b/crates/rust-analyzer/tests/slow-tests/main.rs @@ -9,6 +9,10 @@ //! be sure without a real client anyway. #![allow(clippy::disallowed_types)] +#![cfg_attr(feature = "in-rust-tree", feature(rustc_private))] + +#[cfg(feature = "in-rust-tree")] +extern crate rustc_driver as _; mod cli; mod ratoml; diff --git a/crates/span/Cargo.toml b/crates/span/Cargo.toml index 966962bab381..cfb319d688b6 100644 --- a/crates/span/Cargo.toml +++ b/crates/span/Cargo.toml @@ -27,6 +27,7 @@ syntax.workspace = true [features] default = ["salsa"] +in-rust-tree = [] [lints] workspace = true diff --git a/crates/span/src/lib.rs b/crates/span/src/lib.rs index cb91f4924944..c44b0198b72c 100644 --- a/crates/span/src/lib.rs +++ b/crates/span/src/lib.rs @@ -1,4 +1,10 @@ //! File and span related types. + +#![cfg_attr(feature = "in-rust-tree", feature(rustc_private))] + +#[cfg(feature = "in-rust-tree")] +extern crate rustc_driver as _; + use std::fmt::{self, Write}; mod ast_id; diff --git a/crates/syntax-bridge/src/lib.rs b/crates/syntax-bridge/src/lib.rs index 1ded2b411319..815b4f279900 100644 --- a/crates/syntax-bridge/src/lib.rs +++ b/crates/syntax-bridge/src/lib.rs @@ -1,5 +1,10 @@ //! Conversions between [`SyntaxNode`] and [`tt::TokenTree`]. +#![cfg_attr(feature = "in-rust-tree", feature(rustc_private))] + +#[cfg(feature = "in-rust-tree")] +extern crate rustc_driver as _; + use std::{collections::VecDeque, fmt, hash::Hash}; use intern::Symbol; diff --git a/crates/syntax/Cargo.toml b/crates/syntax/Cargo.toml index 1ee93013e3e8..8909fb423c4d 100644 --- a/crates/syntax/Cargo.toml +++ b/crates/syntax/Cargo.toml @@ -33,6 +33,7 @@ rustc_apfloat = "0.2.3" test-utils.workspace = true [features] +default = [] in-rust-tree = [] [lints] diff --git a/crates/syntax/src/lib.rs b/crates/syntax/src/lib.rs index de341f05538e..9e3083066c94 100644 --- a/crates/syntax/src/lib.rs +++ b/crates/syntax/src/lib.rs @@ -19,6 +19,11 @@ //! [RFC]: //! [Swift]: +#![cfg_attr(feature = "in-rust-tree", feature(rustc_private))] + +#[cfg(feature = "in-rust-tree")] +extern crate rustc_driver as _; + mod parsing; mod ptr; mod syntax_error; diff --git a/crates/test-fixture/Cargo.toml b/crates/test-fixture/Cargo.toml index 353d4c312dba..7760ae7aa045 100644 --- a/crates/test-fixture/Cargo.toml +++ b/crates/test-fixture/Cargo.toml @@ -21,5 +21,9 @@ intern.workspace = true triomphe.workspace = true paths.workspace = true +[features] +default = [] +in-rust-tree = [] + [lints] workspace = true diff --git a/crates/test-fixture/src/lib.rs b/crates/test-fixture/src/lib.rs index 457cd3ac854a..5e8b250c24a0 100644 --- a/crates/test-fixture/src/lib.rs +++ b/crates/test-fixture/src/lib.rs @@ -1,4 +1,10 @@ //! A set of high-level utility fixture methods to use in tests. + +#![cfg_attr(feature = "in-rust-tree", feature(rustc_private))] + +#[cfg(feature = "in-rust-tree")] +extern crate rustc_driver as _; + use std::{any::TypeId, mem, str::FromStr, sync}; use base_db::target::TargetData; diff --git a/crates/tt/Cargo.toml b/crates/tt/Cargo.toml index 82e7c24668fe..3183b72a6629 100644 --- a/crates/tt/Cargo.toml +++ b/crates/tt/Cargo.toml @@ -21,6 +21,7 @@ intern.workspace = true ra-ap-rustc_lexer.workspace = true [features] +default = [] in-rust-tree = [] [lints] diff --git a/crates/tt/src/lib.rs b/crates/tt/src/lib.rs index ea0752250db1..d6a743c695e8 100644 --- a/crates/tt/src/lib.rs +++ b/crates/tt/src/lib.rs @@ -5,6 +5,9 @@ #![cfg_attr(feature = "in-rust-tree", feature(rustc_private))] +#[cfg(feature = "in-rust-tree")] +extern crate rustc_driver as _; + #[cfg(not(feature = "in-rust-tree"))] extern crate ra_ap_rustc_lexer as rustc_lexer; #[cfg(feature = "in-rust-tree")] From ed7cfb52567fffb5d8224feb19bf0f22dd3b1799 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jana=20D=C3=B6nszelmann?= Date: Thu, 21 Aug 2025 13:30:55 +0200 Subject: [PATCH 2/4] EII liveness analysis From f77781c19d053ef25afb05a54e8c5cbcb4504b13 Mon Sep 17 00:00:00 2001 From: The rustc-josh-sync Cronjob Bot Date: Mon, 15 Dec 2025 04:25:42 +0000 Subject: [PATCH 3/4] Prepare for merging from rust-lang/rust This updates the rust-version file to 0208ee09be465f69005a7a12c28d5eccac7d5f34. --- rust-version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust-version b/rust-version index 7a84872f266d..dcf82c94aaee 100644 --- a/rust-version +++ b/rust-version @@ -1 +1 @@ -dfe1b8c97bcde283102f706d5dcdc3649e5e12e3 +0208ee09be465f69005a7a12c28d5eccac7d5f34 From f6c67ed0a4e9b7ec436f9f2c62b6aa856480a2a1 Mon Sep 17 00:00:00 2001 From: The rustc-josh-sync Cronjob Bot Date: Mon, 15 Dec 2025 04:30:49 +0000 Subject: [PATCH 4/4] Format code --- crates/ide-completion/src/lib.rs | 1 - crates/parser/src/lib.rs | 4 ++-- crates/proc-macro-api/src/lib.rs | 1 - crates/project-model/src/lib.rs | 1 - 4 files changed, 2 insertions(+), 5 deletions(-) diff --git a/crates/ide-completion/src/lib.rs b/crates/ide-completion/src/lib.rs index c9d5971cd0e3..33ab43fa614a 100644 --- a/crates/ide-completion/src/lib.rs +++ b/crates/ide-completion/src/lib.rs @@ -2,7 +2,6 @@ // It's useful to refer to code that is private in doc comments. #![allow(rustdoc::private_intra_doc_links)] - #![cfg_attr(feature = "in-rust-tree", feature(rustc_private))] #[cfg(feature = "in-rust-tree")] diff --git a/crates/parser/src/lib.rs b/crates/parser/src/lib.rs index 81cdc188012c..4478bf4e3733 100644 --- a/crates/parser/src/lib.rs +++ b/crates/parser/src/lib.rs @@ -24,9 +24,9 @@ #[cfg(not(feature = "in-rust-tree"))] extern crate ra_ap_rustc_lexer as rustc_lexer; #[cfg(feature = "in-rust-tree")] -extern crate rustc_lexer; -#[cfg(feature = "in-rust-tree")] extern crate rustc_driver as _; +#[cfg(feature = "in-rust-tree")] +extern crate rustc_lexer; mod event; mod frontmatter; diff --git a/crates/proc-macro-api/src/lib.rs b/crates/proc-macro-api/src/lib.rs index 8e1faca00a1b..85b250eddfd4 100644 --- a/crates/proc-macro-api/src/lib.rs +++ b/crates/proc-macro-api/src/lib.rs @@ -11,7 +11,6 @@ feature(proc_macro_internals, proc_macro_diagnostic, proc_macro_span) )] #![allow(internal_features)] - #![cfg_attr(feature = "in-rust-tree", feature(rustc_private))] #[cfg(feature = "in-rust-tree")] diff --git a/crates/project-model/src/lib.rs b/crates/project-model/src/lib.rs index 0d89e13ed374..3414b52d4514 100644 --- a/crates/project-model/src/lib.rs +++ b/crates/project-model/src/lib.rs @@ -17,7 +17,6 @@ // It's useful to refer to code that is private in doc comments. #![allow(rustdoc::private_intra_doc_links)] - #![cfg_attr(feature = "in-rust-tree", feature(rustc_private))] #[cfg(feature = "in-rust-tree")]