diff --git a/src/function.rs b/src/function.rs index 24cbb130..ffaf6a7b 100644 --- a/src/function.rs +++ b/src/function.rs @@ -155,9 +155,8 @@ where unsafe fn extend_memo_lifetime<'this, 'memo>( &'this self, memo: &'memo memo::Memo>, - ) -> Option<&'this C::Output<'this>> { - let memo_value: Option<&'memo C::Output<'this>> = memo.value.as_ref(); - std::mem::transmute(memo_value) + ) -> &'this memo::Memo> { + std::mem::transmute(memo) } fn insert_memo<'db>( @@ -170,7 +169,7 @@ where let value = unsafe { // Unsafety conditions: memo must be in the map (it's not yet, but it will be by the time this // value is returned) and anything removed from map is added to deleted entries (ensured elsewhere). - self.extend_memo_lifetime(&memo) + self.extend_memo_lifetime(&memo).value.as_ref() }; if let Some(old_value) = self.insert_memo_into_table_for(zalsa, id, memo) { // In case there is a reference to the old memo out there, we have to store it diff --git a/src/function/fetch.rs b/src/function/fetch.rs index ff77b95c..5a7c25b3 100644 --- a/src/function/fetch.rs +++ b/src/function/fetch.rs @@ -52,7 +52,7 @@ where { let value = unsafe { // Unsafety invariant: memo is present in memo_map - self.extend_memo_lifetime(memo).unwrap() + self.extend_memo_lifetime(memo).value.as_ref().unwrap() }; return Some(memo.revisions.stamped_value(value)); } @@ -86,7 +86,7 @@ where if old_memo.value.is_some() && self.deep_verify_memo(db, old_memo, &active_query) { let value = unsafe { // Unsafety invariant: memo is present in memo_map. - self.extend_memo_lifetime(old_memo).unwrap() + self.extend_memo_lifetime(old_memo).value.as_ref().unwrap() }; return Some(old_memo.revisions.stamped_value(value)); }