From a4025e89ebbff5a19c3ced47485c8e32a83108a2 Mon Sep 17 00:00:00 2001 From: marc0246 <40955683+marc0246@users.noreply.github.com> Date: Mon, 8 Jul 2024 23:58:53 +0200 Subject: [PATCH] Fix `SlotMap::try_collect` not checking the guard's global --- src/lib.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index 34e2ea4..c9e255f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -391,7 +391,12 @@ impl> SlotMap { } } + /// # Panics + /// + /// Panics if `guard.global()` does not equal `self.global()`. pub fn try_collect(&self, guard: &epoch::Guard<'_>) { + assert_eq!(guard.global(), &self.global); + let epoch = guard.epoch(); let queued_list = &self.free_list_queue[((epoch >> 1) & 1) as usize]; let mut queued_state = queued_list.load(Acquire);