Skip to content

Commit 8c0ec58

Browse files
committed
Address reviews
1 parent bde56cb commit 8c0ec58

File tree

16 files changed

+60
-76
lines changed

16 files changed

+60
-76
lines changed

components/salsa-macro-rules/src/setup_tracked_fn.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,6 @@ macro_rules! setup_tracked_fn {
318318
};
319319

320320
let fn_ingredient = <$zalsa::function::IngredientImpl<$Configuration>>::new(
321-
zalsa,
322321
first_index,
323322
memo_ingredient_indices,
324323
$lru,

components/salsa-macros/src/db.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,9 @@ impl DbMacro {
135135
#[inline(never)]
136136
#[doc(hidden)]
137137
fn zalsa_register_downcaster(&self) -> &salsa::plumbing::DatabaseDownCaster<dyn #TraitPath> {
138-
salsa::plumbing::views(self).add(<Self as #TraitPath>::downcast)
138+
salsa::plumbing::views(self).add::<Self, dyn #TraitPath>(unsafe {
139+
::std::mem::transmute(<Self as #TraitPath>::downcast as fn(_) -> _)
140+
})
139141
}
140142
});
141143
input.items.push(parse_quote! {

src/accumulator.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ impl<A: Accumulator> Ingredient for IngredientImpl<A> {
103103
unsafe fn maybe_changed_after(
104104
&self,
105105
_zalsa: &crate::zalsa::Zalsa,
106-
_db: crate::database::RawDatabasePointer<'_>,
106+
_db: crate::database::RawDatabase<'_>,
107107
_input: Id,
108108
_revision: Revision,
109109
_cycle_heads: &mut CycleHeads,

src/database.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,25 @@ use crate::zalsa::{IngredientIndex, ZalsaDatabase};
66
use crate::{Durability, Revision};
77

88
#[derive(Copy, Clone)]
9-
pub struct RawDatabasePointer<'db> {
9+
pub struct RawDatabase<'db> {
1010
pub(crate) ptr: NonNull<()>,
1111
_marker: std::marker::PhantomData<&'db dyn Database>,
1212
}
1313

14-
impl<'db, Db: Database + ?Sized> From<&'db Db> for RawDatabasePointer<'db> {
14+
impl<'db, Db: Database + ?Sized> From<&'db Db> for RawDatabase<'db> {
1515
#[inline]
1616
fn from(db: &'db Db) -> Self {
17-
RawDatabasePointer {
17+
RawDatabase {
1818
ptr: NonNull::from(db).cast(),
1919
_marker: std::marker::PhantomData,
2020
}
2121
}
2222
}
2323

24-
impl<'db, Db: Database + ?Sized> From<&'db mut Db> for RawDatabasePointer<'db> {
24+
impl<'db, Db: Database + ?Sized> From<&'db mut Db> for RawDatabase<'db> {
2525
#[inline]
2626
fn from(db: &'db mut Db) -> Self {
27-
RawDatabasePointer {
27+
RawDatabase {
2828
ptr: NonNull::from(db).cast(),
2929
_marker: std::marker::PhantomData,
3030
}

src/function.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use crate::accumulator::accumulated_map::{AccumulatedMap, InputAccumulatedValues
1010
use crate::cycle::{
1111
empty_cycle_heads, CycleHeads, CycleRecoveryAction, CycleRecoveryStrategy, ProvisionalStatus,
1212
};
13-
use crate::database::RawDatabasePointer;
13+
use crate::database::RawDatabase;
1414
use crate::function::delete::DeletedEntries;
1515
use crate::function::sync::{ClaimResult, SyncTable};
1616
use crate::ingredient::{Ingredient, WaitForResult};
@@ -130,7 +130,6 @@ pub struct IngredientImpl<C: Configuration> {
130130
///
131131
/// The supplied database must be be the same as the database used to construct the [`Views`]
132132
/// instances that this downcaster was derived from.
133-
/// instances that this downcaster was derived from.
134133
view_caster: OnceLock<DatabaseDownCaster<C::DbView>>,
135134

136135
sync_table: SyncTable,
@@ -155,7 +154,6 @@ where
155154
C: Configuration,
156155
{
157156
pub fn new(
158-
_zalsa: &Zalsa,
159157
index: IngredientIndex,
160158
memo_ingredient_indices: <C::SalsaStruct<'static> as SalsaStructInDb>::MemoIngredientMap,
161159
lru: usize,
@@ -173,7 +171,10 @@ where
173171
/// Set the view-caster for this tracked function ingredient, if it has
174172
/// not already been initialized.
175173
#[inline]
176-
pub fn get_or_init(&self, view_caster: impl FnOnce() -> DatabaseDownCaster<C::DbView>) -> &Self {
174+
pub fn get_or_init(
175+
&self,
176+
view_caster: impl FnOnce() -> DatabaseDownCaster<C::DbView>,
177+
) -> &Self {
177178
// Note that we must set this lazily as we don't have access to the database
178179
// type when ingredients are registered into the `Zalsa`.
179180
self.view_caster.get_or_init(view_caster);
@@ -261,7 +262,7 @@ where
261262
unsafe fn maybe_changed_after(
262263
&self,
263264
_zalsa: &crate::zalsa::Zalsa,
264-
db: RawDatabasePointer<'_>,
265+
db: RawDatabase<'_>,
265266
input: Id,
266267
revision: Revision,
267268
cycle_heads: &mut CycleHeads,
@@ -372,7 +373,7 @@ where
372373

373374
unsafe fn accumulated<'db>(
374375
&'db self,
375-
db: RawDatabasePointer<'db>,
376+
db: RawDatabase<'db>,
376377
key_index: Id,
377378
) -> (Option<&'db AccumulatedMap>, InputAccumulatedValues) {
378379
// SAFETY: The `db` belongs to the ingredient as per caller invariant

src/ingredient.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use crate::accumulator::accumulated_map::{AccumulatedMap, InputAccumulatedValues
55
use crate::cycle::{
66
empty_cycle_heads, CycleHeads, CycleRecoveryStrategy, IterationCount, ProvisionalStatus,
77
};
8-
use crate::database::RawDatabasePointer;
8+
use crate::database::RawDatabase;
99
use crate::function::VerifyResult;
1010
use crate::runtime::Running;
1111
use crate::sync::Arc;
@@ -49,7 +49,7 @@ pub trait Ingredient: Any + std::fmt::Debug + Send + Sync {
4949
unsafe fn maybe_changed_after(
5050
&self,
5151
zalsa: &crate::zalsa::Zalsa,
52-
db: crate::database::RawDatabasePointer<'_>,
52+
db: crate::database::RawDatabase<'_>,
5353
input: Id,
5454
revision: Revision,
5555
cycle_heads: &mut CycleHeads,
@@ -167,7 +167,7 @@ pub trait Ingredient: Any + std::fmt::Debug + Send + Sync {
167167
/// The passed in database needs to be the same one that the ingredient was created with.
168168
unsafe fn accumulated<'db>(
169169
&'db self,
170-
db: RawDatabasePointer<'db>,
170+
db: RawDatabase<'db>,
171171
key_index: Id,
172172
) -> (Option<&'db AccumulatedMap>, InputAccumulatedValues) {
173173
let _ = (db, key_index);

src/input.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ impl<C: Configuration> Ingredient for IngredientImpl<C> {
221221
unsafe fn maybe_changed_after(
222222
&self,
223223
_zalsa: &crate::zalsa::Zalsa,
224-
_db: crate::database::RawDatabasePointer<'_>,
224+
_db: crate::database::RawDatabase<'_>,
225225
_input: Id,
226226
_revision: Revision,
227227
_cycle_heads: &mut CycleHeads,

src/input/input_field.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ where
5353
unsafe fn maybe_changed_after(
5454
&self,
5555
zalsa: &crate::zalsa::Zalsa,
56-
_db: crate::database::RawDatabasePointer<'_>,
56+
_db: crate::database::RawDatabase<'_>,
5757
input: Id,
5858
revision: Revision,
5959
_cycle_heads: &mut CycleHeads,

src/interned.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -795,7 +795,7 @@ where
795795
unsafe fn maybe_changed_after(
796796
&self,
797797
zalsa: &crate::zalsa::Zalsa,
798-
_db: crate::database::RawDatabasePointer<'_>,
798+
_db: crate::database::RawDatabase<'_>,
799799
input: Id,
800800
_revision: Revision,
801801
_cycle_heads: &mut CycleHeads,

src/key.rs

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -36,27 +36,18 @@ impl DatabaseKeyIndex {
3636

3737
pub(crate) fn maybe_changed_after(
3838
&self,
39-
db: crate::database::RawDatabasePointer<'_>,
39+
db: crate::database::RawDatabase<'_>,
4040
zalsa: &Zalsa,
4141
last_verified_at: crate::Revision,
4242
cycle_heads: &mut CycleHeads,
4343
) -> VerifyResult {
4444
// SAFETY: The `db` belongs to the ingredient
4545
unsafe {
46-
// heer, `db` has to be either the correct type already, or a subtype (as far as trait
46+
// here, `db` has to be either the correct type already, or a subtype (as far as trait
4747
// hierarchy is concerned)
4848
zalsa
4949
.lookup_ingredient(self.ingredient_index())
50-
.maybe_changed_after(
51-
zalsa,
52-
// lets say we do turn this into an opaque pair of data and vtable pointer
53-
// then we also need an downcast function, from our dbview to the ingredients
54-
// dbview
55-
db,
56-
self.key_index(),
57-
last_verified_at,
58-
cycle_heads,
59-
)
50+
.maybe_changed_after(zalsa, db, self.key_index(), last_verified_at, cycle_heads)
6051
}
6152
}
6253

0 commit comments

Comments
 (0)