Skip to content

Commit 65162bc

Browse files
committed
Merge branch 'master' into fixpoint
* master: chore: release v0.19.0 (salsa-rs#698) Have salsa not depend on salsa-macros (salsa-rs#750) chore: Group versions of packages together for releases (salsa-rs#751)
2 parents 5f59410 + 9ebc8a3 commit 65162bc

File tree

11 files changed

+172
-43
lines changed

11 files changed

+172
-43
lines changed

CHANGELOG.md

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7+
8+
## [Unreleased]
9+
10+
## [0.19.0](https://github.com/salsa-rs/salsa/compare/salsa-v0.18.0...salsa-v0.19.0) - 2025-03-10
11+
12+
### Fixed
13+
14+
- fix typo
15+
- fix enums bug
16+
17+
### Other
18+
19+
- Have salsa not depend on salsa-macros ([#750](https://github.com/salsa-rs/salsa/pull/750))
20+
- Group versions of packages together for releases ([#751](https://github.com/salsa-rs/salsa/pull/751))
21+
- use `portable-atomic` in `IngredientCache` to compile on `powerpc-unknown-linux-gnu` ([#749](https://github.com/salsa-rs/salsa/pull/749))
22+
- Store view downcaster in function ingredients directly ([#720](https://github.com/salsa-rs/salsa/pull/720))
23+
- Some small perf things ([#744](https://github.com/salsa-rs/salsa/pull/744))
24+
- :replace instead of std::mem::replace ([#746](https://github.com/salsa-rs/salsa/pull/746))
25+
- Cleanup `Cargo.toml`s ([#745](https://github.com/salsa-rs/salsa/pull/745))
26+
- Drop clone requirement for accumulated values
27+
- implement `Update` trait for `IndexMap`, and `IndexSet`
28+
- more correct bounds on `Send` and `Sync` implementation `DeletedEntries`
29+
- replace `arc-swap` with manual `AtomicPtr`
30+
- Remove unnecessary `current_revision` call from `setup_interned_struct`
31+
- Merge pull request #731 from Veykril/veykril/push-nzkwqzxxkxou
32+
- Remove some dynamically dispatched `Database::event` calls
33+
- Lazy fetching
34+
- Add small supertype input benchmark
35+
- Replace a `DashMap` with `RwLock` as writing is rare for it
36+
- address review comments
37+
- Skip memo ingredient index mapping for non enum tracked functions
38+
- Trade off a bit of memory for more speed in `MemoIngredientIndices`
39+
- Introduce Salsa enums
40+
- Cancel duplicate test workflow runs
41+
- implement `Update` trait for `hashbrown::HashMap`
42+
- Move `unwind_if_revision_cancelled` from `ZalsaLocal` to `Zalsa`
43+
- Don't clone strings in benchmarks
44+
- Merge pull request #714 from Veykril/veykril/push-synxntlkqqsq
45+
- Merge pull request #711 from Veykril/veykril/push-stmmwmtprovt
46+
- Merge pull request #715 from Veykril/veykril/push-plwpsqknwulq
47+
- Enforce `unsafe_op_in_unsafe_fn`
48+
- Remove some `ZalsaDatabase::zalsa` calls
49+
- Remove outdated FIXME
50+
- Replace `IngredientCache` lock with atomic primitive
51+
- Reduce method delegation duplication
52+
- Automatically clear the cancellation flag when cancellation completes
53+
- Allow trigger LRU eviction without increasing the current revision
54+
- Simplify `Ingredient::reset_for_new_revision` setup
55+
- Require mut Zalsa access for setting the lru limit
56+
- Split off revision bumping from `zalsa_mut` access
57+
- Update `hashbrown` (0.15) and `hashlink` (0.10)

Cargo.toml

+13-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "salsa"
3-
version = "0.18.0"
3+
version = "0.19.0"
44
authors.workspace = true
55
edition.workspace = true
66
license.workspace = true
@@ -9,8 +9,8 @@ rust-version.workspace = true
99
description = "A generic framework for on-demand, incrementalized computation (experimental)"
1010

1111
[dependencies]
12-
salsa-macro-rules = { version = "0.18.0", path = "components/salsa-macro-rules" }
13-
salsa-macros = { version = "0.18.0", path = "components/salsa-macros" }
12+
salsa-macro-rules = { version = "0.19.0", path = "components/salsa-macro-rules" }
13+
salsa-macros = { version = "0.19.0", path = "components/salsa-macros", optional = true }
1414

1515
boxcar = "0.2.9"
1616
crossbeam-queue = "0.3.11"
@@ -22,7 +22,7 @@ parking_lot = "0.12"
2222
portable-atomic = "1"
2323
rustc-hash = "2"
2424
smallvec = "1"
25-
tracing = "0.1"
25+
tracing = { version = "0.1", default-features = false, features = ["std"] }
2626

2727
# parallel map
2828
rayon = { version = "1.10.0", optional = true }
@@ -31,9 +31,17 @@ rayon = { version = "1.10.0", optional = true }
3131
compact_str = { version = "0.8", optional = true }
3232

3333
[features]
34-
default = ["salsa_unstable", "rayon"]
34+
default = ["salsa_unstable", "rayon", "macros"]
3535
# FIXME: remove `salsa_unstable` before 1.0.
3636
salsa_unstable = []
37+
macros = ["dep:salsa-macros"]
38+
39+
# This interlocks the `salsa-macros` and `salsa` versions together
40+
# preventing scenarios where they could diverge in a given project
41+
# which may ultimately result in odd issues due to the proc-macro
42+
# output mismatching with the declarative macro inputs
43+
[target.'cfg(any())'.dependencies]
44+
salsa-macros = { version = "=0.19.0", path = "components/salsa-macros" }
3745

3846
[dev-dependencies]
3947
# examples
+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7+
8+
## [Unreleased]
9+
10+
## [0.19.0](https://github.com/salsa-rs/salsa/compare/salsa-macro-rules-v0.18.0...salsa-macro-rules-v0.19.0) - 2025-03-10
11+
12+
### Other
13+
14+
- Store view downcaster in function ingredients directly ([#720](https://github.com/salsa-rs/salsa/pull/720))

components/salsa-macro-rules/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "salsa-macro-rules"
3-
version = "0.18.0"
3+
version = "0.19.0"
44
authors.workspace = true
55
edition.workspace = true
66
license.workspace = true

components/salsa-macros/CHANGELOG.md

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7+
8+
## [Unreleased]
9+
10+
## [0.19.0](https://github.com/salsa-rs/salsa/compare/salsa-macros-v0.18.0...salsa-macros-v0.19.0) - 2025-03-10
11+
12+
### Fixed
13+
14+
- fix enums bug
15+
16+
### Other
17+
18+
- Store view downcaster in function ingredients directly ([#720](https://github.com/salsa-rs/salsa/pull/720))
19+
- :replace instead of std::mem::replace ([#746](https://github.com/salsa-rs/salsa/pull/746))
20+
- Cleanup `Cargo.toml`s ([#745](https://github.com/salsa-rs/salsa/pull/745))
21+
- address review comments
22+
- Skip memo ingredient index mapping for non enum tracked functions
23+
- Trade off a bit of memory for more speed in `MemoIngredientIndices`
24+
- Introduce Salsa enums
25+
- Track revisions for tracked fields only

components/salsa-macros/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "salsa-macros"
3-
version = "0.18.0"
3+
version = "0.19.0"
44
authors.workspace = true
55
edition.workspace = true
66
license.workspace = true

release-plz.toml

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
[[package]]
2+
name = "salsa"
3+
version_group = "salsa"
4+
5+
[[package]]
6+
name = "salsa-macros"
7+
version_group = "salsa"
8+
9+
[[package]]
10+
name = "salsa-macro-rules"
11+
version_group = "salsa"

src/database.rs

+15-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ use crate::{
77

88
/// The trait implemented by all Salsa databases.
99
/// You can create your own subtraits of this trait using the `#[salsa::db]`(`crate::db`) procedural macro.
10-
#[crate::db]
1110
pub trait Database: Send + AsDynDatabase + Any + ZalsaDatabase {
1211
/// This function is invoked by the salsa runtime at various points during execution.
1312
/// You can customize what happens by implementing the [`UserData`][] trait.
@@ -89,6 +88,21 @@ pub trait Database: Send + AsDynDatabase + Any + ZalsaDatabase {
8988
{
9089
crate::attach::attach(self, || op(self))
9190
}
91+
92+
#[doc(hidden)]
93+
fn zalsa_register_downcaster(&self) {
94+
// The no-op downcaster is special cased in view caster construction.
95+
}
96+
97+
#[doc(hidden)]
98+
#[inline(always)]
99+
unsafe fn downcast(db: &dyn Database) -> &dyn Database
100+
where
101+
Self: Sized,
102+
{
103+
// No-op
104+
db
105+
}
92106
}
93107

94108
/// Upcast to a `dyn Database`.

src/database_impl.rs

+15-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
use crate::{self as salsa, Database, Event, Storage};
1+
use crate::{storage::HasStorage, Database, Event, Storage};
22

3-
#[salsa::db]
43
/// Default database implementation that you can use if you don't
54
/// require any custom user data.
65
#[derive(Default, Clone)]
@@ -19,10 +18,23 @@ impl DatabaseImpl {
1918
}
2019
}
2120

22-
#[salsa::db]
2321
impl Database for DatabaseImpl {
2422
/// Default behavior: tracing debug log the event.
2523
fn salsa_event(&self, event: &dyn Fn() -> Event) {
2624
tracing::debug!("salsa_event({:?})", event());
2725
}
2826
}
27+
28+
// # Safety
29+
//
30+
// The `storage` and `storage_mut` fields return a reference to the same
31+
// storage field owned by `self`.
32+
unsafe impl HasStorage for DatabaseImpl {
33+
fn storage(&self) -> &Storage<Self> {
34+
&self.storage
35+
}
36+
37+
fn storage_mut(&mut self) -> &mut Storage<Self> {
38+
&mut self.storage
39+
}
40+
}

src/lib.rs

+2-9
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
#![forbid(unsafe_op_in_unsafe_fn)]
22

3-
extern crate self as salsa;
4-
53
mod accumulator;
64
mod active_query;
75
mod array;
@@ -54,13 +52,8 @@ pub use self::zalsa::IngredientIndex;
5452
pub use crate::attach::with_attached_database;
5553
#[cfg(feature = "rayon")]
5654
pub use par_map::par_map;
57-
pub use salsa_macros::accumulator;
58-
pub use salsa_macros::db;
59-
pub use salsa_macros::input;
60-
pub use salsa_macros::interned;
61-
pub use salsa_macros::tracked;
62-
pub use salsa_macros::Supertype;
63-
pub use salsa_macros::Update;
55+
#[cfg(feature = "macros")]
56+
pub use salsa_macros::{accumulator, db, input, interned, tracked, Supertype, Update};
6457

6558
pub mod prelude {
6659
pub use crate::Accumulator;

src/views.rs

+18-23
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,22 @@ struct ViewCaster {
2424
cast: ErasedDatabaseDownCasterSig,
2525
}
2626

27+
impl ViewCaster {
28+
fn new<DbView: ?Sized + Any>(func: unsafe fn(&dyn Database) -> &DbView) -> ViewCaster {
29+
ViewCaster {
30+
target_type_id: TypeId::of::<DbView>(),
31+
type_name: std::any::type_name::<DbView>(),
32+
// SAFETY: We are type erasing for storage, taking care of unerasing before we call
33+
// the function pointer.
34+
cast: unsafe {
35+
std::mem::transmute::<DatabaseDownCasterSig<DbView>, ErasedDatabaseDownCasterSig>(
36+
func,
37+
)
38+
},
39+
}
40+
}
41+
}
42+
2743
type ErasedDatabaseDownCasterSig = unsafe fn(&dyn Database) -> *const ();
2844
type DatabaseDownCasterSig<DbView> = unsafe fn(&dyn Database) -> &DbView;
2945

@@ -55,18 +71,7 @@ impl Views {
5571
let source_type_id = TypeId::of::<Db>();
5672
let view_casters = boxcar::Vec::new();
5773
// special case the no-op transformation, that way we skip out on reconstructing the wide pointer
58-
view_casters.push(ViewCaster {
59-
target_type_id: TypeId::of::<dyn Database>(),
60-
type_name: std::any::type_name::<dyn Database>(),
61-
// SAFETY: We are type erasing for storage, taking care of unerasing before we call
62-
// the function pointer.
63-
cast: unsafe {
64-
std::mem::transmute::<
65-
DatabaseDownCasterSig<dyn Database>,
66-
ErasedDatabaseDownCasterSig,
67-
>(|db| db)
68-
},
69-
});
74+
view_casters.push(ViewCaster::new::<dyn Database>(|db| db));
7075
Self {
7176
source_type_id,
7277
view_casters,
@@ -83,17 +88,7 @@ impl Views {
8388
{
8489
return;
8590
}
86-
self.view_casters.push(ViewCaster {
87-
target_type_id,
88-
type_name: std::any::type_name::<DbView>(),
89-
// SAFETY: We are type erasing for storage, taking care of unerasing before we call
90-
// the function pointer.
91-
cast: unsafe {
92-
std::mem::transmute::<DatabaseDownCasterSig<DbView>, ErasedDatabaseDownCasterSig>(
93-
func,
94-
)
95-
},
96-
});
91+
self.view_casters.push(ViewCaster::new::<DbView>(func));
9792
}
9893

9994
/// Retrieve an downcaster function from `dyn Database` to `dyn DbView`.

0 commit comments

Comments
 (0)