Unnamed repository; edit this file 'description' to name the repository.
Auto merge of #147372 - jieyouxu:rust-analyzer-main-tests, r=Kobzol
Run main rust-analyzer tests in rust-lang/rust CI Part of rust-lang/rust#147370. MCP: https://github.com/rust-lang/compiler-team/issues/923 This PR prepares `rust-analyzer` crates with `in-rust-tree` cargo featues where needed, and and updates bootstrap to run the main `rust-analyzer` tests in rust-lang/rust CI, not just the `proc-macro-srv` crate tests. This supersedes the earlier attempt at https://github.com/rust-lang/rust/pull/136779. I was honestly expecting more failures in this PR, but looking back at the previous attempt, that makes sense because we no longer run `i686-mingw` (32-bit windows-gnu) which had a _bunch_ of these failures. In the earlier attempt I also disabled the `i686-mingw`-related failures for `i686-msvc` since I didn't feel like digging into 32-bit msvc at the time. Try results from this PR shows that it's most likely limited to 32-bit windows-gnu specifically. ### `rust-analyzer` test remarks - I actually had to _remove_ the `CARGO_WORKSPACE_DIR` `expect-test`-hack in order for `expect-test` to be able to find the test expectation HTML files (for `syntax_highlighting` tests in `ide`). When I added the hack, ironically, it made `expect-test` unable to find the expectation files. I think this was because previously the path was of the `proc-macro-srv` crate specifically, now we point to the root r-a workspace? - The `cfg`-related differences on `aarch64-apple-darwin` might've been fixed? I can't tell, but we don't seem to be observing the differences now. - I'm not sure why `config::{generate_config_documentation, generate_package_json_config}` no longer fails. Perhaps they were fixed to no longer try to write to source directory? ### Review remarks - Commit 1 updates r-a crates that are involved in tests needing artifacts from `rustc_private` compiler crates to use the `in-rust-tree` cargo feature. I briefly tried to use a plain `--cfg=in_rust_tree`, but quickly realized it was very hacky, and needed invasive bootstrap changes. The cargo feature approach seems most "natural"/well-supported to both bootstrap and cargo. - Commit 2 updates bootstrap to not only run the `proc-macro-srv` tests, but the whole r-a tests. - Commit 3 restricts r-a main tests to non-32-bit targets we test in CI, since (1) r-a repo does not run tests against 32-bit platforms, and (2) there are some target pointer width sensitive hash differences causing tests to fail. Notably, this means that we also no longer run r-a `proc-macro-srv` tests against 32-bit targets, but we don't expect that crate to be have target pointer width differences. Discussed this in [#t-compiler/rust-analyzer > 32-bit tests?](https://rust-lang.zulipchat.com/#narrow/channel/185405-t-compiler.2Frust-analyzer/topic/32-bit.20tests.3F/with/563145736). --- // try-job: aarch64-gnu // try-job: aarch64-apple // try-job: x86_64-mingw-1 // try-job: i686-msvc-1 // try-job: x86_64-msvc-1 // try-job: aarch64-msvc-1
bors 4 months ago
parent 6effa6a · parent acb575c · commit aea6cfd
-rw-r--r--crates/base-db/Cargo.toml4
-rw-r--r--crates/base-db/src/lib.rs5
-rw-r--r--crates/cfg/Cargo.toml4
-rw-r--r--crates/cfg/src/lib.rs5
-rw-r--r--crates/ide-completion/Cargo.toml4
-rw-r--r--crates/ide-completion/src/lib.rs5
-rw-r--r--crates/ide-db/Cargo.toml4
-rw-r--r--crates/ide-db/src/lib.rs5
-rw-r--r--crates/ide-diagnostics/Cargo.toml4
-rw-r--r--crates/ide-diagnostics/src/lib.rs5
-rw-r--r--crates/ide-ssr/Cargo.toml4
-rw-r--r--crates/ide-ssr/src/lib.rs5
-rw-r--r--crates/load-cargo/src/lib.rs6
-rw-r--r--crates/parser/src/lib.rs2
-rw-r--r--crates/proc-macro-api/Cargo.toml2
-rw-r--r--crates/proc-macro-api/src/lib.rs5
-rw-r--r--crates/project-model/Cargo.toml4
-rw-r--r--crates/project-model/src/lib.rs5
-rw-r--r--crates/rust-analyzer/Cargo.toml10
-rw-r--r--crates/rust-analyzer/src/lib.rs5
-rw-r--r--crates/rust-analyzer/tests/slow-tests/main.rs4
-rw-r--r--crates/span/Cargo.toml1
-rw-r--r--crates/span/src/lib.rs6
-rw-r--r--crates/syntax-bridge/src/lib.rs5
-rw-r--r--crates/syntax/Cargo.toml1
-rw-r--r--crates/syntax/src/lib.rs5
-rw-r--r--crates/test-fixture/Cargo.toml4
-rw-r--r--crates/test-fixture/src/lib.rs6
-rw-r--r--crates/tt/Cargo.toml1
-rw-r--r--crates/tt/src/lib.rs3
30 files changed, 126 insertions, 3 deletions
diff --git a/crates/base-db/Cargo.toml b/crates/base-db/Cargo.toml
index ea06fd9c48..55dfcbc7e5 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 9793892410..b6e3465211 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 9e2a95dbf3..7207cfcf7d 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 b1ec4c273a..3e3d67cb4a 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 277d5dfa49..6abc009241 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 31e33db104..c9d5971cd0 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 f1f9d85cf9..fca06b69d1 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 0301b50208..338c423254 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 6f1e66948f..ddf5999036 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 fe04bd175c..e001f4b3e4 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 0620bd26fe..1900b069e0 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 977dfb7466..958a26324f 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 a486219efa..28fbfecfde 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 b15bf0cd01..81cdc18801 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 18a2408c40..4de1a3e5dd 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 f0c7ce7efd..8e1faca00a 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 7e0b1f75f7..f825a456de 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 8eee3d1455..0d89e13ed3 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 2e48c5a5a6..d1283ca59e 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 3dea21e564..a6cd431392 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 5a4ad6f380..48433342d5 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 966962bab3..cfb319d688 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 cb91f49249..c44b0198b7 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 1ded2b4113..815b4f2799 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 1ee93013e3..8909fb423c 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 de341f0553..9e3083066c 100644
--- a/crates/syntax/src/lib.rs
+++ b/crates/syntax/src/lib.rs
@@ -19,6 +19,11 @@
//! [RFC]: <https://github.com/rust-lang/rfcs/pull/2256>
//! [Swift]: <https://github.com/apple/swift/blob/13d593df6f359d0cb2fc81cfaac273297c539455/lib/Syntax/README.md>
+#![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 353d4c312d..7760ae7aa0 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 457cd3ac85..5e8b250c24 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 82e7c24668..3183b72a66 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 ea0752250d..d6a743c695 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")]