Skip to content

Commit 996d6ed

Browse files
committed
Split out salsa_macros
Does not do much yet due to tracing pulling syn but oh well
1 parent 9fa647c commit 996d6ed

File tree

25 files changed

+63
-48
lines changed

25 files changed

+63
-48
lines changed

Cargo.lock

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

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,8 @@ process-wrap = { version = "8.2.0", features = ["std"] }
131131
pulldown-cmark-to-cmark = "10.0.4"
132132
pulldown-cmark = { version = "0.9.6", default-features = false }
133133
rayon = "1.10.0"
134-
salsa = "0.21.0"
134+
salsa = { version = "0.21.0", default-features = false, features = ["rayon","salsa_unstable"] }
135+
salsa-macros = "0.21.0"
135136
semver = "1.0.26"
136137
serde = { version = "1.0.219" }
137138
serde_derive = { version = "1.0.219" }

crates/base-db/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ rust-version.workspace = true
1515
la-arena.workspace = true
1616
dashmap.workspace = true
1717
salsa.workspace = true
18+
salsa-macros.workspace = true
1819
query-group.workspace = true
1920
rustc-hash.workspace = true
2021
triomphe.workspace = true

crates/base-db/src/input.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ impl BuiltDependency {
392392

393393
pub type CratesIdMap = FxHashMap<CrateBuilderId, Crate>;
394394

395-
#[salsa::input]
395+
#[salsa_macros::input]
396396
#[derive(Debug)]
397397
pub struct Crate {
398398
#[return_ref]

crates/base-db/src/lib.rs

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
//! base_db defines basic database traits. The concrete DB is defined by ide.
2+
3+
pub use salsa;
4+
pub use salsa_macros;
5+
26
// FIXME: Rename this crate, base db is non descriptive
37
mod change;
48
mod input;
@@ -17,7 +21,6 @@ pub use crate::{
1721
use dashmap::{DashMap, mapref::entry::Entry};
1822
pub use query_group::{self};
1923
use rustc_hash::{FxHashSet, FxHasher};
20-
pub use salsa::{self};
2124
use salsa::{Durability, Setter};
2225
pub use semver::{BuildMetadata, Prerelease, Version, VersionReq};
2326
use span::Edition;
@@ -28,7 +31,7 @@ pub use vfs::{AnchoredPath, AnchoredPathBuf, FileId, VfsPath, file_set::FileSet}
2831
#[macro_export]
2932
macro_rules! impl_intern_key {
3033
($id:ident, $loc:ident) => {
31-
#[salsa::interned(no_lifetime)]
34+
#[salsa_macros::interned(no_lifetime)]
3235
pub struct $id {
3336
pub loc: $loc,
3437
}
@@ -161,7 +164,7 @@ impl Files {
161164
}
162165
}
163166

164-
#[salsa::interned(no_lifetime, debug, constructor=from_span)]
167+
#[salsa_macros::interned(no_lifetime, debug, constructor=from_span)]
165168
pub struct EditionedFileId {
166169
pub editioned_file_id: span::EditionedFileId,
167170
}
@@ -196,18 +199,18 @@ impl EditionedFileId {
196199
}
197200
}
198201

199-
#[salsa::input(debug)]
202+
#[salsa_macros::input(debug)]
200203
pub struct FileText {
201204
pub text: Arc<str>,
202205
pub file_id: vfs::FileId,
203206
}
204207

205-
#[salsa::input(debug)]
208+
#[salsa_macros::input(debug)]
206209
pub struct FileSourceRootInput {
207210
pub source_root_id: SourceRootId,
208211
}
209212

210-
#[salsa::input(debug)]
213+
#[salsa_macros::input(debug)]
211214
pub struct SourceRootInput {
212215
pub source_root: Arc<SourceRoot>,
213216
}
@@ -274,7 +277,7 @@ pub fn transitive_deps(db: &dyn SourceDatabase, crate_id: Crate) -> FxHashSet<Cr
274277
deps
275278
}
276279

277-
#[salsa::db]
280+
#[salsa_macros::db]
278281
pub trait SourceDatabase: salsa::Database {
279282
/// Text of the file.
280283
fn file_text(&self, file_id: vfs::FileId) -> FileText;
@@ -353,7 +356,7 @@ fn parse(db: &dyn RootQueryDb, file_id: EditionedFileId) -> Parse<ast::SourceFil
353356
}
354357

355358
fn parse_errors(db: &dyn RootQueryDb, file_id: EditionedFileId) -> Option<&[SyntaxError]> {
356-
#[salsa::tracked(return_ref)]
359+
#[salsa_macros::tracked(return_ref)]
357360
fn parse_errors(db: &dyn RootQueryDb, file_id: EditionedFileId) -> Option<Box<[SyntaxError]>> {
358361
let errors = db.parse(file_id).errors();
359362
match &*errors {

crates/hir-def/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ triomphe.workspace = true
2828
rustc_apfloat = "0.2.2"
2929
text-size.workspace = true
3030
salsa.workspace = true
31+
salsa-macros.workspace = true
3132
query-group.workspace = true
3233

3334
ra-ap-rustc_parse_format.workspace = true

crates/hir-def/src/lang_item.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ impl LangItemTarget {
8484
}
8585

8686
/// Salsa query. This will look for lang items in a specific crate.
87-
#[salsa::tracked(return_ref)]
87+
#[salsa_macros::tracked(return_ref)]
8888
pub fn crate_lang_items(db: &dyn DefDatabase, krate: Crate) -> Option<Box<LangItems>> {
8989
let _p = tracing::info_span!("crate_lang_items_query").entered();
9090

@@ -153,7 +153,7 @@ pub fn crate_lang_items(db: &dyn DefDatabase, krate: Crate) -> Option<Box<LangIt
153153

154154
/// Salsa query. Look for a lang item, starting from the specified crate and recursively
155155
/// traversing its dependencies.
156-
#[salsa::tracked]
156+
#[salsa_macros::tracked]
157157
pub fn lang_item(
158158
db: &dyn DefDatabase,
159159
start_crate: Crate,

crates/hir-def/src/lib.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -554,7 +554,7 @@ pub enum ItemContainerId {
554554
impl_from!(ModuleId for ItemContainerId);
555555

556556
/// A Data Type
557-
#[derive(Debug, PartialOrd, Ord, Clone, Copy, PartialEq, Eq, Hash, salsa::Supertype)]
557+
#[derive(Debug, PartialOrd, Ord, Clone, Copy, PartialEq, Eq, Hash, salsa_macros::Supertype)]
558558
pub enum AdtId {
559559
StructId(StructId),
560560
UnionId(UnionId),
@@ -563,7 +563,7 @@ pub enum AdtId {
563563
impl_from!(StructId, UnionId, EnumId for AdtId);
564564

565565
/// A macro
566-
#[derive(Debug, PartialOrd, Ord, Clone, Copy, PartialEq, Eq, Hash, salsa::Supertype)]
566+
#[derive(Debug, PartialOrd, Ord, Clone, Copy, PartialEq, Eq, Hash, salsa_macros::Supertype)]
567567
pub enum MacroId {
568568
Macro2Id(Macro2Id),
569569
MacroRulesId(MacroRulesId),
@@ -619,7 +619,7 @@ impl_from!(
619619

620620
/// A constant, which might appears as a const item, an anonymous const block in expressions
621621
/// or patterns, or as a constant in types with const generics.
622-
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, salsa::Supertype)]
622+
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, salsa_macros::Supertype)]
623623
pub enum GeneralConstId {
624624
ConstId(ConstId),
625625
StaticId(StaticId),
@@ -656,7 +656,7 @@ impl GeneralConstId {
656656
}
657657

658658
/// The defs which have a body (have root expressions for type inference).
659-
#[derive(Debug, PartialOrd, Ord, Clone, Copy, PartialEq, Eq, Hash, salsa::Supertype)]
659+
#[derive(Debug, PartialOrd, Ord, Clone, Copy, PartialEq, Eq, Hash, salsa_macros::Supertype)]
660660
pub enum DefWithBodyId {
661661
FunctionId(FunctionId),
662662
StaticId(StaticId),
@@ -701,7 +701,7 @@ pub enum AssocItemId {
701701
// casting them, and somehow making the constructors private, which would be annoying.
702702
impl_from!(FunctionId, ConstId, TypeAliasId for AssocItemId);
703703

704-
#[derive(Debug, PartialOrd, Ord, Clone, Copy, PartialEq, Eq, Hash, salsa::Supertype)]
704+
#[derive(Debug, PartialOrd, Ord, Clone, Copy, PartialEq, Eq, Hash, salsa_macros::Supertype)]
705705
pub enum GenericDefId {
706706
AdtId(AdtId),
707707
// consts can have type parameters from their parents (i.e. associated consts of traits)
@@ -790,7 +790,7 @@ impl From<AssocItemId> for GenericDefId {
790790
}
791791
}
792792

793-
#[derive(Debug, PartialOrd, Ord, Clone, Copy, PartialEq, Eq, Hash, salsa::Supertype)]
793+
#[derive(Debug, PartialOrd, Ord, Clone, Copy, PartialEq, Eq, Hash, salsa_macros::Supertype)]
794794
pub enum CallableDefId {
795795
FunctionId(FunctionId),
796796
StructId(StructId),
@@ -906,7 +906,7 @@ impl From<VariantId> for AttrDefId {
906906
}
907907
}
908908

909-
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, salsa::Supertype)]
909+
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, salsa_macros::Supertype)]
910910
pub enum VariantId {
911911
EnumVariantId(EnumVariantId),
912912
StructId(StructId),

crates/hir-def/src/test_db.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use crate::{
1919
src::HasSource,
2020
};
2121

22-
#[salsa::db]
22+
#[salsa_macros::db]
2323
#[derive(Clone)]
2424
pub(crate) struct TestDB {
2525
storage: salsa::Storage<Self>,
@@ -44,7 +44,7 @@ impl Default for TestDB {
4444
}
4545
}
4646

47-
#[salsa::db]
47+
#[salsa_macros::db]
4848
impl salsa::Database for TestDB {
4949
fn salsa_event(&self, event: &dyn std::ops::Fn() -> salsa::Event) {
5050
let mut events = self.events.lock().unwrap();
@@ -63,7 +63,7 @@ impl fmt::Debug for TestDB {
6363

6464
impl panic::RefUnwindSafe for TestDB {}
6565

66-
#[salsa::db]
66+
#[salsa_macros::db]
6767
impl SourceDatabase for TestDB {
6868
fn file_text(&self, file_id: base_db::FileId) -> FileText {
6969
self.files.file_text(file_id)

crates/hir-expand/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ smallvec.workspace = true
2121
triomphe.workspace = true
2222
query-group.workspace = true
2323
salsa.workspace = true
24+
salsa-macros.workspace = true
2425

2526
# local deps
2627
stdx.workspace = true

crates/hir-expand/src/change.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
//! Defines a unit of change that can applied to the database to get the next
22
//! state. Changes are transactional.
3-
use base_db::{CrateGraphBuilder, FileChange, SourceRoot};
4-
use salsa::Durability;
3+
use base_db::{CrateGraphBuilder, FileChange, SourceRoot, salsa::Durability};
54
use span::FileId;
65
use triomphe::Arc;
76

crates/hir-expand/src/db.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ pub trait ExpandDatabase: RootQueryDb {
144144
fn syntax_context(&self, file: HirFileId, edition: Edition) -> SyntaxContext;
145145
}
146146

147-
#[salsa::interned(no_lifetime, id = span::SyntaxContext)]
147+
#[salsa_macros::interned(no_lifetime, id = span::SyntaxContext)]
148148
pub struct SyntaxContextWrapper {
149149
pub data: SyntaxContext,
150150
}

crates/hir-expand/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1050,7 +1050,7 @@ impl ExpandTo {
10501050

10511051
intern::impl_internable!(ModPath, attrs::AttrInput);
10521052

1053-
#[salsa::interned(no_lifetime, debug)]
1053+
#[salsa_macros::interned(no_lifetime, debug)]
10541054
#[doc(alias = "MacroFileId")]
10551055
pub struct MacroCallId {
10561056
pub loc: MacroCallLoc,
@@ -1070,7 +1070,7 @@ impl From<MacroCallId> for span::MacroCallId {
10701070
}
10711071
}
10721072

1073-
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, salsa::Supertype)]
1073+
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, salsa_macros::Supertype)]
10741074
pub enum HirFileId {
10751075
FileId(EditionedFileId),
10761076
MacroFile(MacroCallId),

crates/hir-ty/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ indexmap.workspace = true
3434
rustc_apfloat = "0.2.2"
3535
query-group.workspace = true
3636
salsa.workspace = true
37+
salsa-macros.workspace = true
3738

3839
ra-ap-rustc_abi.workspace = true
3940
ra-ap-rustc_index.workspace = true

crates/hir-ty/src/lower.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1468,7 +1468,7 @@ fn type_for_enum_variant_constructor(
14681468
}
14691469
}
14701470

1471-
#[salsa::tracked(cycle_result = type_for_adt_cycle_result)]
1471+
#[salsa_macros::tracked(cycle_result = type_for_adt_cycle_result)]
14721472
fn type_for_adt_tracked(db: &dyn HirDatabase, adt: AdtId) -> Binders<Ty> {
14731473
type_for_adt(db, adt)
14741474
}
@@ -1533,7 +1533,7 @@ pub enum TyDefId {
15331533
}
15341534
impl_from!(BuiltinType, AdtId(StructId, EnumId, UnionId), TypeAliasId for TyDefId);
15351535

1536-
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, salsa::Supertype)]
1536+
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, salsa_macros::Supertype)]
15371537
pub enum ValueTyDefId {
15381538
FunctionId(FunctionId),
15391539
StructId(StructId),

crates/hir-ty/src/test_db.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use syntax::TextRange;
1616
use test_utils::extract_annotations;
1717
use triomphe::Arc;
1818

19-
#[salsa::db]
19+
#[salsa_macros::db]
2020
#[derive(Clone)]
2121
pub(crate) struct TestDB {
2222
storage: salsa::Storage<Self>,
@@ -47,7 +47,7 @@ impl fmt::Debug for TestDB {
4747
}
4848
}
4949

50-
#[salsa::db]
50+
#[salsa_macros::db]
5151
impl SourceDatabase for TestDB {
5252
fn file_text(&self, file_id: base_db::FileId) -> FileText {
5353
self.files.file_text(file_id)
@@ -102,7 +102,7 @@ impl SourceDatabase for TestDB {
102102
}
103103
}
104104

105-
#[salsa::db]
105+
#[salsa_macros::db]
106106
impl salsa::Database for TestDB {
107107
fn salsa_event(&self, event: &dyn std::ops::Fn() -> salsa::Event) {
108108
let mut events = self.events.lock().unwrap();

crates/ide-db/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ arrayvec.workspace = true
2424
indexmap.workspace = true
2525
memchr = "2.7.4"
2626
salsa.workspace = true
27+
salsa-macros.workspace = true
2728
query-group.workspace = true
2829
triomphe.workspace = true
2930
nohash-hasher.workspace = true

crates/ide-db/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ pub type FxIndexMap<K, V> =
7676
pub type FilePosition = FilePositionWrapper<FileId>;
7777
pub type FileRange = FileRangeWrapper<FileId>;
7878

79-
#[salsa::db]
79+
#[salsa_macros::db]
8080
pub struct RootDatabase {
8181
// FIXME: Revisit this commit now that we migrated to the new salsa, given we store arcs in this
8282
// db directly now
@@ -91,7 +91,7 @@ pub struct RootDatabase {
9191

9292
impl std::panic::RefUnwindSafe for RootDatabase {}
9393

94-
#[salsa::db]
94+
#[salsa_macros::db]
9595
impl salsa::Database for RootDatabase {
9696
fn salsa_event(&self, _event: &dyn Fn() -> salsa::Event) {}
9797
}
@@ -118,7 +118,7 @@ impl fmt::Debug for RootDatabase {
118118
}
119119
}
120120

121-
#[salsa::db]
121+
#[salsa_macros::db]
122122
impl SourceDatabase for RootDatabase {
123123
fn file_text(&self, file_id: vfs::FileId) -> FileText {
124124
self.files.file_text(file_id)

0 commit comments

Comments
 (0)