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 {
3232 if (self.hash_map.get(key) == null) {
3333 const key_copy = try self.copy(key);
3434 errdefer self.free(key_copy);
35 _ = try self.hash_map.put(key_copy, {});
35 try self.hash_map.put(key_copy, {});
3636 }
3737 }
3838
lib/std/build.zig+2-2
......@@ -790,7 +790,7 @@ pub const Builder = struct {
790790 var list = ArrayList([]const u8).init(self.allocator);
791791 list.append(s) catch unreachable;
792792 list.append(value) catch unreachable;
793 _ = self.user_input_options.put(name, UserInputOption{
793 self.user_input_options.put(name, UserInputOption{
794794 .name = name,
795795 .value = UserValue{ .List = list },
796796 .used = false,
......@@ -799,7 +799,7 @@ pub const Builder = struct {
799799 UserValue.List => |*list| {
800800 // append to the list
801801 list.append(value) catch unreachable;
802 _ = self.user_input_options.put(name, UserInputOption{
802 self.user_input_options.put(name, UserInputOption{
803803 .name = name,
804804 .value = UserValue{ .List = list.* },
805805 .used = false,
lib/std/hash_map.zig+1-2
......@@ -563,7 +563,6 @@ pub fn HashMapUnmanaged(
563563 }
564564
565565 /// Insert an entry if the associated key is not already present, otherwise update preexisting value.
566 /// Returns true if the key was already present.
567566 pub fn put(self: *Self, allocator: *Allocator, key: K, value: V) !void {
568567 const result = try self.getOrPut(allocator, key);
569568 result.entry.value = value;
......@@ -1116,7 +1115,7 @@ test "std.hash_map put" {
11161115
11171116 var i: u32 = 0;
11181117 while (i < 16) : (i += 1) {
1119 _ = try map.put(i, i);
1118 try map.put(i, i);
11201119 }
11211120
11221121 i = 0;
lib/std/json.zig+6-6
......@@ -2077,27 +2077,27 @@ pub const Parser = struct {
20772077 p.state = .ArrayValue;
20782078 },
20792079 .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));
20812081 _ = p.stack.pop();
20822082 p.state = .ObjectKey;
20832083 },
20842084 .Number => |n| {
2085 _ = try object.put(key, try p.parseNumber(n, input, i));
2085 try object.put(key, try p.parseNumber(n, input, i));
20862086 _ = p.stack.pop();
20872087 p.state = .ObjectKey;
20882088 },
20892089 .True => {
2090 _ = try object.put(key, Value{ .Bool = true });
2090 try object.put(key, Value{ .Bool = true });
20912091 _ = p.stack.pop();
20922092 p.state = .ObjectKey;
20932093 },
20942094 .False => {
2095 _ = try object.put(key, Value{ .Bool = false });
2095 try object.put(key, Value{ .Bool = false });
20962096 _ = p.stack.pop();
20972097 p.state = .ObjectKey;
20982098 },
20992099 .Null => {
2100 _ = try object.put(key, Value.Null);
2100 try object.put(key, Value.Null);
21012101 _ = p.stack.pop();
21022102 p.state = .ObjectKey;
21032103 },
......@@ -2184,7 +2184,7 @@ pub const Parser = struct {
21842184 _ = p.stack.pop();
21852185
21862186 var object = &p.stack.items[p.stack.items.len - 1].Object;
2187 _ = try object.put(key, value.*);
2187 try object.put(key, value.*);
21882188 p.state = .ObjectKey;
21892189 },
21902190 // Array Parent -> [ ..., <array>, value ]
lib/std/json/write_stream.zig+2-2
......@@ -293,7 +293,7 @@ test "json write stream" {
293293
294294fn getJsonObject(allocator: *std.mem.Allocator) !std.json.Value {
295295 var value = std.json.Value{ .Object = std.json.ObjectMap.init(allocator) };
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 });
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 });
298298 return value;
299299}
lib/std/priority_queue.zig+1-1
......@@ -410,7 +410,7 @@ test "std.PriorityQueue: iterator" {
410410 const items = [_]u32{ 54, 12, 7, 23, 25, 13 };
411411 for (items) |e| {
412412 _ = try queue.add(e);
413 _ = try map.put(e, {});
413 try map.put(e, {});
414414 }
415415
416416 var it = queue.iterator();
src/link/Elf.zig+3-3
......@@ -2165,7 +2165,7 @@ pub fn freeDecl(self: *Elf, decl: *Module.Decl) void {
21652165 // is desired for both.
21662166 _ = self.dbg_line_fn_free_list.remove(&decl.fn_link.elf);
21672167 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 {};
21692169 prev.next = decl.fn_link.elf.next;
21702170 if (decl.fn_link.elf.next) |next| {
21712171 next.prev = prev;
......@@ -2423,7 +2423,7 @@ pub fn updateDecl(self: *Elf, module: *Module, decl: *Module.Decl) !void {
24232423 if (src_fn.off + src_fn.len + min_nop_size > next.off) {
24242424 // It grew too big, so we move it to a new location.
24252425 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 {};
24272427 prev.next = src_fn.next;
24282428 }
24292429 assert(src_fn.prev != next);
......@@ -2579,7 +2579,7 @@ fn updateDeclDebugInfoAllocation(self: *Elf, text_block: *TextBlock, len: u32) !
25792579 if (text_block.dbg_info_off + text_block.dbg_info_len + min_nop_size > next.dbg_info_off) {
25802580 // It grew too big, so we move it to a new location.
25812581 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 {};
25832583 prev.dbg_info_next = text_block.dbg_info_next;
25842584 }
25852585 next.dbg_info_prev = text_block.dbg_info_prev;
src/link/MachO/DebugSymbols.zig+2-2
......@@ -1096,7 +1096,7 @@ pub fn commitDeclDebugInfo(
10961096 if (src_fn.off + src_fn.len + min_nop_size > next.off) {
10971097 // It grew too big, so we move it to a new location.
10981098 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 {};
11001100 prev.next = src_fn.next;
11011101 }
11021102 next.prev = src_fn.prev;
......@@ -1256,7 +1256,7 @@ fn updateDeclDebugInfoAllocation(
12561256 if (text_block.dbg_info_off + text_block.dbg_info_len + min_nop_size > next.dbg_info_off) {
12571257 // It grew too big, so we move it to a new location.
12581258 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 {};
12601260 prev.dbg_info_next = text_block.dbg_info_next;
12611261 }
12621262 next.dbg_info_prev = text_block.dbg_info_prev;
src/liveness.zig+2-2
......@@ -119,7 +119,7 @@ fn analyzeInst(
119119 if (!else_table.contains(then_death)) {
120120 try else_entry_deaths.append(then_death);
121121 }
122 _ = try table.put(then_death, {});
122 try table.put(then_death, {});
123123 }
124124 }
125125 // Now we have to correctly populate new_set.
......@@ -195,7 +195,7 @@ fn analyzeInst(
195195 }
196196 }
197197 // undo resetting the table
198 _ = try table.put(case_death, {});
198 try table.put(case_death, {});
199199 }
200200 }
201201
src/translate_c.zig+10-10
......@@ -377,7 +377,7 @@ fn prepopulateGlobalNameTable(ast_unit: *clang.ASTUnit, c: *Context) !void {
377377 const macro = @ptrCast(*clang.MacroDefinitionRecord, entity);
378378 const raw_name = macro.getName_getNameStart();
379379 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, {});
381381 },
382382 else => {},
383383 }
......@@ -399,7 +399,7 @@ fn declVisitorC(context: ?*c_void, decl: *const clang.Decl) callconv(.C) bool {
399399fn declVisitorNamesOnly(c: *Context, decl: *const clang.Decl) Error!void {
400400 if (decl.castToNamedDecl()) |named_decl| {
401401 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, {});
403403 }
404404}
405405
......@@ -788,7 +788,7 @@ fn transRecordDecl(c: *Context, scope: *Scope, record_decl: *const clang.RecordD
788788 const is_pub = toplevel and !is_unnamed;
789789 const init_node = blk: {
790790 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()), {});
792792 break :blk Tag.opaque_literal.init();
793793 };
794794
......@@ -805,13 +805,13 @@ fn transRecordDecl(c: *Context, scope: *Scope, record_decl: *const clang.RecordD
805805 const field_qt = field_decl.getType();
806806
807807 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()), {});
809809 try warn(c, scope, field_loc, "{s} demoted to opaque type - has bitfield", .{container_kind_name});
810810 break :blk Tag.opaque_literal.init();
811811 }
812812
813813 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()), {});
815815 try warn(c, scope, field_loc, "{s} demoted to opaque type - has variable length array", .{container_kind_name});
816816 break :blk Tag.opaque_literal.init();
817817 }
......@@ -826,7 +826,7 @@ fn transRecordDecl(c: *Context, scope: *Scope, record_decl: *const clang.RecordD
826826 }
827827 const field_type = transQualType(c, scope, field_qt, field_loc) catch |err| switch (err) {
828828 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()), {});
830830 try warn(c, scope, record_loc, "{s} demoted to opaque type - unable to translate type of field {s}", .{ container_kind_name, field_name });
831831 break :blk Tag.opaque_literal.init();
832832 },
......@@ -972,7 +972,7 @@ fn transEnumDecl(c: *Context, scope: *Scope, enum_decl: *const clang.EnumDecl) E
972972 .fields = try c.arena.dupe(ast.Payload.Enum.Field, fields.items),
973973 });
974974 } 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()), {});
976976 break :blk Tag.opaque_literal.init();
977977 };
978978
......@@ -3199,7 +3199,7 @@ fn maybeSuppressResult(
31993199}
32003200
32013201fn 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);
32033203 try c.global_scope.nodes.append(decl_node);
32043204}
32053205
......@@ -4235,7 +4235,7 @@ fn transMacroDefine(c: *Context, m: *MacroCtx) ParseError!void {
42354235 return m.fail(c, "unable to translate C expr: unexpected token .{s}", .{@tagName(last)});
42364236
42374237 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);
42394239}
42404240
42414241fn transMacroFnDefine(c: *Context, m: *MacroCtx) ParseError!void {
......@@ -4294,7 +4294,7 @@ fn transMacroFnDefine(c: *Context, m: *MacroCtx) ParseError!void {
42944294 .return_type = return_type,
42954295 .body = try block_scope.complete(c),
42964296 });
4297 _ = try c.global_scope.macro_table.put(m.name, fn_decl);
4297 try c.global_scope.macro_table.put(m.name, fn_decl);
42984298}
42994299
43004300const ParseError = Error || error{ParseError};
tools/update_glibc.zig+2-2
......@@ -200,7 +200,7 @@ pub fn main() !void {
200200 continue;
201201 }
202202 if (std.mem.startsWith(u8, ver, "GCC_")) continue;
203 _ = try global_ver_set.put(ver, undefined);
203 try global_ver_set.put(ver, undefined);
204204 const gop = try global_fn_set.getOrPut(name);
205205 if (gop.found_existing) {
206206 if (!std.mem.eql(u8, gop.entry.value.lib, "c")) {
......@@ -242,7 +242,7 @@ pub fn main() !void {
242242 var buffered = std.io.bufferedWriter(vers_txt_file.writer());
243243 const vers_txt = buffered.writer();
244244 for (global_ver_list) |name, i| {
245 _ = global_ver_set.put(name, i) catch unreachable;
245 global_ver_set.put(name, i) catch unreachable;
246246 try vers_txt.print("{s}\n", .{name});
247247 }
248248 try buffered.flush();