Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit ae2c322

Browse files
committed
Auto merge of rust-lang#16150 - Veykril:text-fixture, r=Veykril
internal: Move out `WithFixture` into dev-dep only crate
2 parents 5daf090 + f49a2fe commit ae2c322

File tree

59 files changed

+189
-119
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+189
-119
lines changed

Cargo.lock

Lines changed: 23 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,9 @@ proc-macro-srv = { path = "./crates/proc-macro-srv", version = "0.0.0" }
7070
proc-macro-srv-cli = { path = "./crates/proc-macro-srv-cli", version = "0.0.0" }
7171
profile = { path = "./crates/profile", version = "0.0.0" }
7272
project-model = { path = "./crates/project-model", version = "0.0.0" }
73-
sourcegen = { path = "./crates/sourcegen", version = "0.0.0" }
7473
span = { path = "./crates/span", version = "0.0.0" }
7574
stdx = { path = "./crates/stdx", version = "0.0.0" }
7675
syntax = { path = "./crates/syntax", version = "0.0.0" }
77-
test-utils = { path = "./crates/test-utils", version = "0.0.0" }
7876
text-edit = { path = "./crates/text-edit", version = "0.0.0" }
7977
toolchain = { path = "./crates/toolchain", version = "0.0.0" }
8078
tt = { path = "./crates/tt", version = "0.0.0" }
@@ -84,6 +82,9 @@ rustc-dependencies = { path = "./crates/rustc-dependencies", version = "0.0.0" }
8482

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

