Skip to content

Commit 3f92794

Browse files
committed
Split out salsa_macros
Does not do much yet due to tracing pulling syn but oh well
1 parent 0e139b8 commit 3f92794

File tree

25 files changed

+63
-48
lines changed

25 files changed

+63
-48
lines changed

src/tools/rust-analyzer/Cargo.lock

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ dependencies = [
8585
"query-group-macro",
8686
"rustc-hash 2.1.1",
8787
"salsa",
88+
"salsa-macros",
8889
"semver",
8990
"span",
9091
"syntax",
@@ -630,6 +631,7 @@ dependencies = [
630631
"rustc-hash 2.1.1",
631632
"rustc_apfloat",
632633
"salsa",
634+
"salsa-macros",
633635
"smallvec",
634636
"span",
635637
"stdx",
@@ -660,6 +662,7 @@ dependencies = [
660662
"query-group-macro",
661663
"rustc-hash 2.1.1",
662664
"salsa",
665+
"salsa-macros",
663666
"smallvec",
664667
"span",
665668
"stdx",
@@ -700,6 +703,7 @@ dependencies = [
700703
"rustc-hash 2.1.1",
701704
"rustc_apfloat",
702705
"salsa",
706+
"salsa-macros",
703707
"scoped-tls",
704708
"smallvec",
705709
"span",
@@ -936,6 +940,7 @@ dependencies = [
936940
"rayon",
937941
"rustc-hash 2.1.1",
938942
"salsa",
943+
"salsa-macros",
939944
"span",
940945
"stdx",
941946
"syntax",
@@ -1729,6 +1734,7 @@ dependencies = [
17291734
"proc-macro2",
17301735
"quote",
17311736
"salsa",
1737+
"salsa-macros",
17321738
"syn",
17331739
]
17341740

src/tools/rust-analyzer/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" }

src/tools/rust-analyzer/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

src/tools/rust-analyzer/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]

src/tools/rust-analyzer/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 {

src/tools/rust-analyzer/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

src/tools/rust-analyzer/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,

src/tools/rust-analyzer/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),

src/tools/rust-analyzer/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)

src/tools/rust-analyzer/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

0 commit comments

Comments
 (0)