Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 14 additions & 9 deletions crates/iddqd/src/bi_hash_map/imp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1927,19 +1927,24 @@ impl<T: BiHashItem, S: Clone + BuildHasher, A: Allocator> BiHashMap<T, S, A> {
([MapHash::new(hash1), MapHash::new(hash2)], dormant_item)
};

// SAFETY: The original items is no longer used after the first
// block above.
let items = unsafe { dormant_items.awaken() };
// SAFETY: The original item is no longer used after the second
// block above.
let item = unsafe { dormant_item.awaken() };

let hash2 = hashes[1].hash();
let retain = {
// SAFETY: The original item is no longer used after the second
// block above. dormant_items, from which item is derived, is
// currently dormant.
let item = unsafe { dormant_item.awaken() };

let ref_mut = RefMut::new(hash_state.clone(), hashes, item);
f(ref_mut)
};

let ref_mut = RefMut::new(hash_state.clone(), hashes, item);
if f(ref_mut) {
if retain {
true
} else {
// SAFETY: The original items is no longer used after the first
// block above, and item + dormant_item have been dropped after
// being used above.
let items = unsafe { dormant_items.awaken() };
items.remove(index);
let k2_entry = self
.tables
Expand Down
23 changes: 14 additions & 9 deletions crates/iddqd/src/id_hash_map/imp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1341,17 +1341,22 @@ impl<T: IdHashItem, S: Clone + BuildHasher, A: Allocator> IdHashMap<T, S, A> {
(MapHash::new(hash), dormant_item)
};

// SAFETY: The original items is no longer used after the first
// block above.
let items = unsafe { dormant_items.awaken() };
// SAFETY: The original item is no longer used after the second
// block above.
let item = unsafe { dormant_item.awaken() };

let ref_mut = RefMut::new(hash_state.clone(), hash, item);
if f(ref_mut) {
let retain = {
// SAFETY: The original item is no longer used after the second
// block above. dormant_items, from which item is derived, is
// currently dormant.
let item = unsafe { dormant_item.awaken() };

let ref_mut = RefMut::new(hash_state.clone(), hash, item);
f(ref_mut)
};

if retain {
true
} else {
// SAFETY: The original items is no longer used after the first
// block above, and item + dormant item have been used above.
let items = unsafe { dormant_items.awaken() };
items.remove(index);
false
}
Expand Down
24 changes: 15 additions & 9 deletions crates/iddqd/src/id_ord_map/imp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1329,17 +1329,23 @@ impl<T: IdOrdItem> IdOrdMap<T> {
(MapHash::new(hash), dormant_item)
};

// SAFETY: The original items is no longer used after the first
// block above.
let items = unsafe { dormant_items.awaken() };
// SAFETY: The original item is no longer used after the second
// block above.
let item = unsafe { dormant_item.awaken() };

let ref_mut = RefMut::new(hash_state.clone(), hash, item);
if f(ref_mut) {
let retain = {
// SAFETY: The original item is no longer used after the second
// block above. dormant_items, from which item is derived, is
// currently dormant.
let item = unsafe { dormant_item.awaken() };

let ref_mut = RefMut::new(hash_state.clone(), hash, item);
f(ref_mut)
};

if retain {
true
} else {
// SAFETY: The original items is no longer used after the first
// block above, and item + dormant_item have been dropped after
// being used above.
let items = unsafe { dormant_items.awaken() };
items.remove(index);
false
}
Expand Down
23 changes: 14 additions & 9 deletions crates/iddqd/src/tri_hash_map/imp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2586,20 +2586,25 @@ impl<T: TriHashItem, S: Clone + BuildHasher, A: Allocator> TriHashMap<T, S, A> {
)
};

// SAFETY: The original items is no longer used after the first
// block above.
let items = unsafe { dormant_items.awaken() };
// SAFETY: The original item is no longer used after the second
// block above.
let item = unsafe { dormant_item.awaken() };

let hash2 = hashes[1].hash();
let hash3 = hashes[2].hash();
let retain = {
// SAFETY: The original item is no longer used after the second
// block above. dormant_items, from which item is derived, is
// currently dormant.
let item = unsafe { dormant_item.awaken() };

let ref_mut = RefMut::new(hash_state.clone(), hashes, item);
f(ref_mut)
};

let ref_mut = RefMut::new(hash_state.clone(), hashes, item);
if f(ref_mut) {
if retain {
true
} else {
// SAFETY: The original items is no longer used after the first
// block above, and item + dormant_item have been dropped after
// being used above.
let items = unsafe { dormant_items.awaken() };
items.remove(index);
let k2_entry = self
.tables
Expand Down
Loading