Skip to content

Commit 97f5547

Browse files
committed
forgot to add mem::forget() on key
1 parent 54499fe commit 97f5547

File tree

1 file changed

+4
-3
lines changed
  • library/alloc/src/collections/btree

1 file changed

+4
-3
lines changed

library/alloc/src/collections/btree/map.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1328,7 +1328,7 @@ impl<K, V, A: Allocator + Clone> BTreeMap<K, V, A> {
13281328
}
13291329
}
13301330
} else {
1331-
// SAFETY: if we reach here, that means our cursor has reached
1331+
// Safety: if we reach here, that means our cursor has reached
13321332
// the end of self BTreeMap, (other_key is greater than all the
13331333
// previous self BTreeMap keys) so we just insert other_key here
13341334
// at the end of the CursorMut
@@ -3488,9 +3488,10 @@ impl<'a, K: Ord, V, A: Allocator + Clone> CursorMutKey<'a, K, V, A> {
34883488

34893489
let mut emptied_internal_root = false;
34903490
if let Ok(next_kv) = current.next_kv() {
3491-
let ((_, val), pos) =
3491+
let ((key, val), pos) =
34923492
next_kv.remove_kv_tracking(|| emptied_internal_root = true, self.alloc.clone());
3493-
// Don't run destructor on next element's value
3493+
// Don't run destructor on next element's key and value
3494+
mem::forget(key);
34943495
mem::forget(val);
34953496
self.current = Some(pos);
34963497
*self.length -= 1;

0 commit comments

Comments
 (0)