diff options
Diffstat (limited to 'tests/ui/hashmap/hashmap-capacity-overflow.rs')
-rw-r--r-- | tests/ui/hashmap/hashmap-capacity-overflow.rs | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/ui/hashmap/hashmap-capacity-overflow.rs b/tests/ui/hashmap/hashmap-capacity-overflow.rs new file mode 100644 index 000000000..2988af065 --- /dev/null +++ b/tests/ui/hashmap/hashmap-capacity-overflow.rs @@ -0,0 +1,12 @@ +// run-fail +// error-pattern:capacity overflow +// ignore-emscripten no processes + +use std::collections::hash_map::HashMap; +use std::mem::size_of; + +fn main() { + let threshold = usize::MAX / size_of::<(u64, u64, u64)>(); + let mut h = HashMap::<u64, u64>::with_capacity(threshold + 100); + h.insert(0, 0); +} |