diff --git a/components/salsa-2022/src/input_field.rs b/components/salsa-2022/src/input_field.rs index fcd9c706..187dafa7 100644 --- a/components/salsa-2022/src/input_field.rs +++ b/components/salsa-2022/src/input_field.rs @@ -1,6 +1,7 @@ use crate::cycle::CycleRecoveryStrategy; use crate::ingredient::{fmt_index, Ingredient, IngredientRequiresReset}; use crate::key::DependencyIndex; +use crate::plumbing::transmute_lifetime; use crate::runtime::local_state::QueryOrigin; use crate::runtime::StampedValue; use crate::{AsId, DatabaseKeyIndex, Durability, Id, IngredientIndex, Revision, Runtime}; @@ -104,14 +105,6 @@ where } } -// Returns `u` but with the lifetime of `t`. -// -// Safe if you know that data at `u` will remain shared -// until the reference `t` expires. -unsafe fn transmute_lifetime<'t, 'u, T, U>(_t: &'t T, u: &'u U) -> &'t U { - std::mem::transmute(u) -} - impl Ingredient for InputFieldIngredient where K: AsId, diff --git a/components/salsa-2022/src/interned.rs b/components/salsa-2022/src/interned.rs index 80d78f87..a54132f5 100644 --- a/components/salsa-2022/src/interned.rs +++ b/components/salsa-2022/src/interned.rs @@ -8,6 +8,7 @@ use crate::durability::Durability; use crate::id::AsId; use crate::ingredient::{fmt_index, IngredientRequiresReset}; use crate::key::DependencyIndex; +use crate::plumbing::transmute_lifetime; use crate::runtime::local_state::QueryOrigin; use crate::runtime::Runtime; use crate::DatabaseKeyIndex; @@ -181,14 +182,6 @@ where } } -// Returns `u` but with the lifetime of `t`. -// -// Safe if you know that data at `u` will remain shared -// until the reference `t` expires. -unsafe fn transmute_lifetime<'t, 'u, T, U>(_t: &'t T, u: &'u U) -> &'t U { - std::mem::transmute(u) -} - impl Ingredient for InternedIngredient where Id: InternedId, diff --git a/components/salsa-2022/src/plumbing.rs b/components/salsa-2022/src/plumbing.rs index 65a06451..f5e95d98 100644 --- a/components/salsa-2022/src/plumbing.rs +++ b/components/salsa-2022/src/plumbing.rs @@ -26,3 +26,11 @@ pub unsafe fn create_jars_inplace(init: impl FnOnce(*mut DB::Jars)) unsafe { Box::from_raw(place) } } } + +// Returns `u` but with the lifetime of `t`. +// +// Safe if you know that data at `u` will remain shared +// until the reference `t` expires. +pub(crate) unsafe fn transmute_lifetime<'t, 'u, T, U>(_t: &'t T, u: &'u U) -> &'t U { + std::mem::transmute(u) +}