Skip to content

[DO NOT MERGE] ./x test rust-analyzer #136779

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
309 changes: 188 additions & 121 deletions src/bootstrap/src/core/build_steps/compile.rs

Large diffs are not rendered by default.

387 changes: 367 additions & 20 deletions src/bootstrap/src/core/build_steps/test.rs

Large diffs are not rendered by default.

7 changes: 5 additions & 2 deletions src/bootstrap/src/core/builder/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use crate::core::config::{DryRun, TargetSelection};
use crate::utils::cache::Cache;
use crate::utils::exec::{BootstrapCommand, command};
use crate::utils::helpers::{self, LldThreads, add_dylib_path, exe, libdir, linker_args, t};
use crate::{Build, Crate};
use crate::{Build, Crate, trace};

mod cargo;

Expand Down Expand Up @@ -971,6 +971,7 @@ impl<'a> Builder<'a> {
test::Cargotest,
test::Cargo,
test::RustAnalyzer,
test::RustAnalyzerProcMacroSrv,
test::ErrorIndex,
test::Distcheck,
test::Nomicon,
Expand Down Expand Up @@ -1215,7 +1216,7 @@ impl<'a> Builder<'a> {
/// `Compiler` since all `Compiler` instances are meant to be obtained through this function,
/// since it ensures that they are valid (i.e., built and assembled).
pub fn compiler(&self, stage: u32, host: TargetSelection) -> Compiler {
self.ensure(compile::Assemble { target_compiler: Compiler { stage, host } })
self.ensure(compile::Assemble { output_compiler: Compiler { stage, host } })
}

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

trace!(rustc_lib_paths = ?self.rustc_lib_paths(compiler));

add_dylib_path(self.rustc_lib_paths(compiler), cmd);
}

Expand Down
20 changes: 10 additions & 10 deletions src/bootstrap/src/core/builder/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -352,9 +352,9 @@ mod defaults {
assert_eq!(
first(cache.all::<compile::Assemble>()),
&[
compile::Assemble { target_compiler: Compiler { host: a, stage: 0 } },
compile::Assemble { target_compiler: Compiler { host: a, stage: 1 } },
compile::Assemble { target_compiler: Compiler { host: b, stage: 1 } },
compile::Assemble { output_compiler: Compiler { host: a, stage: 0 } },
compile::Assemble { output_compiler: Compiler { host: a, stage: 1 } },
compile::Assemble { output_compiler: Compiler { host: b, stage: 1 } },
]
);
assert_eq!(
Expand Down Expand Up @@ -632,10 +632,10 @@ mod dist {
assert_eq!(
first(cache.all::<compile::Assemble>()),
&[
compile::Assemble { target_compiler: Compiler { host: a, stage: 0 } },
compile::Assemble { target_compiler: Compiler { host: a, stage: 1 } },
compile::Assemble { target_compiler: Compiler { host: a, stage: 2 } },
compile::Assemble { target_compiler: Compiler { host: b, stage: 2 } },
compile::Assemble { output_compiler: Compiler { host: a, stage: 0 } },
compile::Assemble { output_compiler: Compiler { host: a, stage: 1 } },
compile::Assemble { output_compiler: Compiler { host: a, stage: 2 } },
compile::Assemble { output_compiler: Compiler { host: b, stage: 2 } },
]
);
}
Expand Down Expand Up @@ -713,9 +713,9 @@ mod dist {
assert_eq!(
first(builder.cache.all::<compile::Assemble>()),
&[
compile::Assemble { target_compiler: Compiler { host: a, stage: 0 } },
compile::Assemble { target_compiler: Compiler { host: a, stage: 1 } },
compile::Assemble { target_compiler: Compiler { host: a, stage: 2 } },
compile::Assemble { output_compiler: Compiler { host: a, stage: 0 } },
compile::Assemble { output_compiler: Compiler { host: a, stage: 1 } },
compile::Assemble { output_compiler: Compiler { host: a, stage: 2 } },
]
);
assert_eq!(
Expand Down
3 changes: 3 additions & 0 deletions src/tools/rust-analyzer/crates/base-db/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,8 @@ vfs.workspace = true
span.workspace = true
intern.workspace = true

[features]
in-rust-tree = []

[lints]
workspace = true
5 changes: 5 additions & 0 deletions src/tools/rust-analyzer/crates/base-db/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
//! base_db defines basic database traits. The concrete DB is defined by ide.

#![cfg_attr(feature = "in-rust-tree", feature(rustc_private))]
#[cfg(all(feature = "in-rust-tree", test))]
extern crate rustc_driver as _;
Comment on lines +3 to +5
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will we need to add this prelude for any new crate we add, or only for those that have (unit) tests?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only for new crates that have unit tests AFAIK. What I did basically was to tag all the crates that had unit tests (which complained about not finding rustc_lexer and friends).


// FIXME: Rename this crate, base db is non descriptive
mod change;
mod input;
Expand Down
4 changes: 4 additions & 0 deletions src/tools/rust-analyzer/crates/cfg/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,9 @@ derive_arbitrary = "1.3.2"
syntax-bridge.workspace = true
syntax.workspace = true

[features]
default = []
in-rust-tree = []

[lints]
workspace = true
4 changes: 4 additions & 0 deletions src/tools/rust-analyzer/crates/cfg/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
//! cfg defines conditional compiling options, `cfg` attribute parser and evaluator

#![cfg_attr(feature = "in-rust-tree", feature(rustc_private))]
#[cfg(all(feature = "in-rust-tree", test))]
extern crate rustc_driver as _;

mod cfg_expr;
mod dnf;
#[cfg(test)]
Expand Down
1 change: 1 addition & 0 deletions src/tools/rust-analyzer/crates/hir-def/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ expect-test.workspace = true
test-utils.workspace = true
test-fixture.workspace = true
syntax-bridge.workspace = true

[features]
in-rust-tree = ["hir-expand/in-rust-tree"]

Expand Down
2 changes: 2 additions & 0 deletions src/tools/rust-analyzer/crates/hir-def/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
//! actually true.

#![cfg_attr(feature = "in-rust-tree", feature(rustc_private))]
#[cfg(all(feature = "in-rust-tree", test))]
extern crate rustc_driver as _;

#[cfg(feature = "in-rust-tree")]
extern crate rustc_parse_format;
Expand Down
5 changes: 5 additions & 0 deletions src/tools/rust-analyzer/crates/hir-expand/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,13 @@
//! Specifically, it implements a concept of `MacroFile` -- a file whose syntax
//! tree originates not from the text of some `FileId`, but from some macro
//! expansion.

#![cfg_attr(feature = "in-rust-tree", feature(rustc_private))]

#[cfg_attr(all(feature = "in-rust-tree", test), allow(unused_extern_crates))]
#[cfg(all(feature = "in-rust-tree", test))]
extern crate rustc_driver;

pub mod attrs;
pub mod builtin;
pub mod change;
Expand Down
2 changes: 2 additions & 0 deletions src/tools/rust-analyzer/crates/hir-ty/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
//! information and various assists.

#![cfg_attr(feature = "in-rust-tree", feature(rustc_private))]
#[cfg(all(feature = "in-rust-tree", test))]
extern crate rustc_driver as _;

#[cfg(feature = "in-rust-tree")]
extern crate rustc_index;
Expand Down
5 changes: 4 additions & 1 deletion src/tools/rust-analyzer/crates/hir/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,12 @@
//! from the ide with completions, hovers, etc. It is a (soft, internal) boundary:
//! <https://www.tedinski.com/2018/02/06/system-boundaries.html>.

#![cfg_attr(feature = "in-rust-tree", feature(rustc_private))]
#![recursion_limit = "512"]

#![cfg_attr(feature = "in-rust-tree", feature(rustc_private))]
#[cfg(all(feature = "in-rust-tree", test))]
extern crate rustc_driver as _;

mod attrs;
mod from_id;
mod has_source;
Expand Down
2 changes: 2 additions & 0 deletions src/tools/rust-analyzer/crates/ide-assists/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@
//! <https://rust-analyzer.github.io/blog/2020/09/28/how-to-make-a-light-bulb.html>

#![cfg_attr(feature = "in-rust-tree", feature(rustc_private))]
#[cfg(all(feature = "in-rust-tree", test))]
extern crate rustc_driver as _;

mod assist_config;
mod assist_context;
Expand Down
4 changes: 4 additions & 0 deletions src/tools/rust-analyzer/crates/ide-completion/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,9 @@ expect-test = "1.4.0"
test-utils.workspace = true
test-fixture.workspace = true

[features]
default = []
in-rust-tree = []

[lints]
workspace = true
4 changes: 4 additions & 0 deletions src/tools/rust-analyzer/crates/ide-completion/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
//! `completions` crate provides utilities for generating completions of user input.

#![cfg_attr(feature = "in-rust-tree", feature(rustc_private))]
#[cfg(all(feature = "in-rust-tree", test))]
extern crate rustc_driver as _;

mod completions;
mod config;
mod context;
Expand Down
4 changes: 4 additions & 0 deletions src/tools/rust-analyzer/crates/ide-db/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,9 @@ expect-test = "1.4.0"
test-utils.workspace = true
test-fixture.workspace = true

[features]
default = []
in-rust-tree = []

[lints]
workspace = true
4 changes: 4 additions & 0 deletions src/tools/rust-analyzer/crates/ide-db/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
//!
//! It is mainly a `HirDatabase` for semantic analysis, plus a `SymbolsDatabase`, for fuzzy search.

#![cfg_attr(feature = "in-rust-tree", feature(rustc_private))]
#[cfg(all(feature = "in-rust-tree", test))]
extern crate rustc_driver as _;

mod apply_change;

pub mod active_parameter;
Expand Down
4 changes: 4 additions & 0 deletions src/tools/rust-analyzer/crates/ide-diagnostics/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,9 @@ expect-test = "1.4.0"
test-utils.workspace = true
test-fixture.workspace = true

[features]
default = []
in-rust-tree = []

[lints]
workspace = true
4 changes: 4 additions & 0 deletions src/tools/rust-analyzer/crates/ide-diagnostics/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@
//! There are also a couple of ad-hoc diagnostics implemented directly here, we
//! don't yet have a great pattern for how to do them properly.

#![cfg_attr(feature = "in-rust-tree", feature(rustc_private))]
#[cfg(all(feature = "in-rust-tree", test))]
extern crate rustc_driver as _;

mod handlers {
pub(crate) mod await_outside_of_async;
pub(crate) mod break_outside_of_loop;
Expand Down
4 changes: 4 additions & 0 deletions src/tools/rust-analyzer/crates/ide-ssr/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,9 @@ expect-test = "1.4.0"
test-utils.workspace = true
test-fixture.workspace = true

[features]
default = []
in-rust-tree = []

[lints]
workspace = true
4 changes: 4 additions & 0 deletions src/tools/rust-analyzer/crates/ide-ssr/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
//! Allows searching the AST for code that matches one or more patterns and then replacing that code
//! based on a template.

#![cfg_attr(feature = "in-rust-tree", feature(rustc_private))]
#[cfg(all(feature = "in-rust-tree", test))]
extern crate rustc_driver as _;

// Feature: Structural Search and Replace
//
// Search and replace with named wildcards that will match any expression, type, path, pattern or item.
Expand Down
5 changes: 4 additions & 1 deletion src/tools/rust-analyzer/crates/ide/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,12 @@

// For proving that RootDatabase is RefUnwindSafe.

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

#![cfg_attr(feature = "in-rust-tree", feature(rustc_private))]
#[cfg(all(feature = "in-rust-tree", test))]
extern crate rustc_driver as _;

#[cfg(test)]
mod fixture;

Expand Down
5 changes: 5 additions & 0 deletions src/tools/rust-analyzer/crates/load-cargo/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
//! Loads a Cargo project into a static instance of analysis, without support
//! for incorporating changes.

#![cfg_attr(feature = "in-rust-tree", feature(rustc_private))]
#[cfg(all(feature = "in-rust-tree", test))]
extern crate rustc_driver as _;

// Note, don't remove any public api from this. This API is consumed by external tools
// to run rust-analyzer as a library.
use std::{collections::hash_map::Entry, iter, mem, path::Path, sync};
Expand Down
2 changes: 2 additions & 0 deletions src/tools/rust-analyzer/crates/mbe/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
//! `hir_def::macro_expansion_tests::mbe`.

#![cfg_attr(feature = "in-rust-tree", feature(rustc_private))]
#[cfg(all(feature = "in-rust-tree", test))]
extern crate rustc_driver as _;

#[cfg(not(feature = "in-rust-tree"))]
extern crate ra_ap_rustc_lexer as rustc_lexer;
Expand Down
3 changes: 3 additions & 0 deletions src/tools/rust-analyzer/crates/parser/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@
//! [`Parser`]: crate::parser::Parser

#![allow(rustdoc::private_intra_doc_links)]

#![cfg_attr(feature = "in-rust-tree", feature(rustc_private))]
#[cfg(all(feature = "in-rust-tree", test))]
extern crate rustc_driver as _;

#[cfg(not(feature = "in-rust-tree"))]
extern crate ra_ap_rustc_lexer as rustc_lexer;
Expand Down
4 changes: 4 additions & 0 deletions src/tools/rust-analyzer/crates/proc-macro-api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,9 @@ span = { path = "../span", version = "0.0.0", default-features = false}

intern.workspace = true

[features]
default = []
in-rust-tree = []

[lints]
workspace = true
4 changes: 4 additions & 0 deletions src/tools/rust-analyzer/crates/proc-macro-api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
//! is used to provide basic infrastructure for communication between two
//! processes: Client (RA itself), Server (the external program)

#![cfg_attr(feature = "in-rust-tree", feature(rustc_private))]
#[cfg(all(feature = "in-rust-tree", test))]
extern crate rustc_driver as _;

pub mod legacy_protocol {
pub mod json;
pub mod msg;
Expand Down
4 changes: 4 additions & 0 deletions src/tools/rust-analyzer/crates/project-model/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,9 @@ toolchain.workspace = true
[dev-dependencies]
expect-test = "1.4.0"

[features]
default = []
in-rust-tree = []

[lints]
workspace = true
4 changes: 4 additions & 0 deletions src/tools/rust-analyzer/crates/project-model/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
//! procedural macros).
//! * Lowering of concrete model to a [`base_db::CrateGraph`]

#![cfg_attr(feature = "in-rust-tree", feature(rustc_private))]
#[cfg(all(feature = "in-rust-tree", test))]
extern crate rustc_driver as _;

pub mod project_json;
pub mod toolchain_info {
pub mod rustc_cfg;
Expand Down
4 changes: 4 additions & 0 deletions src/tools/rust-analyzer/crates/rust-analyzer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
//! The `cli` submodule implements some batch-processing analysis, primarily as
//! a debugging aid.

#![cfg_attr(feature = "in-rust-tree", feature(rustc_private))]
#[cfg(all(feature = "in-rust-tree", test))]
extern crate rustc_driver as _;

pub mod cli;

mod command;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@

#![allow(clippy::disallowed_types)]

#![cfg_attr(feature = "in-rust-tree", feature(rustc_private))]

#[cfg_attr(all(feature = "in-rust-tree", test), allow(unused_extern_crates))]
#[cfg(all(feature = "in-rust-tree", test))]
extern crate rustc_driver;

mod cli;
mod ratoml;
mod support;
Expand Down
1 change: 1 addition & 0 deletions src/tools/rust-analyzer/crates/span/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ stdx.workspace = true

[features]
default = ["ra-salsa"]
in-rust-tree = []

[lints]
workspace = true
5 changes: 5 additions & 0 deletions src/tools/rust-analyzer/crates/span/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
//! File and span related types.

#![cfg_attr(feature = "in-rust-tree", feature(rustc_private))]
#[cfg(all(feature = "in-rust-tree", test))]
extern crate rustc_driver as _;

use std::fmt::{self, Write};

#[cfg(feature = "ra-salsa")]
Expand Down
4 changes: 4 additions & 0 deletions src/tools/rust-analyzer/crates/syntax-bridge/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
//! Conversions between [`SyntaxNode`] and [`tt::TokenTree`].

#![cfg_attr(feature = "in-rust-tree", feature(rustc_private))]
#[cfg(all(feature = "in-rust-tree", test))]
extern crate rustc_driver as _;

use std::{fmt, hash::Hash};

use intern::Symbol;
Expand Down
Loading
Loading