about summary refs log tree commit diff
path: root/src/libstd/collections
diff options
context:
space:
mode:
authorJohn Kåre Alsaker <john.kare.alsaker@gmail.com>2018-12-06 14:23:29 +0100
committerJohn Kåre Alsaker <john.kare.alsaker@gmail.com>2018-12-06 14:32:00 +0100
commit7df4b812f07c503dc10037797f80a9aaa6b84aac (patch)
tree4cd4c4decdf8f7694c9f92c13389de1ad60e6960 /src/libstd/collections
parent128a1fa4e1f85e04f522653bb9bee83ed6523440 (diff)
downloadrust-7df4b812f07c503dc10037797f80a9aaa6b84aac.tar.gz
rust-7df4b812f07c503dc10037797f80a9aaa6b84aac.zip
Fix bug in from_key_hashed_nocheck
Diffstat (limited to 'src/libstd/collections')
-rw-r--r--src/libstd/collections/hash/map.rs4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/libstd/collections/hash/map.rs b/src/libstd/collections/hash/map.rs
index 536ce2e16a0..11ccf206d00 100644
--- a/src/libstd/collections/hash/map.rs
+++ b/src/libstd/collections/hash/map.rs
@@ -11,6 +11,7 @@
 use self::Entry::*;
 use self::VacantEntryState::*;
 
+use intrinsics::unlikely;
 use collections::CollectionAllocErr;
 use cell::Cell;
 use borrow::Borrow;
@@ -1992,6 +1993,9 @@ impl<'a, K, V, S> RawEntryBuilder<'a, K, V, S>
     fn search<F>(self, hash: u64, is_match: F, compare_hashes: bool) -> Option<(&'a K, &'a V)>
         where F: FnMut(&K) -> bool
     {
+        if unsafe { unlikely(self.map.table.size() == 0) } {
+            return None;
+        }
         match search_hashed_nonempty(&self.map.table,
                                      SafeHash::new(hash),
                                      is_match,