8889
# In-tree crates that are published separately and follow semver. See lib/README.md
8990
line-index = { version = "0.1.1" }
@@ -94,8 +95,11 @@ lsp-server = { version = "0.7.4" }
9495
anyhow = "1.0.75"
9596
bitflags = "2.4.1"
9697
cargo_metadata = "0.18.1"
98+
command-group = "2.0.1"
99+
crossbeam-channel = "0.5.8"
97100
dissimilar = "1.0.7"
98101
either = "1.9.0"
102+
expect-test = "1.4.0"
99103
hashbrown = { version = "0.14", features = [
100104
"inline-more",
101105
], default-features = false }
@@ -125,5 +129,6 @@ tracing-subscriber = { version = "0.3.18", default-features = false, features =
125129
triomphe = { version = "0.1.10", default-features = false, features = ["std"] }
126130
xshell = "0.2.5"
127131

132+
128133
# We need to freeze the version of the crate, as the raw-api feature is considered unstable
129134
dashmap = { version = "=5.5.3", features = ["raw-api"] }

crates/base-db/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,5 @@ cfg.workspace = true
2222
profile.workspace = true
2323
stdx.workspace = true
2424
syntax.workspace = true
25-
test-utils.workspace = true
2625
vfs.workspace = true
2726
span.workspace = true

crates/cfg/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ rust-version.workspace = true
1212
doctest = false
1313

1414
[dependencies]
15-
rustc-hash = "1.1.0"
15+
rustc-hash.workspace = true
1616

1717
# locals deps
1818
tt.workspace = true

crates/flycheck/Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ doctest = false
1313

1414
[dependencies]
1515
cargo_metadata.workspace = true
16-
crossbeam-channel = "0.5.8"
16+
crossbeam-channel.workspace = true
1717
tracing.workspace = true
18-
rustc-hash = "1.1.0"
18+
rustc-hash.workspace = true
1919
serde_json.workspace = true
2020
serde.workspace = true
21-
command-group = "2.0.1"
21+
command-group.workspace = true
2222

2323
# local deps
2424
paths.workspace = true

crates/hir-def/Cargo.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ indexmap.workspace = true
2323
itertools.workspace = true
2424
la-arena.workspace = true
2525
once_cell = "1.17.0"
26-
rustc-hash = "1.1.0"
26+
rustc-hash.workspace = true
2727
tracing.workspace = true
2828
smallvec.workspace = true
2929
hashbrown.workspace = true
@@ -46,10 +46,11 @@ span.workspace = true
4646

4747

4848
[dev-dependencies]
49-
expect-test = "1.4.0"
49+
expect-test.workspace = true
5050

5151
# local deps
5252
test-utils.workspace = true
53+
test-fixture.workspace = true
5354

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

crates/hir-def/src/body/scope.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,8 +268,9 @@ fn compute_expr_scopes(expr: ExprId, body: &Body, scopes: &mut ExprScopes, scope
268268
#[cfg(test)]
269269
mod tests {
270270
use base_db::{FileId, SourceDatabase};
271-
use hir_expand::{fixture::WithFixture, name::AsName, InFile};
271+
use hir_expand::{name::AsName, InFile};
272272
use syntax::{algo::find_node_at_offset, ast, AstNode};
273+
use test_fixture::WithFixture;
273274
use test_utils::{assert_eq_text, extract_offset};
274275

275276
use crate::{db::DefDatabase, test_db::TestDB, FunctionId, ModuleDefId};

crates/hir-def/src/body/tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ mod block;
22

33
use base_db::SourceDatabase;
44
use expect_test::{expect, Expect};
5-
use hir_expand::fixture::WithFixture;
5+
use test_fixture::WithFixture;
66

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

crates/hir-def/src/find_path.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -585,8 +585,9 @@ fn find_local_import_locations(
585585

586586
#[cfg(test)]
587587
mod tests {
588-
use hir_expand::{db::ExpandDatabase, fixture::WithFixture};
588+
use hir_expand::db::ExpandDatabase;
589589
use syntax::ast::AstNode;
590+
use test_fixture::WithFixture;
590591

591592
use crate::test_db::TestDB;
592593

crates/hir-def/src/import_map.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@ pub fn search_dependencies(
475475
mod tests {
476476
use base_db::{SourceDatabase, Upcast};
477477
use expect_test::{expect, Expect};
478-
use hir_expand::fixture::WithFixture;
478+
use test_fixture::WithFixture;
479479

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

crates/hir-def/src/item_tree/tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use expect_test::{expect, Expect};
2-
use hir_expand::fixture::WithFixture;
2+
use test_fixture::WithFixture;
33

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

crates/hir-def/src/macro_expansion_tests/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ use base_db::SourceDatabase;
2020
use expect_test::Expect;
2121
use hir_expand::{
2222
db::ExpandDatabase,
23-
fixture::WithFixture,
2423
proc_macro::{ProcMacro, ProcMacroExpander, ProcMacroExpansionError, ProcMacroKind},
2524
span_map::SpanMapRef,
2625
InFile, MacroFileId, MacroFileIdExt,
@@ -33,6 +32,7 @@ use syntax::{
3332
SyntaxKind::{COMMENT, EOF, IDENT, LIFETIME_IDENT},
3433
SyntaxNode, T,
3534
};
35+
use test_fixture::WithFixture;
3636

3737
use crate::{
3838
db::DefDatabase,

crates/hir-def/src/nameres/collector.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2370,7 +2370,7 @@ impl ModCollector<'_, '_> {
23702370
#[cfg(test)]
23712371
mod tests {
23722372
use base_db::SourceDatabase;
2373-
use hir_expand::fixture::WithFixture;
2373+
use test_fixture::WithFixture;
23742374

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

crates/hir-def/src/nameres/tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ mod primitives;
66

77
use base_db::SourceDatabase;
88
use expect_test::{expect, Expect};
9-
use hir_expand::fixture::WithFixture;
9+
use test_fixture::WithFixture;
1010
use triomphe::Arc;
1111

1212
use crate::{db::DefDatabase, nameres::DefMap, test_db::TestDB};

crates/hir-def/src/nameres/tests/incremental.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
use base_db::{SourceDatabase, SourceDatabaseExt};
2+
use test_fixture::WithFixture;
23
use triomphe::Arc;
34

4-
use crate::{
5-
db::DefDatabase,
6-
nameres::tests::{TestDB, WithFixture},
7-
AdtId, ModuleDefId,
8-
};
5+
use crate::{db::DefDatabase, nameres::tests::TestDB, AdtId, ModuleDefId};
96

107
fn check_def_map_is_not_recomputed(ra_fixture_initial: &str, ra_fixture_change: &str) {
118
let (mut db, pos) = TestDB::with_position(ra_fixture_initial);

crates/hir-def/src/nameres/tests/macros.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
1-
use super::*;
1+
use expect_test::expect;
2+
use test_fixture::WithFixture;
3+
24
use itertools::Itertools;
35

6+
use crate::nameres::tests::check;
7+
8+
use super::*;
9+
410
#[test]
511
fn macro_rules_are_globally_visible() {
612
check(

crates/hir-expand/Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ doctest = false
1515
cov-mark = "2.0.0-pre.1"
1616
tracing.workspace = true
1717
either.workspace = true
18-
rustc-hash = "1.1.0"
18+
rustc-hash.workspace = true
1919
la-arena.workspace = true
2020
itertools.workspace = true
2121
hashbrown.workspace = true
@@ -33,7 +33,6 @@ tt.workspace = true
3333
mbe.workspace = true
3434
limit.workspace = true
3535
span.workspace = true
36-
test-utils.workspace = true
3736

3837
[dev-dependencies]
3938
expect-test = "1.4.0"

crates/hir-expand/src/change.rs

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
//! Defines a unit of change that can applied to the database to get the next
2+
//! state. Changes are transactional.
3+
use base_db::{salsa::Durability, CrateGraph, FileChange, SourceDatabaseExt, SourceRoot};
4+
use span::FileId;
5+
use triomphe::Arc;
6+
7+
use crate::{db::ExpandDatabase, proc_macro::ProcMacros};
8+
9+
#[derive(Debug, Default)]
10+
pub struct Change {
11+
pub source_change: FileChange,
12+
pub proc_macros: Option<ProcMacros>,
13+
}
14+
15+
impl Change {
16+
pub fn new() -> Self {
17+
Self::default()
18+
}
19+
20+
pub fn apply(self, db: &mut (impl ExpandDatabase + SourceDatabaseExt)) {
21+
self.source_change.apply(db);
22+
if let Some(proc_macros) = self.proc_macros {
23+
db.set_proc_macros_with_durability(Arc::new(proc_macros), Durability::HIGH);
24+
}
25+
}
26+
27+
pub fn change_file(&mut self, file_id: FileId, new_text: Option<Arc<str>>) {
28+
self.source_change.change_file(file_id, new_text)
29+
}
30+
31+
pub fn set_crate_graph(&mut self, graph: CrateGraph) {
32+
self.source_change.set_crate_graph(graph)
33+
}
34+
35+
pub fn set_proc_macros(&mut self, proc_macros: ProcMacros) {
36+
self.proc_macros = Some(proc_macros);
37+
}
38+
39+
pub fn set_roots(&mut self, roots: Vec<SourceRoot>) {
40+
self.source_change.set_roots(roots)
41+
}
42+
}

crates/hir-expand/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ pub mod builtin_fn_macro;
1414
pub mod db;
1515
pub mod eager;
1616
pub mod files;
17-
pub mod fixture;
17+
pub mod change;
1818
pub mod hygiene;
1919
pub mod mod_path;
2020
pub mod name;

crates/hir-ty/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ ena = "0.14.0"
2121
either.workspace = true
2222
oorandom = "11.1.3"
2323
tracing.workspace = true
24-
rustc-hash = "1.1.0"
24+
rustc-hash.workspace = true
2525
scoped-tls = "1.0.0"
2626
chalk-solve = { version = "0.95.0", default-features = false }
2727
chalk-ir = "0.95.0"
@@ -54,6 +54,7 @@ project-model = { path = "../project-model" }
5454

5555
# local deps
5656
test-utils.workspace = true
57+
test-fixture.workspace = true
5758

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

0 commit comments

Comments
 (0)