record when specify is called by a user

Pre-declared fields do not need to be recorded,
as they are always specified.
This commit is contained in:
Niko Matsakis 2022-08-10 03:55:04 -04:00
parent 6ad632a747
commit 604c182d7b
2 changed files with 15 additions and 1 deletions

View file

@ -415,7 +415,7 @@ fn specify_fn(
let (__jar, __runtime) = <_ as salsa::storage::HasJar<#jar_ty>>::jar(#db_var);
let __ingredients = <_ as salsa::storage::HasIngredientsFor<#config_ty>>::ingredient(__jar);
__ingredients.function.specify(#db_var, #(#arg_names,)* #value_arg)
__ingredients.function.specify_and_record(#db_var, #(#arg_names,)* #value_arg)
}
},
}))

View file

@ -71,6 +71,20 @@ where
revisions,
};
log::debug!("specify: about to add memo {:#?} for key {:?}", memo, key);
self.insert_memo(key, memo);
}
/// Specify the value for `key` *and* record that we did so.
/// Used for explicit calls to `specify`, but not needed for pre-declared tracked struct fields.
pub fn specify_and_record<'db>(&self, db: &'db DynDb<'db, C>, key: C::Key, value: C::Value)
where
C::Key: TrackedStructInDb<DynDb<'db, C>>,
{
self.specify(db, key, value);
// Record that the current query *specified* a value for this cell.
let database_key_index = self.database_key_index(key);
db.salsa_runtime().add_output(database_key_index);
}
}