Mark Slot trait as unsafe

This commit is contained in:
Lukas Wirth 2025-06-13 09:21:29 +02:00
parent 27047696c2
commit b387b0fefa
4 changed files with 11 additions and 4 deletions

View file

@ -290,7 +290,8 @@ pub trait HasBuilder {
type Builder;
}
impl<C> Slot for Value<C>
// SAFETY: `Value<C>` is our private type branded over the unique configuration `C`.
unsafe impl<C> Slot for Value<C>
where
C: Configuration,
{

View file

@ -843,7 +843,8 @@ where
}
}
impl<C> Slot for Value<C>
// SAFETY: `Value<C>` is our private type branded over the unique configuration `C`.
unsafe impl<C> Slot for Value<C>
where
C: Configuration,
{

View file

@ -30,7 +30,11 @@ pub struct Table {
non_full_pages: Mutex<FxHashMap<IngredientIndex, Vec<PageIndex>>>,
}
pub(crate) trait Slot: Any + Send + Sync {
/// # Safety
///
/// Implementors of this trait need to make sure that their type is unique with respect to
/// their owning ingredient as the allocation strategy relies on this.
pub(crate) unsafe trait Slot: Any + Send + Sync {
/// Access the [`MemoTable`][] for this slot.
///
/// # Safety condition

View file

@ -912,7 +912,8 @@ where
}
}
impl<C> Slot for Value<C>
// SAFETY: `Value<C>` is our private type branded over the unique configuration `C`.
unsafe impl<C> Slot for Value<C>
where
C: Configuration,
{