diff --git a/components/salsa-2022-macros/src/db.rs b/components/salsa-2022-macros/src/db.rs index 54c22ab8..b6fe5720 100644 --- a/components/salsa-2022-macros/src/db.rs +++ b/components/salsa-2022-macros/src/db.rs @@ -159,6 +159,10 @@ fn has_jars_dyn_impl(input: &syn::ItemStruct, storage: &syn::Ident) -> syn::Item let ingredient = self.#storage.ingredient(ingredient); ingredient.salsa_struct_deleted(self, id); } + fn fmt_index(&self, index: salsa::DependencyIndex, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + let ingredient = self.#storage.ingredient(ingredient); + ingredient.fmt_index(self, index, fmt) + } } } } diff --git a/components/salsa-2022-macros/src/input.rs b/components/salsa-2022-macros/src/input.rs index 9932226b..d2d5c9e4 100644 --- a/components/salsa-2022-macros/src/input.rs +++ b/components/salsa-2022-macros/src/input.rs @@ -135,6 +135,7 @@ impl InputStruct { let jar_ty = self.jar_ty(); let all_field_indices: Vec = self.all_field_indices(); let input_index: Literal = self.input_index(); + let debug_name = Literal::string(&format!("{}", self.id_ident())); parse_quote! { impl salsa::storage::IngredientsFor for #ident { @@ -183,7 +184,7 @@ impl InputStruct { &mut ingredients.#input_index }, ); - salsa::input::InputIngredient::new(index) + salsa::input::InputIngredient::new(index, #debug_name) }, ) } diff --git a/components/salsa-2022-macros/src/tracked_fn.rs b/components/salsa-2022-macros/src/tracked_fn.rs index 355a7668..0af8393d 100644 --- a/components/salsa-2022-macros/src/tracked_fn.rs +++ b/components/salsa-2022-macros/src/tracked_fn.rs @@ -242,6 +242,9 @@ fn ingredients_for_impl( // set 0 as default to disable LRU let lru = args.lru.unwrap_or(0); + // get the name of the function as a string literal + let debug_name = Literal::string(&format!("{}", item_fn.sig.ident)); + parse_quote! { impl salsa::storage::IngredientsFor for #config_ty { type Ingredients = Self; @@ -268,7 +271,7 @@ fn ingredients_for_impl( <_ as salsa::storage::HasIngredientsFor>::ingredient_mut(jar); &mut ingredients.function }); - let ingredient = salsa::function::FunctionIngredient::new(index); + let ingredient = salsa::function::FunctionIngredient::new(index, #debug_name); ingredient.set_capacity(#lru); ingredient } diff --git a/components/salsa-2022/src/accumulator.rs b/components/salsa-2022/src/accumulator.rs index 1d91a405..1df998d0 100644 --- a/components/salsa-2022/src/accumulator.rs +++ b/components/salsa-2022/src/accumulator.rs @@ -148,6 +148,14 @@ where fn salsa_struct_deleted(&self, _db: &DB, _id: crate::Id) { panic!("unexpected call: accumulator is not registered as a dependent fn"); } + + fn fmt_index( + &self, + _index: Option, + _fmt: &mut std::fmt::Formatter<'_>, + ) -> std::fmt::Result { + todo!() + } } impl IngredientRequiresReset for AccumulatorIngredient diff --git a/components/salsa-2022/src/function.rs b/components/salsa-2022/src/function.rs index 9603f6df..929e9b56 100644 --- a/components/salsa-2022/src/function.rs +++ b/components/salsa-2022/src/function.rs @@ -73,6 +73,8 @@ pub struct FunctionIngredient { /// Set to true once we invoke `register_dependent_fn` for `C::SalsaStruct`. /// Prevents us from registering more than once. registered: AtomicCell, + + debug_name: &'static str, } pub trait Configuration { @@ -139,7 +141,7 @@ impl FunctionIngredient where C: Configuration, { - pub fn new(index: IngredientIndex) -> Self { + pub fn new(index: IngredientIndex, debug_name: &'static str) -> Self { Self { index, memo_map: memo::MemoMap::default(), @@ -147,6 +149,7 @@ where sync_map: Default::default(), deleted_entries: Default::default(), registered: Default::default(), + debug_name, } } @@ -273,6 +276,14 @@ where } } } + + fn fmt_index( + &self, + _index: Option, + _fmt: &mut std::fmt::Formatter<'_>, + ) -> std::fmt::Result { + todo!() + } } impl IngredientRequiresReset for FunctionIngredient diff --git a/components/salsa-2022/src/ingredient.rs b/components/salsa-2022/src/ingredient.rs index 89ebb4cf..729011dc 100644 --- a/components/salsa-2022/src/ingredient.rs +++ b/components/salsa-2022/src/ingredient.rs @@ -59,6 +59,12 @@ pub trait Ingredient { /// **Important:** to actually receive resets, the ingredient must set /// [`IngredientRequiresReset::RESET_ON_NEW_REVISION`] to true. fn reset_for_new_revision(&mut self); + + fn fmt_index( + &self, + index: Option, + fmt: &mut std::fmt::Formatter<'_>, + ) -> std::fmt::Result; } /// Defines a const indicating if an ingredient needs to be reset each round. diff --git a/components/salsa-2022/src/input.rs b/components/salsa-2022/src/input.rs index f6dc35cf..7059ca6f 100644 --- a/components/salsa-2022/src/input.rs +++ b/components/salsa-2022/src/input.rs @@ -15,6 +15,7 @@ where { ingredient_index: IngredientIndex, counter: u32, + debug_name: &'static str, _phantom: std::marker::PhantomData, } @@ -22,10 +23,11 @@ impl InputIngredient where Id: InputId, { - pub fn new(index: IngredientIndex) -> Self { + pub fn new(index: IngredientIndex, debug_name: &'static str) -> Self { Self { ingredient_index: index, counter: Default::default(), + debug_name, _phantom: std::marker::PhantomData, } } @@ -95,6 +97,14 @@ where "unexpected call: input ingredients do not register for salsa struct deletion events" ); } + + fn fmt_index( + &self, + _index: Option, + _fmt: &mut std::fmt::Formatter<'_>, + ) -> std::fmt::Result { + todo!() + } } impl IngredientRequiresReset for InputIngredient diff --git a/components/salsa-2022/src/input_field.rs b/components/salsa-2022/src/input_field.rs index 8204e60b..54ce093a 100644 --- a/components/salsa-2022/src/input_field.rs +++ b/components/salsa-2022/src/input_field.rs @@ -113,6 +113,14 @@ where fn reset_for_new_revision(&mut self) { panic!("unexpected call: input fields don't register for resets"); } + + fn fmt_index( + &self, + _index: Option, + _fmt: &mut std::fmt::Formatter<'_>, + ) -> std::fmt::Result { + todo!() + } } impl IngredientRequiresReset for InputFieldIngredient diff --git a/components/salsa-2022/src/interned.rs b/components/salsa-2022/src/interned.rs index e30c1235..e6bd7f6e 100644 --- a/components/salsa-2022/src/interned.rs +++ b/components/salsa-2022/src/interned.rs @@ -234,6 +234,14 @@ where fn salsa_struct_deleted(&self, _db: &DB, _id: crate::Id) { panic!("unexpected call: interned ingredients do not register for salsa struct deletion events"); } + + fn fmt_index( + &self, + _index: Option, + _fmt: &mut std::fmt::Formatter<'_>, + ) -> std::fmt::Result { + todo!() + } } impl IngredientRequiresReset for InternedIngredient diff --git a/components/salsa-2022/src/storage.rs b/components/salsa-2022/src/storage.rs index bf5ba0ea..7d37fd75 100644 --- a/components/salsa-2022/src/storage.rs +++ b/components/salsa-2022/src/storage.rs @@ -220,6 +220,12 @@ pub trait HasJarsDyn { /// as a dependent function using /// [`SalsaStructInDb::register_dependent_fn`](`crate::salsa_struct::SalsaStructInDb::register_dependent_fn`). fn salsa_struct_deleted(&self, ingredient: IngredientIndex, id: Id); + + fn fmt_index( + &self, + index: DependencyIndex, + fmt: &mut std::fmt::Formatter<'_>, + ) -> std::fmt::Result; } // ANCHOR_END: HasJarsDyn diff --git a/components/salsa-2022/src/tracked_struct.rs b/components/salsa-2022/src/tracked_struct.rs index 98ebf6d4..675a3985 100644 --- a/components/salsa-2022/src/tracked_struct.rs +++ b/components/salsa-2022/src/tracked_struct.rs @@ -175,6 +175,14 @@ where fn salsa_struct_deleted(&self, _db: &DB, _id: crate::Id) { panic!("unexpected call: interned ingredients do not register for salsa struct deletion events"); } + + fn fmt_index( + &self, + _index: Option, + _fmt: &mut std::fmt::Formatter<'_>, + ) -> std::fmt::Result { + todo!() + } } impl IngredientRequiresReset for TrackedStructIngredient