Skip to content

Commit 33eb941

Browse files
committed
Auto merge of #92998 - Amanieu:hashbrown12, r=Mark-Simulacrum
Update hashbrown to 0.12.0 [Changelog](https://github.com/rust-lang/hashbrown/blob/master/CHANGELOG.md#v0120---2022-01-17)
2 parents ec4360a + 400dc68 commit 33eb941

File tree

2 files changed

+17
-6
lines changed

2 files changed

+17
-6
lines changed

std/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ libc = { version = "0.2.108", default-features = false, features = ['rustc-dep-o
1919
compiler_builtins = { version = "0.1.66" }
2020
profiler_builtins = { path = "../profiler_builtins", optional = true }
2121
unwind = { path = "../unwind" }
22-
hashbrown = { version = "0.11", default-features = false, features = ['rustc-dep-of-std'] }
22+
hashbrown = { version = "0.12", default-features = false, features = ['rustc-dep-of-std'] }
2323
std_detect = { path = "../stdarch/crates/std_detect", default-features = false, features = ['rustc-dep-of-std'] }
2424

2525
# Dependencies of the `backtrace` crate

std/src/collections/hash/map/tests.rs

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -817,6 +817,7 @@ fn test_retain() {
817817
}
818818

819819
#[test]
820+
#[cfg_attr(target_os = "android", ignore)] // Android used in CI has a broken dlmalloc
820821
fn test_try_reserve() {
821822
let mut empty_bytes: HashMap<u8, u8> = HashMap::new();
822823

@@ -828,11 +829,21 @@ fn test_try_reserve() {
828829
"usize::MAX should trigger an overflow!"
829830
);
830831

831-
assert_matches!(
832-
empty_bytes.try_reserve(MAX_USIZE / 8).map_err(|e| e.kind()),
833-
Err(AllocError { .. }),
834-
"usize::MAX / 8 should trigger an OOM!"
835-
);
832+
if let Err(AllocError { .. }) = empty_bytes.try_reserve(MAX_USIZE / 16).map_err(|e| e.kind()) {
833+
} else {
834+
// This may succeed if there is enough free memory. Attempt to
835+
// allocate a few more hashmaps to ensure the allocation will fail.
836+
let mut empty_bytes2: HashMap<u8, u8> = HashMap::new();
837+
let _ = empty_bytes2.try_reserve(MAX_USIZE / 16);
838+
let mut empty_bytes3: HashMap<u8, u8> = HashMap::new();
839+
let _ = empty_bytes3.try_reserve(MAX_USIZE / 16);
840+
let mut empty_bytes4: HashMap<u8, u8> = HashMap::new();
841+
assert_matches!(
842+
empty_bytes4.try_reserve(MAX_USIZE / 16).map_err(|e| e.kind()),
843+
Err(AllocError { .. }),
844+
"usize::MAX / 16 should trigger an OOM!"
845+
);
846+
}
836847
}
837848

838849
#[test]

0 commit comments

Comments
 (0)