Skip to content

Commit 3b7ca5e

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 c6df1d2 commit 3b7ca5e

File tree

35 files changed

+172
-2
lines changed

35 files changed

+172
-2
lines changed

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

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

33+
[features]
34+
default = []
35+
in-rust-tree = []
36+
3337
[lints]
3438
workspace = true

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
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+
5+
#[cfg_attr(all(feature = "in-rust-tree", test), allow(unused_extern_crates))]
6+
#[cfg(all(feature = "in-rust-tree", test))]
7+
extern crate rustc_driver;
8+
29
// FIXME: Rename this crate, base db is non descriptive
310
mod change;
411
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: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
//! cfg defines conditional compiling options, `cfg` attribute parser and evaluator
22
3+
#![cfg_attr(feature = "in-rust-tree", feature(rustc_private))]
4+
5+
#[cfg_attr(all(feature = "in-rust-tree", test), allow(unused_extern_crates))]
6+
#[cfg(all(feature = "in-rust-tree", test))]
7+
extern crate rustc_driver;
8+
39
mod cfg_expr;
410
mod dnf;
511
#[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: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@
99
1010
#![cfg_attr(feature = "in-rust-tree", feature(rustc_private))]
1111

12+
#[cfg_attr(all(feature = "in-rust-tree", test), allow(unused_extern_crates))]
13+
#[cfg(all(feature = "in-rust-tree", test))]
14+
extern crate rustc_driver;
15+
1216
#[cfg(feature = "in-rust-tree")]
1317
extern crate rustc_parse_format;
1418

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: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
44
#![cfg_attr(feature = "in-rust-tree", feature(rustc_private))]
55

6+
#[cfg_attr(all(feature = "in-rust-tree", test), allow(unused_extern_crates))]
7+
#[cfg(all(feature = "in-rust-tree", test))]
8+
extern crate rustc_driver;
9+
610
#[cfg(feature = "in-rust-tree")]
711
extern crate rustc_index;
812

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,14 @@
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+
24+
#[cfg_attr(all(feature = "in-rust-tree", test), allow(unused_extern_crates))]
25+
#[cfg(all(feature = "in-rust-tree", test))]
26+
extern crate rustc_driver;
27+
2328
mod attrs;
2429
mod from_id;
2530
mod has_source;

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,10 @@
6060
6161
#![cfg_attr(feature = "in-rust-tree", feature(rustc_private))]
6262

63+
#[cfg_attr(all(feature = "in-rust-tree", test), allow(unused_extern_crates))]
64+
#[cfg(all(feature = "in-rust-tree", test))]
65+
extern crate rustc_driver;
66+
6367
mod assist_config;
6468
mod assist_context;
6569
#[cfg(test)]

0 commit comments

Comments
 (0)