Skip to content

Commit d2f1787

Browse files
authored
Merge pull request #19853 from Veykril/push-ovpvzkxmpsuk
Bump salsa
2 parents 76ee900 + cbff4ae commit d2f1787

File tree

10 files changed

+83
-280
lines changed

10 files changed

+83
-280
lines changed

Cargo.lock

Lines changed: 18 additions & 223 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 & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -132,11 +132,8 @@ pulldown-cmark-to-cmark = "10.0.4"
132132
pulldown-cmark = { version = "0.9.6", default-features = false }
133133
rayon = "1.10.0"
134134
rowan = "=0.15.15"
135-
salsa = { version = "0.21.1", default-features = false, features = [
136-
"rayon",
137-
"salsa_unstable",
138-
] }
139-
salsa-macros = "0.21.1"
135+
salsa = { version = "0.22.0", default-features = false, features = ["rayon","salsa_unstable"] }
136+
salsa-macros = "0.22.0"
140137
semver = "1.0.26"
141138
serde = { version = "1.0.219" }
142139
serde_derive = { version = "1.0.219" }

crates/base-db/src/input.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -395,21 +395,21 @@ impl BuiltDependency {
395395
pub type CratesIdMap = FxHashMap<CrateBuilderId, Crate>;
396396

397397
#[salsa_macros::input]
398-
#[derive(Debug)]
398+
#[derive(Debug, PartialOrd, Ord)]
399399
pub struct Crate {
400-
#[return_ref]
400+
#[returns(ref)]
401401
pub data: BuiltCrateData,
402402
/// Crate data that is not needed for analysis.
403403
///
404404
/// This is split into a separate field to increase incrementality.
405-
#[return_ref]
405+
#[returns(ref)]
406406
pub extra_data: ExtraCrateData,
407407
// This is in `Arc` because it is shared for all crates in a workspace.
408-
#[return_ref]
408+
#[returns(ref)]
409409
pub workspace_data: Arc<CrateWorkspaceData>,
410-
#[return_ref]
410+
#[returns(ref)]
411411
pub cfg_options: CfgOptions,
412-
#[return_ref]
412+
#[returns(ref)]
413413
pub env: Env,
414414
}
415415

crates/base-db/src/lib.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ pub use vfs::{AnchoredPath, AnchoredPathBuf, FileId, VfsPath, file_set::FileSet}
3232
macro_rules! impl_intern_key {
3333
($id:ident, $loc:ident) => {
3434
#[salsa_macros::interned(no_lifetime)]
35+
#[derive(PartialOrd, Ord)]
3536
pub struct $id {
3637
pub loc: $loc,
3738
}
@@ -165,6 +166,7 @@ impl Files {
165166
}
166167

167168
#[salsa_macros::interned(no_lifetime, debug, constructor=from_span)]
169+
#[derive(PartialOrd, Ord)]
168170
pub struct EditionedFileId {
169171
pub editioned_file_id: span::EditionedFileId,
170172
}
@@ -356,7 +358,7 @@ fn parse(db: &dyn RootQueryDb, file_id: EditionedFileId) -> Parse<ast::SourceFil
356358
}
357359

358360
fn parse_errors(db: &dyn RootQueryDb, file_id: EditionedFileId) -> Option<&[SyntaxError]> {
359-
#[salsa_macros::tracked(return_ref)]
361+
#[salsa_macros::tracked(returns(ref))]
360362
fn parse_errors(db: &dyn RootQueryDb, file_id: EditionedFileId) -> Option<Box<[SyntaxError]>> {
361363
let errors = db.parse(file_id).errors();
362364
match &*errors {

crates/hir-def/src/lang_item.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ impl LangItemTarget {
8585
}
8686

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

crates/hir-def/src/nameres.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -381,15 +381,15 @@ mod __ {
381381
#[salsa_macros::tracked]
382382
pub(crate) struct DefMapPair<'db> {
383383
#[tracked]
384-
#[return_ref]
384+
#[returns(ref)]
385385
pub(crate) def_map: DefMap,
386-
#[return_ref]
386+
#[returns(ref)]
387387
pub(crate) local: LocalDefMap,
388388
}
389389
}
390390
pub(crate) use __::DefMapPair;
391391

392-
#[salsa_macros::tracked(return_ref)]
392+
#[salsa_macros::tracked(returns(ref))]
393393
pub(crate) fn crate_local_def_map(db: &dyn DefDatabase, crate_id: Crate) -> DefMapPair<'_> {
394394
let krate = crate_id.data(db);
395395
let _p = tracing::info_span!(
@@ -420,7 +420,7 @@ pub(crate) fn crate_local_def_map(db: &dyn DefDatabase, crate_id: Crate) -> DefM
420420
DefMapPair::new(db, def_map, local_def_map)
421421
}
422422

423-
#[salsa_macros::tracked(return_ref)]
423+
#[salsa_macros::tracked(returns(ref))]
424424
pub fn block_def_map(db: &dyn DefDatabase, block_id: BlockId) -> DefMap {
425425
let BlockLoc { ast_id, module } = block_id.lookup(db);
426426

crates/hir-def/src/test_db.rs

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,18 @@ pub(crate) struct TestDB {
3030

3131
impl Default for TestDB {
3232
fn default() -> Self {
33+
let events = <Arc<Mutex<Option<Vec<salsa::Event>>>>>::default();
3334
let mut this = Self {
34-
storage: Default::default(),
35-
events: Default::default(),
35+
storage: salsa::Storage::new(Some(Box::new({
36+
let events = events.clone();
37+
move |event| {
38+
let mut events = events.lock().unwrap();
39+
if let Some(events) = &mut *events {
40+
events.push(event);
41+
}
42+
}
43+
}))),
44+
events,
3645
files: Default::default(),
3746
crates_map: Default::default(),
3847
};
@@ -45,15 +54,7 @@ impl Default for TestDB {
4554
}
4655

4756
#[salsa_macros::db]
48-
impl salsa::Database for TestDB {
49-
fn salsa_event(&self, event: &dyn std::ops::Fn() -> salsa::Event) {
50-
let mut events = self.events.lock().unwrap();
51-
if let Some(events) = &mut *events {
52-
let event = event();
53-
events.push(event);
54-
}
55-
}
56-
}
57+
impl salsa::Database for TestDB {}
5758

5859
impl fmt::Debug for TestDB {
5960
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {

crates/hir-ty/src/test_db.rs

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,18 @@ pub(crate) struct TestDB {
2727

2828
impl Default for TestDB {
2929
fn default() -> Self {
30+
let events = <Arc<Mutex<Option<Vec<salsa::Event>>>>>::default();
3031
let mut this = Self {
31-
storage: Default::default(),
32-
events: Default::default(),
32+
storage: salsa::Storage::new(Some(Box::new({
33+
let events = events.clone();
34+
move |event| {
35+
let mut events = events.lock().unwrap();
36+
if let Some(events) = &mut *events {
37+
events.push(event);
38+
}
39+
}
40+
}))),
41+
events,
3342
files: Default::default(),
3443
crates_map: Default::default(),
3544
};
@@ -103,14 +112,7 @@ impl SourceDatabase for TestDB {
103112
}
104113

105114
#[salsa_macros::db]
106-
impl salsa::Database for TestDB {
107-
fn salsa_event(&self, event: &dyn std::ops::Fn() -> salsa::Event) {
108-
let mut events = self.events.lock().unwrap();
109-
if let Some(events) = &mut *events {
110-
events.push(event());
111-
}
112-
}
113-
}
115+
impl salsa::Database for TestDB {}
114116

115117
impl panic::RefUnwindSafe for TestDB {}
116118

crates/ide-db/src/lib.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,7 @@ pub struct RootDatabase {
9292
impl std::panic::RefUnwindSafe for RootDatabase {}
9393

9494
#[salsa_macros::db]
95-
impl salsa::Database for RootDatabase {
96-
fn salsa_event(&self, _event: &dyn Fn() -> salsa::Event) {}
97-
}
95+
impl salsa::Database for RootDatabase {}
9896

9997
impl Drop for RootDatabase {
10098
fn drop(&mut self) {

crates/query-group-macro/tests/logger_db.rs

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,41 @@
11
use std::sync::{Arc, Mutex};
22

33
#[salsa_macros::db]
4-
#[derive(Default, Clone)]
4+
#[derive(Clone)]
55
pub(crate) struct LoggerDb {
66
storage: salsa::Storage<Self>,
77
logger: Logger,
88
}
99

10+
impl Default for LoggerDb {
11+
fn default() -> Self {
12+
let logger = Logger::default();
13+
Self {
14+
storage: salsa::Storage::new(Some(Box::new({
15+
let logger = logger.clone();
16+
move |event| match event.kind {
17+
salsa::EventKind::WillExecute { .. }
18+
| salsa::EventKind::WillCheckCancellation
19+
| salsa::EventKind::DidValidateMemoizedValue { .. }
20+
| salsa::EventKind::WillDiscardStaleOutput { .. }
21+
| salsa::EventKind::DidDiscard { .. } => {
22+
logger.logs.lock().unwrap().push(format!("salsa_event({:?})", event.kind));
23+
}
24+
_ => {}
25+
}
26+
}))),
27+
logger,
28+
}
29+
}
30+
}
31+
1032
#[derive(Default, Clone)]
1133
struct Logger {
1234
logs: Arc<Mutex<Vec<String>>>,
1335
}
1436

1537
#[salsa_macros::db]
16-
impl salsa::Database for LoggerDb {
17-
fn salsa_event(&self, event: &dyn Fn() -> salsa::Event) {
18-
let event = event();
19-
match event.kind {
20-
salsa::EventKind::WillExecute { .. }
21-
| salsa::EventKind::WillCheckCancellation
22-
| salsa::EventKind::DidValidateMemoizedValue { .. }
23-
| salsa::EventKind::WillDiscardStaleOutput { .. }
24-
| salsa::EventKind::DidDiscard { .. } => {
25-
self.push_log(format!("salsa_event({:?})", event.kind));
26-
}
27-
_ => {}
28-
}
29-
}
30-
}
38+
impl salsa::Database for LoggerDb {}
3139

3240
impl LoggerDb {
3341
/// Log an event from inside a tracked function.

0 commit comments

Comments
 (0)