diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2022-04-20 17:16:32 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2022-04-20 17:18:06 -0700 |
| commit | 4f527e5d36f66a83ff6a263a03f16e2c4d049f1e (patch) | |
| tree | 7ea75f706f934a32f0c7dd9b3ec4ca392855fe1d | |
| parent | 99112b63bdeec512e164f289556b24fa1554a775 (diff) | |
| download | zig-4f527e5d36f66a83ff6a263a03f16e2c4d049f1e.tar.gz zig-4f527e5d36f66a83ff6a263a03f16e2c4d049f1e.zip | |
std: fix missing hash map safety
There was a missing compile error for calling ensureUnusedCapacity
without a Context in the case that the Context is non-void.
| -rw-r--r-- | lib/std/array_hash_map.zig | 2 | ||||
| -rw-r--r-- | lib/std/hash_map.zig | 2 |
2 files changed, 3 insertions, 1 deletions
diff --git a/lib/std/array_hash_map.zig b/lib/std/array_hash_map.zig index 31860963af..304c98a2a9 100644 --- a/lib/std/array_hash_map.zig +++ b/lib/std/array_hash_map.zig @@ -798,7 +798,7 @@ pub fn ArrayHashMapUnmanaged( allocator: Allocator, additional_capacity: usize, ) !void { - if (@sizeOf(ByIndexContext) != 0) + if (@sizeOf(Context) != 0) @compileError("Cannot infer context " ++ @typeName(Context) ++ ", call ensureTotalCapacityContext instead."); return self.ensureUnusedCapacityContext(allocator, additional_capacity, undefined); } diff --git a/lib/std/hash_map.zig b/lib/std/hash_map.zig index 96df243f6e..eb24ef591b 100644 --- a/lib/std/hash_map.zig +++ b/lib/std/hash_map.zig @@ -913,6 +913,8 @@ pub fn HashMapUnmanaged( } pub fn ensureUnusedCapacity(self: *Self, allocator: Allocator, additional_size: Size) Allocator.Error!void { + if (@sizeOf(Context) != 0) + @compileError("Cannot infer context " ++ @typeName(Context) ++ ", call ensureUnusedCapacityContext instead."); return ensureUnusedCapacityContext(self, allocator, additional_size, undefined); } pub fn ensureUnusedCapacityContext(self: *Self, allocator: Allocator, additional_size: Size, ctx: Context) Allocator.Error!void { |
