Skip to content

Commit 5ae6a16

Browse files
committed
[DO NOT MERGE] rust-analyzer: hacks to get the main tests to build
I needed to: - Consistently use `feature(rustc_private)` on all participating r-a crates under `test` scenario. - Force an `extern crate rustc_driver;` on all the r-a crates for reasons I don't yet understand. At least this builds, *at all*.
1 parent 641d85b commit 5ae6a16

File tree

35 files changed

+127
-2
lines changed

35 files changed

+127
-2
lines changed

src/tools/rust-analyzer/crates/base-db/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,8 @@ vfs.workspace = true
3030
span.workspace = true
3131
intern.workspace = true
3232

33+
[features]
34+
in-rust-tree = []
35+
3336
[lints]
3437
workspace = true

src/tools/rust-analyzer/crates/base-db/src/lib.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
//! base_db defines basic database traits. The concrete DB is defined by ide.
2+
3+
#![cfg_attr(feature = "in-rust-tree", feature(rustc_private))]
4+
#[cfg(all(feature = "in-rust-tree", test))]
5+
extern crate rustc_driver as _;
6+
27
// FIXME: Rename this crate, base db is non descriptive
38
mod change;
49
mod input;

src/tools/rust-analyzer/crates/cfg/Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,9 @@ derive_arbitrary = "1.3.2"
3333
syntax-bridge.workspace = true
3434
syntax.workspace = true
3535

36+
[features]
37+
default = []
38+
in-rust-tree = []
39+
3640
[lints]
3741
workspace = true

src/tools/rust-analyzer/crates/cfg/src/lib.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
//! cfg defines conditional compiling options, `cfg` attribute parser and evaluator
22
3+
#![cfg_attr(feature = "in-rust-tree", feature(rustc_private))]
4+
#[cfg(all(feature = "in-rust-tree", test))]
5+
extern crate rustc_driver as _;
6+
37
mod cfg_expr;
48
mod dnf;
59
#[cfg(test)]

src/tools/rust-analyzer/crates/hir-def/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ expect-test.workspace = true
5454
test-utils.workspace = true
5555
test-fixture.workspace = true
5656
syntax-bridge.workspace = true
57+
5758
[features]
5859
in-rust-tree = ["hir-expand/in-rust-tree"]
5960

src/tools/rust-analyzer/crates/hir-def/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
//! actually true.
99
1010
#![cfg_attr(feature = "in-rust-tree", feature(rustc_private))]
11+
#[cfg(all(feature = "in-rust-tree", test))]
12+
extern crate rustc_driver as _;
1113

1214
#[cfg(feature = "in-rust-tree")]
1315
extern crate rustc_parse_format;

src/tools/rust-analyzer/crates/hir-expand/src/lib.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,13 @@
33
//! Specifically, it implements a concept of `MacroFile` -- a file whose syntax
44
//! tree originates not from the text of some `FileId`, but from some macro
55
//! expansion.
6+
67
#![cfg_attr(feature = "in-rust-tree", feature(rustc_private))]
78

9+
#[cfg_attr(all(feature = "in-rust-tree", test), allow(unused_extern_crates))]
10+
#[cfg(all(feature = "in-rust-tree", test))]
11+
extern crate rustc_driver;
12+
813
pub mod attrs;
914
pub mod builtin;
1015
pub mod change;

src/tools/rust-analyzer/crates/hir-ty/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
//! information and various assists.
33
44
#![cfg_attr(feature = "in-rust-tree", feature(rustc_private))]
5+
#[cfg(all(feature = "in-rust-tree", test))]
6+
extern crate rustc_driver as _;
57

68
#[cfg(feature = "in-rust-tree")]
79
extern crate rustc_index;

src/tools/rust-analyzer/crates/hir/src/lib.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,12 @@
1717
//! from the ide with completions, hovers, etc. It is a (soft, internal) boundary:
1818
//! <https://www.tedinski.com/2018/02/06/system-boundaries.html>.
1919
20-
#![cfg_attr(feature = "in-rust-tree", feature(rustc_private))]
2120
#![recursion_limit = "512"]
2221

22+
#![cfg_attr(feature = "in-rust-tree", feature(rustc_private))]
23+
#[cfg(all(feature = "in-rust-tree", test))]
24+
extern crate rustc_driver as _;
25+
2326
mod attrs;
2427
mod from_id;
2528
mod has_source;

src/tools/rust-analyzer/crates/ide-assists/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@
5959
//! <https://rust-analyzer.github.io/blog/2020/09/28/how-to-make-a-light-bulb.html>
6060
6161
#![cfg_attr(feature = "in-rust-tree", feature(rustc_private))]
62+
#[cfg(all(feature = "in-rust-tree", test))]
63+
extern crate rustc_driver as _;
6264

6365
mod assist_config;
6466
mod assist_context;

0 commit comments

Comments
 (0)