Skip to content

Commit

Permalink
Auto merge of #16150 - Veykril:text-fixture, r=Veykril
Browse files Browse the repository at this point in the history
internal: Move out `WithFixture` into dev-dep only crate
  • Loading branch information
bors committed Dec 18, 2023
2 parents 5daf090 + f49a2fe commit ae2c322
Show file tree
Hide file tree
Showing 59 changed files with 189 additions and 119 deletions.
25 changes: 23 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 7 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,9 @@ proc-macro-srv = { path = "./crates/proc-macro-srv", version = "0.0.0" }
proc-macro-srv-cli = { path = "./crates/proc-macro-srv-cli", version = "0.0.0" }
profile = { path = "./crates/profile", version = "0.0.0" }
project-model = { path = "./crates/project-model", version = "0.0.0" }
sourcegen = { path = "./crates/sourcegen", version = "0.0.0" }
span = { path = "./crates/span", version = "0.0.0" }
stdx = { path = "./crates/stdx", version = "0.0.0" }
syntax = { path = "./crates/syntax", version = "0.0.0" }
test-utils = { path = "./crates/test-utils", version = "0.0.0" }
text-edit = { path = "./crates/text-edit", version = "0.0.0" }
toolchain = { path = "./crates/toolchain", version = "0.0.0" }
tt = { path = "./crates/tt", version = "0.0.0" }
Expand All @@ -84,6 +82,9 @@ rustc-dependencies = { path = "./crates/rustc-dependencies", version = "0.0.0" }

# local crates that aren't published to crates.io. These should not have versions.
proc-macro-test = { path = "./crates/proc-macro-test" }
sourcegen = { path = "./crates/sourcegen" }
test-fixture = { path = "./crates/test-fixture" }
test-utils = { path = "./crates/test-utils" }

