mirror of
https://github.com/salsa-rs/salsa.git
synced 2025-02-02 09:46:06 +00:00
fix(fmt_index): impl for InputFieldIngredient
This commit is contained in:
parent
78d7894266
commit
b76ac29a09
2 changed files with 15 additions and 11 deletions
|
@ -135,7 +135,12 @@ impl InputStruct {
|
|||
let jar_ty = self.jar_ty();
|
||||
let all_field_indices: Vec<Literal> = self.all_field_indices();
|
||||
let input_index: Literal = self.input_index();
|
||||
let debug_name = Literal::string(&format!("{}", self.id_ident()));
|
||||
let debug_name_struct = Literal::string(&self.id_ident().to_string());
|
||||
let debug_name_fields: Vec<_> = self
|
||||
.all_field_names()
|
||||
.into_iter()
|
||||
.map(|ident| Literal::string(&ident.to_string()))
|
||||
.collect();
|
||||
|
||||
parse_quote! {
|
||||
impl salsa::storage::IngredientsFor for #ident {
|
||||
|
@ -168,7 +173,7 @@ impl InputStruct {
|
|||
&mut ingredients.#all_field_indices
|
||||
},
|
||||
);
|
||||
salsa::input_field::InputFieldIngredient::new(index)
|
||||
salsa::input_field::InputFieldIngredient::new(index, #debug_name_fields)
|
||||
},
|
||||
)*
|
||||
{
|
||||
|
@ -184,7 +189,7 @@ impl InputStruct {
|
|||
&mut ingredients.#input_index
|
||||
},
|
||||
);
|
||||
salsa::input::InputIngredient::new(index, #debug_name)
|
||||
salsa::input::InputIngredient::new(index, #debug_name_struct)
|
||||
},
|
||||
)
|
||||
}
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
use crate::cycle::CycleRecoveryStrategy;
|
||||
use crate::ingredient::{Ingredient, IngredientRequiresReset};
|
||||
use crate::ingredient::{fmt_index, Ingredient, IngredientRequiresReset};
|
||||
use crate::key::DependencyIndex;
|
||||
use crate::runtime::local_state::QueryOrigin;
|
||||
use crate::runtime::StampedValue;
|
||||
use crate::{AsId, DatabaseKeyIndex, Durability, Id, IngredientIndex, Revision, Runtime};
|
||||
use rustc_hash::FxHashMap;
|
||||
use std::fmt;
|
||||
use std::hash::Hash;
|
||||
|
||||
/// Ingredient used to represent the fields of a `#[salsa::input]`.
|
||||
|
@ -15,16 +16,18 @@ use std::hash::Hash;
|
|||
pub struct InputFieldIngredient<K, F> {
|
||||
index: IngredientIndex,
|
||||
map: FxHashMap<K, StampedValue<F>>,
|
||||
debug_name: &'static str,
|
||||
}
|
||||
|
||||
impl<K, F> InputFieldIngredient<K, F>
|
||||
where
|
||||
K: Eq + Hash + AsId,
|
||||
{
|
||||
pub fn new(index: IngredientIndex) -> Self {
|
||||
pub fn new(index: IngredientIndex, debug_name: &'static str) -> Self {
|
||||
Self {
|
||||
index,
|
||||
map: Default::default(),
|
||||
debug_name,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -114,12 +117,8 @@ where
|
|||
panic!("unexpected call: input fields don't register for resets");
|
||||
}
|
||||
|
||||
fn fmt_index(
|
||||
&self,
|
||||
_index: Option<crate::Id>,
|
||||
_fmt: &mut std::fmt::Formatter<'_>,
|
||||
) -> std::fmt::Result {
|
||||
todo!()
|
||||
fn fmt_index(&self, index: Option<crate::Id>, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
fmt_index(self.debug_name, index, fmt)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue