diff --git a/src/libstd/collections/hash/map.rs b/src/libstd/collections/hash/map.rs index 6f04495861858..8fb703e8fb830 100644 --- a/src/libstd/collections/hash/map.rs +++ b/src/libstd/collections/hash/map.rs @@ -1668,8 +1668,13 @@ impl super::Recover for HashMap InternalEntry::Occupied { mut elem } => { Some(mem::replace(elem.read_mut().0, key)) } - _ => { - None + other => { + if let Some(Vacant(vacant)) = other.into_entry(key) { + vacant.insert(()); + None + } else { + unreachable!() + } } } }