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

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

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

+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

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

+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

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

+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

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

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

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

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

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

+4
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
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+
#[cfg(all(feature = "in-rust-tree", test))]
7+
extern crate rustc_driver as _;
8+
59
mod apply_change;
610

711
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

+4
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@
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+
#[cfg(all(feature = "in-rust-tree", test))]
28+
extern crate rustc_driver as _;
29+
2630
mod handlers {
2731
pub(crate) mod await_outside_of_async;
2832
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

+4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
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+
#[cfg(all(feature = "in-rust-tree", test))]
8+
extern crate rustc_driver as _;
9+
610
// Feature: Structural Search and Replace
711
//
812
// 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

+4-1
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,12 @@
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+
#[cfg(all(feature = "in-rust-tree", test))]
16+
extern crate rustc_driver as _;
17+
1518
#[cfg(test)]
1619
mod fixture;
1720

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

+5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
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+
#[cfg(all(feature = "in-rust-tree", test))]
6+
extern crate rustc_driver as _;
7+
38
// Note, don't remove any public api from this. This API is consumed by external tools
49
// to run rust-analyzer as a library.
510
use std::{collections::hash_map::Entry, iter, mem, path::Path, sync};

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

+2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
//! `hir_def::macro_expansion_tests::mbe`.
88
99
#![cfg_attr(feature = "in-rust-tree", feature(rustc_private))]
10+
#[cfg(all(feature = "in-rust-tree", test))]
11+
extern crate rustc_driver as _;
1012

1113
#[cfg(not(feature = "in-rust-tree"))]
1214
extern crate ra_ap_rustc_lexer as rustc_lexer;

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

+3
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,10 @@
1818
//! [`Parser`]: crate::parser::Parser
1919
2020
#![allow(rustdoc::private_intra_doc_links)]
21+
2122
#![cfg_attr(feature = "in-rust-tree", feature(rustc_private))]
23+
#[cfg(all(feature = "in-rust-tree", test))]
24+
extern crate rustc_driver as _;
2225

2326
#[cfg(not(feature = "in-rust-tree"))]
2427
extern crate ra_ap_rustc_lexer as rustc_lexer;

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

+4
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
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+
#[cfg(all(feature = "in-rust-tree", test))]
10+
extern crate rustc_driver as _;
11+
812
pub mod legacy_protocol {
913
pub mod json;
1014
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

+4
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@
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+
#[cfg(all(feature = "in-rust-tree", test))]
20+
extern crate rustc_driver as _;
21+
1822
pub mod project_json;
1923
pub mod toolchain_info {
2024
pub mod rustc_cfg;

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

+4
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@
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+
#[cfg(all(feature = "in-rust-tree", test))]
14+
extern crate rustc_driver as _;
15+
1216
pub mod cli;
1317

1418
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

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

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

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

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

59
use intern::Symbol;

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

+2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
//! [Swift]: <https://github.com/apple/swift/blob/13d593df6f359d0cb2fc81cfaac273297c539455/lib/Syntax/README.md>
2121
2222
#![cfg_attr(feature = "in-rust-tree", feature(rustc_private))]
23+
#[cfg(all(feature = "in-rust-tree", test))]
24+
extern crate rustc_driver as _;
2325

2426
#[cfg(not(feature = "in-rust-tree"))]
2527
extern crate ra_ap_rustc_lexer as rustc_lexer;

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

+5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
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+
#[cfg(all(feature = "in-rust-tree", test))]
5+
extern crate rustc_driver as _;
6+
27
use std::{iter, mem, str::FromStr, sync};
38

49
use base_db::{

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

+2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
//! The `TokenTree` is semantically a tree, but for performance reasons it is stored as a flat structure.
55
66
#![cfg_attr(feature = "in-rust-tree", feature(rustc_private))]
7+
#[cfg(all(feature = "in-rust-tree", test))]
8+
extern crate rustc_driver as _;
79

810
#[cfg(not(feature = "in-rust-tree"))]
911
extern crate ra_ap_rustc_lexer as rustc_lexer;

0 commit comments

Comments
 (0)