Skip to content

Commit 07646dd

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 6162ba0 commit 07646dd

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

+4
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

+7
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

+4
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

+6
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

+1
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

+4
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

+5
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

+4
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

+6-1
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

+4
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)]

src/tools/rust-analyzer/crates/ide-completion/Cargo.toml

+4
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,9 @@ expect-test = "1.4.0"
3636
test-utils.workspace = true
3737
test-fixture.workspace = true
3838

39+
[features]
40+
default = []
41+
in-rust-tree = []
42+
3943
[lints]
4044
workspace = true

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

+6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
//! `completions` crate provides utilities for generating completions of user input.
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 completions;
410
mod config;
511
mod context;

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

+4
Original file line numberDiff line numberDiff line change
@@ -49,5 +49,9 @@ expect-test = "1.4.0"
4949
test-utils.workspace = true
5050
test-fixture.workspace = true
5151

52+
[features]
53+
default = []
54+
in-rust-tree = []
55+
5256
[lints]
5357
workspace = true

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

+6
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22
//!
33
//! It is mainly a `HirDatabase` for semantic analysis, plus a `SymbolsDatabase`, for fuzzy search.
44
5+
#![cfg_attr(feature = "in-rust-tree", feature(rustc_private))]
6+
7+
#[cfg_attr(all(feature = "in-rust-tree", test), allow(unused_extern_crates))]
8+
#[cfg(all(feature = "in-rust-tree", test))]
9+
extern crate rustc_driver;
10+
511
mod apply_change;
612

713
pub mod active_parameter;

src/tools/rust-analyzer/crates/ide-diagnostics/Cargo.toml

+4
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,9 @@ expect-test = "1.4.0"
3434
test-utils.workspace = true
3535
test-fixture.workspace = true
3636

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

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