# In-tree crates that are published separately and follow semver. See lib/README.md
line-index = { version = "0.1.1" }
Expand All @@ -94,8 +95,11 @@ lsp-server = { version = "0.7.4" }
anyhow = "1.0.75"
bitflags = "2.4.1"
cargo_metadata = "0.18.1"
command-group = "2.0.1"
crossbeam-channel = "0.5.8"
dissimilar = "1.0.7"
either = "1.9.0"
expect-test = "1.4.0"
hashbrown = { version = "0.14", features = [
"inline-more",
], default-features = false }
Expand Down Expand Up @@ -125,5 +129,6 @@ tracing-subscriber = { version = "0.3.18", default-features = false, features =
triomphe = { version = "0.1.10", default-features = false, features = ["std"] }
xshell = "0.2.5"


# We need to freeze the version of the crate, as the raw-api feature is considered unstable
dashmap = { version = "=5.5.3", features = ["raw-api"] }
1 change: 0 additions & 1 deletion crates/base-db/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,5 @@ cfg.workspace = true
profile.workspace = true
stdx.workspace = true
syntax.workspace = true
test-utils.workspace = true
vfs.workspace = true
span.workspace = true
2 changes: 1 addition & 1 deletion crates/cfg/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ rust-version.workspace = true
doctest = false

[dependencies]
rustc-hash = "1.1.0"
rustc-hash.workspace = true

# locals deps
tt.workspace = true
Expand Down
6 changes: 3 additions & 3 deletions crates/flycheck/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ doctest = false

[dependencies]
cargo_metadata.workspace = true
crossbeam-channel = "0.5.8"
crossbeam-channel.workspace = true
tracing.workspace = true
rustc-hash = "1.1.0"
rustc-hash.workspace = true
serde_json.workspace = true
serde.workspace = true
command-group = "2.0.1"
command-group.workspace = true

# local deps
paths.workspace = true
Expand Down
5 changes: 3 additions & 2 deletions crates/hir-def/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ indexmap.workspace = true
itertools.workspace = true
la-arena.workspace = true
once_cell = "1.17.0"
rustc-hash = "1.1.0"
rustc-hash.workspace = true
tracing.workspace = true
smallvec.workspace = true
hashbrown.workspace = true
Expand All @@ -46,10 +46,11 @@ span.workspace = true


[dev-dependencies]
expect-test = "1.4.0"
expect-test.workspace = true

# local deps
test-utils.workspace = true
test-fixture.workspace = true

[features]
in-rust-tree = ["rustc-dependencies/in-rust-tree"]
3 changes: 2 additions & 1 deletion crates/hir-def/src/body/scope.rs
Original file line number Diff line number Diff line change
Expand Up @@ -268,8 +268,9 @@ fn compute_expr_scopes(expr: ExprId, body: &Body, scopes: &mut ExprScopes, scope
#[cfg(test)]
mod tests {
use base_db::{FileId, SourceDatabase};
use hir_expand::{fixture::WithFixture, name::AsName, InFile};
use hir_expand::{name::AsName, InFile};
use syntax::{algo::find_node_at_offset, ast, AstNode};
use test_fixture::WithFixture;
use test_utils::{assert_eq_text, extract_offset};

use crate::{db::DefDatabase, test_db::TestDB, FunctionId, ModuleDefId};
Expand Down
2 changes: 1 addition & 1 deletion crates/hir-def/src/body/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ mod block;

use base_db::SourceDatabase;
use expect_test::{expect, Expect};
use hir_expand::fixture::WithFixture;
use test_fixture::WithFixture;

use crate::{test_db::TestDB, ModuleDefId};

Expand Down
3 changes: 2 additions & 1 deletion crates/hir-def/src/find_path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -585,8 +585,9 @@ fn find_local_import_locations(

#[cfg(test)]
mod tests {
use hir_expand::{db::ExpandDatabase, fixture::WithFixture};
use hir_expand::db::ExpandDatabase;
use syntax::ast::AstNode;
use test_fixture::WithFixture;

use crate::test_db::TestDB;

Expand Down
2 changes: 1 addition & 1 deletion crates/hir-def/src/import_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ pub fn search_dependencies(
mod tests {
use base_db::{SourceDatabase, Upcast};
use expect_test::{expect, Expect};
use hir_expand::fixture::WithFixture;
use test_fixture::WithFixture;

use crate::{db::DefDatabase, test_db::TestDB, ItemContainerId, Lookup};

Expand Down
2 changes: 1 addition & 1 deletion crates/hir-def/src/item_tree/tests.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use expect_test::{expect, Expect};
use hir_expand::fixture::WithFixture;
use test_fixture::WithFixture;

use crate::{db::DefDatabase, test_db::TestDB};

Expand Down
2 changes: 1 addition & 1 deletion crates/hir-def/src/macro_expansion_tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ use base_db::SourceDatabase;
use expect_test::Expect;
use hir_expand::{
db::ExpandDatabase,
fixture::WithFixture,
proc_macro::{ProcMacro, ProcMacroExpander, ProcMacroExpansionError, ProcMacroKind},
span_map::SpanMapRef,
InFile, MacroFileId, MacroFileIdExt,
Expand All @@ -33,6 +32,7 @@ use syntax::{
SyntaxKind::{COMMENT, EOF, IDENT, LIFETIME_IDENT},
SyntaxNode, T,
};
use test_fixture::WithFixture;

use crate::{
db::DefDatabase,
Expand Down
2 changes: 1 addition & 1 deletion crates/hir-def/src/nameres/collector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2370,7 +2370,7 @@ impl ModCollector<'_, '_> {
#[cfg(test)]
mod tests {
use base_db::SourceDatabase;
use hir_expand::fixture::WithFixture;
use test_fixture::WithFixture;

use crate::{db::DefDatabase, test_db::TestDB};

Expand Down
2 changes: 1 addition & 1 deletion crates/hir-def/src/nameres/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ mod primitives;

use base_db::SourceDatabase;
use expect_test::{expect, Expect};
use hir_expand::fixture::WithFixture;
use test_fixture::WithFixture;
use triomphe::Arc;

use crate::{db::DefDatabase, nameres::DefMap, test_db::TestDB};
Expand Down
7 changes: 2 additions & 5 deletions crates/hir-def/src/nameres/tests/incremental.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
use base_db::{SourceDatabase, SourceDatabaseExt};
use test_fixture::WithFixture;
use triomphe::Arc;

use crate::{
db::DefDatabase,
nameres::tests::{TestDB, WithFixture},
AdtId, ModuleDefId,
};
use crate::{db::DefDatabase, nameres::tests::TestDB, AdtId, ModuleDefId};

fn check_def_map_is_not_recomputed(ra_fixture_initial: &str, ra_fixture_change: &str) {
let (mut db, pos) = TestDB::with_position(ra_fixture_initial);
Expand Down
8 changes: 7 additions & 1 deletion crates/hir-def/src/nameres/tests/macros.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
use super::*;
use expect_test::expect;
use test_fixture::WithFixture;

use itertools::Itertools;

use crate::nameres::tests::check;

use super::*;

#[test]
fn macro_rules_are_globally_visible() {
check(
Expand Down
3 changes: 1 addition & 2 deletions crates/hir-expand/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ doctest = false
cov-mark = "2.0.0-pre.1"
tracing.workspace = true
either.workspace = true
rustc-hash = "1.1.0"
rustc-hash.workspace = true
la-arena.workspace = true
itertools.workspace = true
hashbrown.workspace = true
Expand All @@ -33,7 +33,6 @@ tt.workspace = true
mbe.workspace = true
limit.workspace = true
span.workspace = true
test-utils.workspace = true

[dev-dependencies]
expect-test = "1.4.0"
42 changes: 42 additions & 0 deletions crates/hir-expand/src/change.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
//! Defines a unit of change that can applied to the database to get the next
//! state. Changes are transactional.
use base_db::{salsa::Durability, CrateGraph, FileChange, SourceDatabaseExt, SourceRoot};
use span::FileId;
use triomphe::Arc;

use crate::{db::ExpandDatabase, proc_macro::ProcMacros};

#[derive(Debug, Default)]
pub struct Change {
pub source_change: FileChange,
pub proc_macros: Option<ProcMacros>,
}

impl Change {
pub fn new() -> Self {
Self::default()
}

pub fn apply(self, db: &mut (impl ExpandDatabase + SourceDatabaseExt)) {
self.source_change.apply(db);
if let Some(proc_macros) = self.proc_macros {
db.set_proc_macros_with_durability(Arc::new(proc_macros), Durability::HIGH);
}
}

pub fn change_file(&mut self, file_id: FileId, new_text: Option<Arc<str>>) {
self.source_change.change_file(file_id, new_text)
}

pub fn set_crate_graph(&mut self, graph: CrateGraph) {
self.source_change.set_crate_graph(graph)
}

pub fn set_proc_macros(&mut self, proc_macros: ProcMacros) {
self.proc_macros = Some(proc_macros);
}

pub fn set_roots(&mut self, roots: Vec<SourceRoot>) {
self.source_change.set_roots(roots)
}
}
2 changes: 1 addition & 1 deletion crates/hir-expand/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ pub mod builtin_fn_macro;
pub mod db;
pub mod eager;
pub mod files;
pub mod fixture;
pub mod change;
pub mod hygiene;
pub mod mod_path;
pub mod name;
Expand Down
3 changes: 2 additions & 1 deletion crates/hir-ty/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ ena = "0.14.0"
either.workspace = true
oorandom = "11.1.3"
tracing.workspace = true
rustc-hash = "1.1.0"
rustc-hash.workspace = true
scoped-tls = "1.0.0"
chalk-solve = { version = "0.95.0", default-features = false }
chalk-ir = "0.95.0"
Expand Down Expand Up @@ -54,6 +54,7 @@ project-model = { path = "../project-model" }

# local deps
test-utils.workspace = true
test-fixture.workspace = true

[features]
in-rust-tree = ["rustc-dependencies/in-rust-tree"]

0 comments on commit ae2c322

Please sign in to comment.