revert fmt

This commit is contained in:
zjp 2022-08-22 08:36:13 +08:00
parent 525a9fec4c
commit 9f9b46f5e0

View file

@ -30,17 +30,15 @@ mod store;
mod sync; mod sync;
/// Function ingredients are the "workhorse" of salsa. /// Function ingredients are the "workhorse" of salsa.
/// They are used for tracked functions, for the "value" fields of tracked structs, and for the /// They are used for tracked functions, for the "value" fields of tracked structs, and for the fields of input structs.
/// fields of input structs. The function ingredient is fairly complex and so its code is /// The function ingredient is fairly complex and so its code is spread across multiple modules, typically one per method.
/// spread across multiple modules, typically one per method. The main entry points are: /// The main entry points are:
/// ///
/// * the `fetch` method, which is invoked when the function is called by the user's code; it /// * the `fetch` method, which is invoked when the function is called by the user's code;
/// will return a memoized value if one exists, or execute the function otherwise. /// it will return a memoized value if one exists, or execute the function otherwise.
/// * the `specify` method, which can only be used when the key is an entity created by the /// * the `specify` method, which can only be used when the key is an entity created by the active query.
/// active query. It sets the value of the function imperatively, so that when later fetches /// It sets the value of the function imperatively, so that when later fetches occur, they'll return this value.
/// occur, they'll return this value. /// * the `store` method, which can only be invoked with an `&mut` reference, and is to set input fields.
/// * the `store` method, which can only be invoked with an `&mut` reference, and is to set
/// input fields.
pub struct FunctionIngredient<C: Configuration> { pub struct FunctionIngredient<C: Configuration> {
/// The ingredient index we were assigned in the database. /// The ingredient index we were assigned in the database.
/// Used to construct `DatabaseKeyIndex` values. /// Used to construct `DatabaseKeyIndex` values.
@ -99,8 +97,8 @@ pub trait Configuration {
/// Invokes after a new result `new_value`` has been computed for which an older memoized /// Invokes after a new result `new_value`` has been computed for which an older memoized
/// value existed `old_value`. Returns true if the new value is equal to the older one /// value existed `old_value`. Returns true if the new value is equal to the older one
/// and hence should be "backdated" (i.e., marked as having last changed in an older /// and hence should be "backdated" (i.e., marked as having last changed in an older revision,
/// revision, even though it was recomputed). /// even though it was recomputed).
/// ///
/// This invokes user's code in form of the `Eq` impl. /// This invokes user's code in form of the `Eq` impl.
fn should_backdate_value(old_value: &Self::Value, new_value: &Self::Value) -> bool; fn should_backdate_value(old_value: &Self::Value, new_value: &Self::Value) -> bool;
@ -188,9 +186,8 @@ where
self.register(db); self.register(db);
let memo = Arc::new(memo); let memo = Arc::new(memo);
let value = unsafe { let value = unsafe {
// Unsafety conditions: memo must be in the map (it's not yet, but it will be by the // Unsafety conditions: memo must be in the map (it's not yet, but it will be by the time this
// time this value is returned) and anything removed from map is added to // value is returned) and anything removed from map is added to deleted entries (ensured elsewhere).
// deleted entries (ensured elsewhere).
self.extend_memo_lifetime(&memo) self.extend_memo_lifetime(&memo)
}; };
if let Some(old_value) = self.memo_map.insert(key, memo) { if let Some(old_value) = self.memo_map.insert(key, memo) {
@ -247,10 +244,9 @@ where
_executor: DatabaseKeyIndex, _executor: DatabaseKeyIndex,
_stale_output_key: Option<crate::Id>, _stale_output_key: Option<crate::Id>,
) { ) {
// This function is invoked when a query Q specifies the value for `stale_output_key` // This function is invoked when a query Q specifies the value for `stale_output_key` in rev 1,
// in rev 1, but not in rev 2. We don't do anything in this case, we just leave // but not in rev 2. We don't do anything in this case, we just leave the (now stale) memo.
// the (now stale) memo. Since its `verified_at` field has not changed, it will // Since its `verified_at` field has not changed, it will be considered dirty if it is invoked.
// be considered dirty if it is invoked.
} }
fn reset_for_new_revision(&mut self) { fn reset_for_new_revision(&mut self) {