+6
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@
2323
//! There are also a couple of ad-hoc diagnostics implemented directly here, we
2424
//! don't yet have a great pattern for how to do them properly.
2525
26+
#![cfg_attr(feature = "in-rust-tree", feature(rustc_private))]
27+
28+
#[cfg_attr(all(feature = "in-rust-tree", test), allow(unused_extern_crates))]
29+
#[cfg(all(feature = "in-rust-tree", test))]
30+
extern crate rustc_driver;
31+
2632
mod handlers {
2733
pub(crate) mod await_outside_of_async;
2834
pub(crate) mod break_outside_of_loop;

src/tools/rust-analyzer/crates/ide-ssr/Cargo.toml

+4
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,9 @@ expect-test = "1.4.0"
3232
test-utils.workspace = true
3333
test-fixture.workspace = true
3434

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

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

+6
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@
33
//! Allows searching the AST for code that matches one or more patterns and then replacing that code
44
//! based on a template.
55
6+
#![cfg_attr(feature = "in-rust-tree", feature(rustc_private))]
7+
8+
#[cfg_attr(all(feature = "in-rust-tree", test), allow(unused_extern_crates))]
9+
#[cfg(all(feature = "in-rust-tree", test))]
10+
extern crate rustc_driver;
11+
612
// Feature: Structural Search and Replace
713
//
814
// Search and replace with named wildcards that will match any expression, type, path, pattern or item.

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

+6-1
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,14 @@
99
1010
// For proving that RootDatabase is RefUnwindSafe.
1111

12-
#![cfg_attr(feature = "in-rust-tree", feature(rustc_private))]
1312
#![recursion_limit = "128"]
1413

14+
#![cfg_attr(feature = "in-rust-tree", feature(rustc_private))]
15+
16+
#[cfg_attr(all(feature = "in-rust-tree", test), allow(unused_extern_crates))]
17+
#[cfg(all(feature = "in-rust-tree", test))]
18+
extern crate rustc_driver;
19+
1520
#[cfg(test)]
1621
mod fixture;
1722

src/tools/rust-analyzer/crates/load-cargo/src/lib.rs

+7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
//! Loads a Cargo project into a static instance of analysis, without support
22
//! for incorporating changes.
3+
4+
#![cfg_attr(feature = "in-rust-tree", feature(rustc_private))]
5+
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+
310
// Note, don't remove any public api from this. This API is consumed by external tools
411
// to run rust-analyzer as a library.
512
use std::{collections::hash_map::Entry, iter, mem, path::Path, sync};

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

+4
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88
99
#![cfg_attr(feature = "in-rust-tree", feature(rustc_private))]
1010

11+
#[cfg_attr(all(feature = "in-rust-tree", test), allow(unused_extern_crates))]
12+
#[cfg(all(feature = "in-rust-tree", test))]
13+
extern crate rustc_driver;
14+
1115
#[cfg(not(feature = "in-rust-tree"))]
1216
extern crate ra_ap_rustc_lexer as rustc_lexer;
1317
#[cfg(feature = "in-rust-tree")]

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

+5
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,13 @@
1818
//! [`Parser`]: crate::parser::Parser
1919
2020
#![allow(rustdoc::private_intra_doc_links)]
21+
2122
#![cfg_attr(feature = "in-rust-tree", feature(rustc_private))]
2223

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
#[cfg(not(feature = "in-rust-tree"))]
2429
extern crate ra_ap_rustc_lexer as rustc_lexer;
2530
#[cfg(feature = "in-rust-tree")]

src/tools/rust-analyzer/crates/proc-macro-api/Cargo.toml

+4
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,9 @@ span = { path = "../span", version = "0.0.0", default-features = false}
2929

3030
intern.workspace = true
3131

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

src/tools/rust-analyzer/crates/proc-macro-api/src/lib.rs

+6
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@
55
//! is used to provide basic infrastructure for communication between two
66
//! processes: Client (RA itself), Server (the external program)
77
8+
#![cfg_attr(feature = "in-rust-tree", feature(rustc_private))]
9+
10+
#[cfg_attr(all(feature = "in-rust-tree", test), allow(unused_extern_crates))]
11+
#[cfg(all(feature = "in-rust-tree", test))]
12+
extern crate rustc_driver;
13+
814
pub mod legacy_protocol {
915
pub mod json;
1016
pub mod msg;

src/tools/rust-analyzer/crates/project-model/Cargo.toml

+4
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,9 @@ toolchain.workspace = true
3737
[dev-dependencies]
3838
expect-test = "1.4.0"
3939

40+
[features]
41+
default = []
42+
in-rust-tree = []
43+
4044
[lints]
4145
workspace = true

src/tools/rust-analyzer/crates/project-model/src/lib.rs

+6
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@
1515
//! procedural macros).
1616
//! * Lowering of concrete model to a [`base_db::CrateGraph`]
1717
18+
#![cfg_attr(feature = "in-rust-tree", feature(rustc_private))]
19+
20+
#[cfg_attr(all(feature = "in-rust-tree", test), allow(unused_extern_crates))]
21+
#[cfg(all(feature = "in-rust-tree", test))]
22+
extern crate rustc_driver;
23+
1824
pub mod project_json;
1925
pub mod toolchain_info {
2026
pub mod rustc_cfg;

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

+6
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@
99
//! The `cli` submodule implements some batch-processing analysis, primarily as
1010
//! a debugging aid.
1111
12+
#![cfg_attr(feature = "in-rust-tree", feature(rustc_private))]
13+
14+
#[cfg_attr(all(feature = "in-rust-tree", test), allow(unused_extern_crates))]
15+
#[cfg(all(feature = "in-rust-tree", test))]
16+
extern crate rustc_driver;
17+
1218
pub mod cli;
1319

1420
mod command;

src/tools/rust-analyzer/crates/rust-analyzer/tests/slow-tests/main.rs

+6
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@
1010
1111
#![allow(clippy::disallowed_types)]
1212

13+
#![cfg_attr(feature = "in-rust-tree", feature(rustc_private))]
14+
15+
#[cfg_attr(all(feature = "in-rust-tree", test), allow(unused_extern_crates))]
16+
#[cfg(all(feature = "in-rust-tree", test))]
17+
extern crate rustc_driver;
18+
1319
mod cli;
1420
mod ratoml;
1521
mod support;

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

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ stdx.workspace = true
2424

2525
[features]
2626
default = ["ra-salsa"]
27+
in-rust-tree = []
2728

2829
[lints]
2930
workspace = true

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

+7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
11
//! File and span related types.
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
use std::fmt::{self, Write};
310

411
#[cfg(feature = "ra-salsa")]

src/tools/rust-analyzer/crates/syntax-bridge/src/lib.rs

+6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
//! Conversions between [`SyntaxNode`] and [`tt::TokenTree`].
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
use std::{fmt, hash::Hash};
410

511
use intern::Symbol;

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

+4
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@
2121
2222
#![cfg_attr(feature = "in-rust-tree", feature(rustc_private))]
2323

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+
2428
#[cfg(not(feature = "in-rust-tree"))]
2529
extern crate ra_ap_rustc_lexer as rustc_lexer;
2630
#[cfg(feature = "in-rust-tree")]

src/tools/rust-analyzer/crates/test-fixture/Cargo.toml

+4
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,9 @@ span.workspace = true
1919
stdx.workspace = true
2020
intern.workspace = true
2121

22+
[features]
23+
default = []
24+
in-rust-tree = []
25+
2226
[lints]
2327
workspace = true

src/tools/rust-analyzer/crates/test-fixture/src/lib.rs

+7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
11
//! A set of high-level utility fixture methods to use in tests.
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
use std::{iter, mem, str::FromStr, sync};
310

411
use base_db::{

0 commit comments

Comments
 (0)