authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-04-20 17:16:32-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-04-20 17:18:06-07:00
log4f527e5d36f66a83ff6a263a03f16e2c4d049f1e
tree7ea75f706f934a32f0c7dd9b3ec4ca392855fe1d
parent99112b63bdeec512e164f289556b24fa1554a775

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.

2 files changed, 3 insertions(+), 1 deletions(-)

lib/std/array_hash_map.zig+1-1
......@@ -798,7 +798,7 @@ pub fn ArrayHashMapUnmanaged(
798798 allocator: Allocator,
799799 additional_capacity: usize,
800800 ) !void {
801 if (@sizeOf(ByIndexContext) != 0)
801 if (@sizeOf(Context) != 0)
802802 @compileError("Cannot infer context " ++ @typeName(Context) ++ ", call ensureTotalCapacityContext instead.");
803803 return self.ensureUnusedCapacityContext(allocator, additional_capacity, undefined);
804804 }
lib/std/hash_map.zig+2
......@@ -913,6 +913,8 @@ pub fn HashMapUnmanaged(
913913 }
914914
915915 pub fn ensureUnusedCapacity(self: *Self, allocator: Allocator, additional_size: Size) Allocator.Error!void {
916 if (@sizeOf(Context) != 0)
917 @compileError("Cannot infer context " ++ @typeName(Context) ++ ", call ensureUnusedCapacityContext instead.");
916918 return ensureUnusedCapacityContext(self, allocator, additional_size, undefined);
917919 }
918920 pub fn ensureUnusedCapacityContext(self: *Self, allocator: Allocator, additional_size: Size, ctx: Context) Allocator.Error!void {