Skip to content

Commit 2a87067

Browse files
committed
Auto merge of rust-lang#136779 - jieyouxu:rahhh, r=<try>
[DO NOT MERGE] `./x test rust-analyzer` I somehow made `./x test rust-analyzer` work on my machine[^machine], **but at what cost?** Not intended for merge but only as a reference. If we do want to land this, I'll need to tidy this up. Notes: - Unrelated tracing bits are extracted to rust-lang#137080. - I abused a bunch of cargo features `in-rust-tree`. It probably doesn't need to be, and simply `--cfg` might work. I was trying to get the main rust-analyzer tests to build *at all*. Anything building is already a miracle. - I had to slap a bunch of the following to all the r-a crates to get the tests to build at all. I don't 100% understand why, but otherwise I get a whole ton of ``expected `rustc_lexer` to be available in rlib format`` build failures. ```rs #![cfg_attr(feature = "in-rust-tree", feature(rustc_private))] #[cfg(all(feature = "in-rust-tree", test))] extern crate rustc_driver as _; ``` - Skipped one config test that was fixed on r-a master but not synced here in r-l/r yet. [^machine]: `x86_64-unknown-linux-gnu`, haven't bothered trying this on msvc yet. try-job: aarch64-gnu try-job: x86_64-apple-1 try-job: aarch64-apple try-job: i686-mingw-1 try-job: x86_64-mingw-1 try-job: i686-msvc-1 try-job: x86_64-msvc-1
2 parents 608e228 + f357199 commit 2a87067

File tree

39 files changed

+697
-155
lines changed

39 files changed

+697
-155
lines changed

src/bootstrap/src/core/build_steps/compile.rs

+188-121
Large diffs are not rendered by default.

src/bootstrap/src/core/build_steps/test.rs

+367-20
Large diffs are not rendered by default.

src/bootstrap/src/core/builder/mod.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use crate::core::config::{DryRun, TargetSelection};
2121
use crate::utils::cache::Cache;
2222
use crate::utils::exec::{BootstrapCommand, command};
2323
use crate::utils::helpers::{self, LldThreads, add_dylib_path, exe, libdir, linker_args, t};
24-
use crate::{Build, Crate};
24+
use crate::{Build, Crate, trace};
2525

2626
mod cargo;
2727

@@ -971,6 +971,7 @@ impl<'a> Builder<'a> {
971971
test::Cargotest,
972972
test::Cargo,
973973
test::RustAnalyzer,
974+
test::RustAnalyzerProcMacroSrv,
974975
test::ErrorIndex,
975976
test::Distcheck,
976977
test::Nomicon,
@@ -1215,7 +1216,7 @@ impl<'a> Builder<'a> {
12151216
/// `Compiler` since all `Compiler` instances are meant to be obtained through this function,
12161217
/// since it ensures that they are valid (i.e., built and assembled).
12171218
pub fn compiler(&self, stage: u32, host: TargetSelection) -> Compiler {
1218-
self.ensure(compile::Assemble { target_compiler: Compiler { stage, host } })
1219+
self.ensure(compile::Assemble { output_compiler: Compiler { stage, host } })
12191220
}
12201221

12211222
/// Similar to `compiler`, except handles the full-bootstrap option to
@@ -1331,6 +1332,8 @@ impl<'a> Builder<'a> {
13311332
return;
13321333
}
13331334

1335+
trace!(rustc_lib_paths = ?self.rustc_lib_paths(compiler));
1336+
13341337
add_dylib_path(self.rustc_lib_paths(compiler), cmd);
13351338
}
13361339

src/bootstrap/src/core/builder/tests.rs

+10-10
Original file line numberDiff line numberDiff line change
@@ -352,9 +352,9 @@ mod defaults {
352352
assert_eq!(
353353
first(cache.all::<compile::Assemble>()),
354354
&[
355-
compile::Assemble { target_compiler: Compiler { host: a, stage: 0 } },
356-
compile::Assemble { target_compiler: Compiler { host: a, stage: 1 } },
357-
compile::Assemble { target_compiler: Compiler { host: b, stage: 1 } },
355+
compile::Assemble { output_compiler: Compiler { host: a, stage: 0 } },
356+
compile::Assemble { output_compiler: Compiler { host: a, stage: 1 } },
357+
compile::Assemble { output_compiler: Compiler { host: b, stage: 1 } },
358358
]
359359
);
360360
assert_eq!(
@@ -632,10 +632,10 @@ mod dist {
632632
assert_eq!(
633633
first(cache.all::<compile::Assemble>()),
634634
&[
635-
compile::Assemble { target_compiler: Compiler { host: a, stage: 0 } },
636-
compile::Assemble { target_compiler: Compiler { host: a, stage: 1 } },
637-
compile::Assemble { target_compiler: Compiler { host: a, stage: 2 } },
638-
compile::Assemble { target_compiler: Compiler { host: b, stage: 2 } },
635+
compile::Assemble { output_compiler: Compiler { host: a, stage: 0 } },
636+
compile::Assemble { output_compiler: Compiler { host: a, stage: 1 } },
637+
compile::Assemble { output_compiler: Compiler { host: a, stage: 2 } },
638+
compile::Assemble { output_compiler: Compiler { host: b, stage: 2 } },
639639
]
640640
);
641641
}
@@ -713,9 +713,9 @@ mod dist {
713713
assert_eq!(
714714
first(builder.cache.all::<compile::Assemble>()),
715715
&[
716-
compile::Assemble { target_compiler: Compiler { host: a, stage: 0 } },
717-
compile::Assemble { target_compiler: Compiler { host: a, stage: 1 } },
718-
compile::Assemble { target_compiler: Compiler { host: a, stage: 2 } },
716+
compile::Assemble { output_compiler: Compiler { host: a, stage: 0 } },
717+
compile::Assemble { output_compiler: Compiler { host: a, stage: 1 } },
718+
compile::Assemble { output_compiler: Compiler { host: a, stage: 2 } },
719719
]
720720
);
721721
assert_eq!(

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;

0 commit comments

Comments
 (0)