authorgravatar for quae@daurnimator.comdaurnimator <quae@daurnimator.com> 2021-02-27 13:49:02+11:00
committergravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2021-02-27 13:11:47+02:00
logd4af35b3fe42a7ad5b808012b15d479526140730
tree8e00a7f4a9418b69aeec7c4d1ac7d0c5c5f8c908
parent490654c332f2d8eaf7edffa35ea0523800df998d

HashMap.put returns !void, not a !bool


11 files changed, 32 insertions(+), 33 deletions(-)

lib/std/buf_set.zig+1-1
...@@ -32,7 +32,7 @@ pub const BufSet = struct {...@@ -32,7 +32,7 @@ pub const BufSet = struct {
32 if (self.hash_map.get(key) == null) {32 if (self.hash_map.get(key) == null) {
33 const key_copy = try self.copy(key);33 const key_copy = try self.copy(key);
34 errdefer self.free(key_copy);34 errdefer self.free(key_copy);
35 _ = try self.hash_map.put(key_copy, {});35 try self.hash_map.put(key_copy, {});
36 }36 }
37 }37 }
3838
lib/std/build.zig+2-2
...@@ -790,7 +790,7 @@ pub const Builder = struct {...@@ -790,7 +790,7 @@ pub const Builder = struct {
790 var list = ArrayList([]const u8).init(self.allocator);790 var list = ArrayList([]const u8).init(self.allocator);
791 list.append(s) catch unreachable;791 list.append(s) catch unreachable;
792 list.append(value) catch unreachable;792 list.append(value) catch unreachable;
793 _ = self.user_input_options.put(name, UserInputOption{793 self.user_input_options.put(name, UserInputOption{
794 .name = name,794 .name = name,
795 .value = UserValue{ .List = list },795 .value = UserValue{ .List = list },
796 .used = false,796 .used = false,
...@@ -799,7 +799,7 @@ pub const Builder = struct {...@@ -799,7 +799,7 @@ pub const Builder = struct {
799 UserValue.List => |*list| {799 UserValue.List => |*list| {
800 // append to the list800 // append to the list
801 list.append(value) catch unreachable;801 list.append(value) catch unreachable;
802 _ = self.user_input_options.put(name, UserInputOption{802 self.user_input_options.put(name, UserInputOption{
803 .name = name,803 .name = name,
804 .value = UserValue{ .List = list.* },804 .value = UserValue{ .List = list.* },
805 .used = false,805 .used = false,
lib/std/hash_map.zig+1-2
...@@ -563,7 +563,6 @@ pub fn HashMapUnmanaged(...@@ -563,7 +563,6 @@ pub fn HashMapUnmanaged(
563 }563 }
564564
565 /// Insert an entry if the associated key is not already present, otherwise update preexisting value.565 /// Insert an entry if the associated key is not already present, otherwise update preexisting value.
566 /// Returns true if the key was already present.
567 pub fn put(self: *Self, allocator: *Allocator, key: K, value: V) !void {566 pub fn put(self: *Self, allocator: *Allocator, key: K, value: V) !void {
568 const result = try self.getOrPut(allocator, key);567 const result = try self.getOrPut(allocator, key);
569 result.entry.value = value;568 result.entry.value = value;
...@@ -1116,7 +1115,7 @@ test "std.hash_map put" {...@@ -1116,7 +1115,7 @@ test "std.hash_map put" {
11161115
1117 var i: u32 = 0;1116 var i: u32 = 0;
1118 while (i < 16) : (i += 1) {1117 while (i < 16) : (i += 1) {
1119 _ = try map.put(i, i);1118 try map.put(i, i);
1120 }1119 }
11211120
1122 i = 0;1121 i = 0;
lib/std/json.zig+6-6
...@@ -2077,27 +2077,27 @@ pub const Parser = struct {...@@ -2077,27 +2077,27 @@ pub const Parser = struct {
2077 p.state = .ArrayValue;2077 p.state = .ArrayValue;
2078 },2078 },
2079 .String => |s| {2079 .String => |s| {
2080 _ = try object.put(key, try p.parseString(allocator, s, input, i));2080 try object.put(key, try p.parseString(allocator, s, input, i));
2081 _ = p.stack.pop();2081 _ = p.stack.pop();
2082 p.state = .ObjectKey;2082 p.state = .ObjectKey;
2083 },2083 },
2084 .Number => |n| {2084 .Number => |n| {
2085 _ = try object.put(key, try p.parseNumber(n, input, i));2085 try object.put(key, try p.parseNumber(n, input, i));
2086 _ = p.stack.pop();2086 _ = p.stack.pop();
2087 p.state = .ObjectKey;2087 p.state = .ObjectKey;
2088 },2088 },
2089 .True => {2089 .True => {
2090 _ = try object.put(key, Value{ .Bool = true });2090 try object.put(key, Value{ .Bool = true });
2091 _ = p.stack.pop();2091 _ = p.stack.pop();
2092 p.state = .ObjectKey;2092 p.state = .ObjectKey;
2093 },2093 },
2094 .False => {2094 .False => {
2095 _ = try object.put(key, Value{ .Bool = false });2095 try object.put(key, Value{ .Bool = false });
2096 _ = p.stack.pop();2096 _ = p.stack.pop();
2097 p.state = .ObjectKey;2097 p.state = .ObjectKey;
2098 },2098 },
2099 .Null => {2099 .Null => {
2100 _ = try object.put(key, Value.Null);2100 try object.put(key, Value.Null);
2101 _ = p.stack.pop();2101 _ = p.stack.pop();
2102 p.state = .ObjectKey;2102 p.state = .ObjectKey;
2103 },2103 },
...@@ -2184,7 +2184,7 @@ pub const Parser = struct {...@@ -2184,7 +2184,7 @@ pub const Parser = struct {
2184 _ = p.stack.pop();2184 _ = p.stack.pop();
21852185
2186 var object = &p.stack.items[p.stack.items.len - 1].Object;2186 var object = &p.stack.items[p.stack.items.len - 1].Object;
2187 _ = try object.put(key, value.*);2187 try object.put(key, value.*);
2188 p.state = .ObjectKey;2188 p.state = .ObjectKey;
2189 },2189 },
2190 // Array Parent -> [ ..., <array>, value ]2190 // Array Parent -> [ ..., <array>, value ]
lib/std/json/write_stream.zig+2-2
...@@ -293,7 +293,7 @@ test "json write stream" {...@@ -293,7 +293,7 @@ test "json write stream" {
293293
294fn getJsonObject(allocator: *std.mem.Allocator) !std.json.Value {294fn getJsonObject(allocator: *std.mem.Allocator) !std.json.Value {
295 var value = std.json.Value{ .Object = std.json.ObjectMap.init(allocator) };295 var value = std.json.Value{ .Object = std.json.ObjectMap.init(allocator) };
296 _ = try value.Object.put("one", std.json.Value{ .Integer = @intCast(i64, 1) });296 try value.Object.put("one", std.json.Value{ .Integer = @intCast(i64, 1) });
297 _ = try value.Object.put("two", std.json.Value{ .Float = 2.0 });297 try value.Object.put("two", std.json.Value{ .Float = 2.0 });
298 return value;298 return value;
299}299}
lib/std/priority_queue.zig+1-1
...@@ -410,7 +410,7 @@ test "std.PriorityQueue: iterator" {...@@ -410,7 +410,7 @@ test "std.PriorityQueue: iterator" {
410 const items = [_]u32{ 54, 12, 7, 23, 25, 13 };410 const items = [_]u32{ 54, 12, 7, 23, 25, 13 };
411 for (items) |e| {411 for (items) |e| {
412 _ = try queue.add(e);412 _ = try queue.add(e);
413 _ = try map.put(e, {});413 try map.put(e, {});
414 }414 }
415415
416 var it = queue.iterator();416 var it = queue.iterator();
src/link/Elf.zig+3-3
...@@ -2165,7 +2165,7 @@ pub fn freeDecl(self: *Elf, decl: *Module.Decl) void {...@@ -2165,7 +2165,7 @@ pub fn freeDecl(self: *Elf, decl: *Module.Decl) void {
2165 // is desired for both.2165 // is desired for both.
2166 _ = self.dbg_line_fn_free_list.remove(&decl.fn_link.elf);2166 _ = self.dbg_line_fn_free_list.remove(&decl.fn_link.elf);
2167 if (decl.fn_link.elf.prev) |prev| {2167 if (decl.fn_link.elf.prev) |prev| {
2168 _ = self.dbg_line_fn_free_list.put(self.base.allocator, prev, {}) catch {};2168 self.dbg_line_fn_free_list.put(self.base.allocator, prev, {}) catch {};
2169 prev.next = decl.fn_link.elf.next;2169 prev.next = decl.fn_link.elf.next;
2170 if (decl.fn_link.elf.next) |next| {2170 if (decl.fn_link.elf.next) |next| {
2171 next.prev = prev;2171 next.prev = prev;
...@@ -2423,7 +2423,7 @@ pub fn updateDecl(self: *Elf, module: *Module, decl: *Module.Decl) !void {...@@ -2423,7 +2423,7 @@ pub fn updateDecl(self: *Elf, module: *Module, decl: *Module.Decl) !void {
2423 if (src_fn.off + src_fn.len + min_nop_size > next.off) {2423 if (src_fn.off + src_fn.len + min_nop_size > next.off) {
2424 // It grew too big, so we move it to a new location.2424 // It grew too big, so we move it to a new location.
2425 if (src_fn.prev) |prev| {2425 if (src_fn.prev) |prev| {
2426 _ = self.dbg_line_fn_free_list.put(self.base.allocator, prev, {}) catch {};2426 self.dbg_line_fn_free_list.put(self.base.allocator, prev, {}) catch {};
2427 prev.next = src_fn.next;2427 prev.next = src_fn.next;
2428 }2428 }
2429 assert(src_fn.prev != next);2429 assert(src_fn.prev != next);
...@@ -2579,7 +2579,7 @@ fn updateDeclDebugInfoAllocation(self: *Elf, text_block: *TextBlock, len: u32) !...@@ -2579,7 +2579,7 @@ fn updateDeclDebugInfoAllocation(self: *Elf, text_block: *TextBlock, len: u32) !
2579 if (text_block.dbg_info_off + text_block.dbg_info_len + min_nop_size > next.dbg_info_off) {2579 if (text_block.dbg_info_off + text_block.dbg_info_len + min_nop_size > next.dbg_info_off) {
2580 // It grew too big, so we move it to a new location.2580 // It grew too big, so we move it to a new location.
2581 if (text_block.dbg_info_prev) |prev| {2581 if (text_block.dbg_info_prev) |prev| {
2582 _ = self.dbg_info_decl_free_list.put(self.base.allocator, prev, {}) catch {};2582 self.dbg_info_decl_free_list.put(self.base.allocator, prev, {}) catch {};
2583 prev.dbg_info_next = text_block.dbg_info_next;2583 prev.dbg_info_next = text_block.dbg_info_next;
2584 }2584 }
2585 next.dbg_info_prev = text_block.dbg_info_prev;2585 next.dbg_info_prev = text_block.dbg_info_prev;
src/link/MachO/DebugSymbols.zig+2-2
...@@ -1096,7 +1096,7 @@ pub fn commitDeclDebugInfo(...@@ -1096,7 +1096,7 @@ pub fn commitDeclDebugInfo(
1096 if (src_fn.off + src_fn.len + min_nop_size > next.off) {1096 if (src_fn.off + src_fn.len + min_nop_size > next.off) {
1097 // It grew too big, so we move it to a new location.1097 // It grew too big, so we move it to a new location.
1098 if (src_fn.prev) |prev| {1098 if (src_fn.prev) |prev| {
1099 _ = self.dbg_line_fn_free_list.put(allocator, prev, {}) catch {};1099 self.dbg_line_fn_free_list.put(allocator, prev, {}) catch {};
1100 prev.next = src_fn.next;1100 prev.next = src_fn.next;
1101 }1101 }
1102 next.prev = src_fn.prev;1102 next.prev = src_fn.prev;
...@@ -1256,7 +1256,7 @@ fn updateDeclDebugInfoAllocation(...@@ -1256,7 +1256,7 @@ fn updateDeclDebugInfoAllocation(
1256 if (text_block.dbg_info_off + text_block.dbg_info_len + min_nop_size > next.dbg_info_off) {1256 if (text_block.dbg_info_off + text_block.dbg_info_len + min_nop_size > next.dbg_info_off) {
1257 // It grew too big, so we move it to a new location.1257 // It grew too big, so we move it to a new location.
1258 if (text_block.dbg_info_prev) |prev| {1258 if (text_block.dbg_info_prev) |prev| {
1259 _ = self.dbg_info_decl_free_list.put(allocator, prev, {}) catch {};1259 self.dbg_info_decl_free_list.put(allocator, prev, {}) catch {};
1260 prev.dbg_info_next = text_block.dbg_info_next;1260 prev.dbg_info_next = text_block.dbg_info_next;
1261 }1261 }
1262 next.dbg_info_prev = text_block.dbg_info_prev;1262 next.dbg_info_prev = text_block.dbg_info_prev;
src/liveness.zig+2-2
...@@ -119,7 +119,7 @@ fn analyzeInst(...@@ -119,7 +119,7 @@ fn analyzeInst(
119 if (!else_table.contains(then_death)) {119 if (!else_table.contains(then_death)) {
120 try else_entry_deaths.append(then_death);120 try else_entry_deaths.append(then_death);
121 }121 }
122 _ = try table.put(then_death, {});122 try table.put(then_death, {});
123 }123 }
124 }124 }
125 // Now we have to correctly populate new_set.125 // Now we have to correctly populate new_set.
...@@ -195,7 +195,7 @@ fn analyzeInst(...@@ -195,7 +195,7 @@ fn analyzeInst(
195 }195 }
196 }196 }
197 // undo resetting the table197 // undo resetting the table
198 _ = try table.put(case_death, {});198 try table.put(case_death, {});
199 }199 }
200 }200 }
201201
src/translate_c.zig+10-10
...@@ -377,7 +377,7 @@ fn prepopulateGlobalNameTable(ast_unit: *clang.ASTUnit, c: *Context) !void {...@@ -377,7 +377,7 @@ fn prepopulateGlobalNameTable(ast_unit: *clang.ASTUnit, c: *Context) !void {
377 const macro = @ptrCast(*clang.MacroDefinitionRecord, entity);377 const macro = @ptrCast(*clang.MacroDefinitionRecord, entity);
378 const raw_name = macro.getName_getNameStart();378 const raw_name = macro.getName_getNameStart();
379 const name = try c.str(raw_name);379 const name = try c.str(raw_name);
380 _ = try c.global_names.put(c.gpa, name, {});380 try c.global_names.put(c.gpa, name, {});
381 },381 },
382 else => {},382 else => {},
383 }383 }
...@@ -399,7 +399,7 @@ fn declVisitorC(context: ?*c_void, decl: *const clang.Decl) callconv(.C) bool {...@@ -399,7 +399,7 @@ fn declVisitorC(context: ?*c_void, decl: *const clang.Decl) callconv(.C) bool {
399fn declVisitorNamesOnly(c: *Context, decl: *const clang.Decl) Error!void {399fn declVisitorNamesOnly(c: *Context, decl: *const clang.Decl) Error!void {
400 if (decl.castToNamedDecl()) |named_decl| {400 if (decl.castToNamedDecl()) |named_decl| {
401 const decl_name = try c.str(named_decl.getName_bytes_begin());401 const decl_name = try c.str(named_decl.getName_bytes_begin());
402 _ = try c.global_names.put(c.gpa, decl_name, {});402 try c.global_names.put(c.gpa, decl_name, {});
403 }403 }
404}404}
405405
...@@ -788,7 +788,7 @@ fn transRecordDecl(c: *Context, scope: *Scope, record_decl: *const clang.RecordD...@@ -788,7 +788,7 @@ fn transRecordDecl(c: *Context, scope: *Scope, record_decl: *const clang.RecordD
788 const is_pub = toplevel and !is_unnamed;788 const is_pub = toplevel and !is_unnamed;
789 const init_node = blk: {789 const init_node = blk: {
790 const record_def = record_decl.getDefinition() orelse {790 const record_def = record_decl.getDefinition() orelse {
791 _ = try c.opaque_demotes.put(c.gpa, @ptrToInt(record_decl.getCanonicalDecl()), {});791 try c.opaque_demotes.put(c.gpa, @ptrToInt(record_decl.getCanonicalDecl()), {});
792 break :blk Tag.opaque_literal.init();792 break :blk Tag.opaque_literal.init();
793 };793 };
794794
...@@ -805,13 +805,13 @@ fn transRecordDecl(c: *Context, scope: *Scope, record_decl: *const clang.RecordD...@@ -805,13 +805,13 @@ fn transRecordDecl(c: *Context, scope: *Scope, record_decl: *const clang.RecordD
805 const field_qt = field_decl.getType();805 const field_qt = field_decl.getType();
806806
807 if (field_decl.isBitField()) {807 if (field_decl.isBitField()) {
808 _ = try c.opaque_demotes.put(c.gpa, @ptrToInt(record_decl.getCanonicalDecl()), {});808 try c.opaque_demotes.put(c.gpa, @ptrToInt(record_decl.getCanonicalDecl()), {});
809 try warn(c, scope, field_loc, "{s} demoted to opaque type - has bitfield", .{container_kind_name});809 try warn(c, scope, field_loc, "{s} demoted to opaque type - has bitfield", .{container_kind_name});
810 break :blk Tag.opaque_literal.init();810 break :blk Tag.opaque_literal.init();
811 }811 }
812812
813 if (qualTypeCanon(field_qt).isIncompleteOrZeroLengthArrayType(c.clang_context)) {813 if (qualTypeCanon(field_qt).isIncompleteOrZeroLengthArrayType(c.clang_context)) {
814 _ = try c.opaque_demotes.put(c.gpa, @ptrToInt(record_decl.getCanonicalDecl()), {});814 try c.opaque_demotes.put(c.gpa, @ptrToInt(record_decl.getCanonicalDecl()), {});
815 try warn(c, scope, field_loc, "{s} demoted to opaque type - has variable length array", .{container_kind_name});815 try warn(c, scope, field_loc, "{s} demoted to opaque type - has variable length array", .{container_kind_name});
816 break :blk Tag.opaque_literal.init();816 break :blk Tag.opaque_literal.init();
817 }817 }
...@@ -826,7 +826,7 @@ fn transRecordDecl(c: *Context, scope: *Scope, record_decl: *const clang.RecordD...@@ -826,7 +826,7 @@ fn transRecordDecl(c: *Context, scope: *Scope, record_decl: *const clang.RecordD
826 }826 }
827 const field_type = transQualType(c, scope, field_qt, field_loc) catch |err| switch (err) {827 const field_type = transQualType(c, scope, field_qt, field_loc) catch |err| switch (err) {
828 error.UnsupportedType => {828 error.UnsupportedType => {
829 _ = try c.opaque_demotes.put(c.gpa, @ptrToInt(record_decl.getCanonicalDecl()), {});829 try c.opaque_demotes.put(c.gpa, @ptrToInt(record_decl.getCanonicalDecl()), {});
830 try warn(c, scope, record_loc, "{s} demoted to opaque type - unable to translate type of field {s}", .{ container_kind_name, field_name });830 try warn(c, scope, record_loc, "{s} demoted to opaque type - unable to translate type of field {s}", .{ container_kind_name, field_name });
831 break :blk Tag.opaque_literal.init();831 break :blk Tag.opaque_literal.init();
832 },832 },
...@@ -972,7 +972,7 @@ fn transEnumDecl(c: *Context, scope: *Scope, enum_decl: *const clang.EnumDecl) E...@@ -972,7 +972,7 @@ fn transEnumDecl(c: *Context, scope: *Scope, enum_decl: *const clang.EnumDecl) E
972 .fields = try c.arena.dupe(ast.Payload.Enum.Field, fields.items),972 .fields = try c.arena.dupe(ast.Payload.Enum.Field, fields.items),
973 });973 });
974 } else blk: {974 } else blk: {
975 _ = try c.opaque_demotes.put(c.gpa, @ptrToInt(enum_decl.getCanonicalDecl()), {});975 try c.opaque_demotes.put(c.gpa, @ptrToInt(enum_decl.getCanonicalDecl()), {});
976 break :blk Tag.opaque_literal.init();976 break :blk Tag.opaque_literal.init();
977 };977 };
978978
...@@ -3199,7 +3199,7 @@ fn maybeSuppressResult(...@@ -3199,7 +3199,7 @@ fn maybeSuppressResult(
3199}3199}
32003200
3201fn addTopLevelDecl(c: *Context, name: []const u8, decl_node: Node) !void {3201fn addTopLevelDecl(c: *Context, name: []const u8, decl_node: Node) !void {
3202 _ = try c.global_scope.sym_table.put(name, decl_node);3202 try c.global_scope.sym_table.put(name, decl_node);
3203 try c.global_scope.nodes.append(decl_node);3203 try c.global_scope.nodes.append(decl_node);
3204}3204}
32053205
...@@ -4235,7 +4235,7 @@ fn transMacroDefine(c: *Context, m: *MacroCtx) ParseError!void {...@@ -4235,7 +4235,7 @@ fn transMacroDefine(c: *Context, m: *MacroCtx) ParseError!void {
4235 return m.fail(c, "unable to translate C expr: unexpected token .{s}", .{@tagName(last)});4235 return m.fail(c, "unable to translate C expr: unexpected token .{s}", .{@tagName(last)});
42364236
4237 const var_decl = try Tag.pub_var_simple.create(c.arena, .{ .name = m.name, .init = init_node });4237 const var_decl = try Tag.pub_var_simple.create(c.arena, .{ .name = m.name, .init = init_node });
4238 _ = try c.global_scope.macro_table.put(m.name, var_decl);4238 try c.global_scope.macro_table.put(m.name, var_decl);
4239}4239}
42404240
4241fn transMacroFnDefine(c: *Context, m: *MacroCtx) ParseError!void {4241fn transMacroFnDefine(c: *Context, m: *MacroCtx) ParseError!void {
...@@ -4294,7 +4294,7 @@ fn transMacroFnDefine(c: *Context, m: *MacroCtx) ParseError!void {...@@ -4294,7 +4294,7 @@ fn transMacroFnDefine(c: *Context, m: *MacroCtx) ParseError!void {
4294 .return_type = return_type,4294 .return_type = return_type,
4295 .body = try block_scope.complete(c),4295 .body = try block_scope.complete(c),
4296 });4296 });
4297 _ = try c.global_scope.macro_table.put(m.name, fn_decl);4297 try c.global_scope.macro_table.put(m.name, fn_decl);
4298}4298}
42994299
4300const ParseError = Error || error{ParseError};4300const ParseError = Error || error{ParseError};
tools/update_glibc.zig+2-2
...@@ -200,7 +200,7 @@ pub fn main() !void {...@@ -200,7 +200,7 @@ pub fn main() !void {
200 continue;200 continue;
201 }201 }
202 if (std.mem.startsWith(u8, ver, "GCC_")) continue;202 if (std.mem.startsWith(u8, ver, "GCC_")) continue;
203 _ = try global_ver_set.put(ver, undefined);203 try global_ver_set.put(ver, undefined);
204 const gop = try global_fn_set.getOrPut(name);204 const gop = try global_fn_set.getOrPut(name);
205 if (gop.found_existing) {205 if (gop.found_existing) {
206 if (!std.mem.eql(u8, gop.entry.value.lib, "c")) {206 if (!std.mem.eql(u8, gop.entry.value.lib, "c")) {
...@@ -242,7 +242,7 @@ pub fn main() !void {...@@ -242,7 +242,7 @@ pub fn main() !void {
242 var buffered = std.io.bufferedWriter(vers_txt_file.writer());242 var buffered = std.io.bufferedWriter(vers_txt_file.writer());
243 const vers_txt = buffered.writer();243 const vers_txt = buffered.writer();
244 for (global_ver_list) |name, i| {244 for (global_ver_list) |name, i| {
245 _ = global_ver_set.put(name, i) catch unreachable;245 global_ver_set.put(name, i) catch unreachable;
246 try vers_txt.print("{s}\n", .{name});246 try vers_txt.print("{s}\n", .{name});
247 }247 }
248 try buffered.flush();248 try buffered.flush();