From d4af35b3fe42a7ad5b808012b15d479526140730 Mon Sep 17 00:00:00 2001 From: daurnimator Date: Sat, 27 Feb 2021 13:49:02 +1100 Subject: [PATCH] HashMap.put returns !void, not a !bool --- lib/std/buf_set.zig | 2 +- lib/std/build.zig | 4 ++-- lib/std/hash_map.zig | 3 +-- lib/std/json.zig | 12 ++++++------ lib/std/json/write_stream.zig | 4 ++-- lib/std/priority_queue.zig | 2 +- src/link/Elf.zig | 6 +++--- src/link/MachO/DebugSymbols.zig | 4 ++-- src/liveness.zig | 4 ++-- src/translate_c.zig | 20 ++++++++++---------- tools/update_glibc.zig | 4 ++-- 11 files changed, 32 insertions(+), 33 deletions(-) diff --git a/lib/std/buf_set.zig b/lib/std/buf_set.zig index 75c5ae742d..e59dc9841b 100644 --- a/lib/std/buf_set.zig +++ b/lib/std/buf_set.zig @@ -32,7 +32,7 @@ pub const BufSet = struct { if (self.hash_map.get(key) == null) { const key_copy = try self.copy(key); errdefer self.free(key_copy); - _ = try self.hash_map.put(key_copy, {}); + try self.hash_map.put(key_copy, {}); } } diff --git a/lib/std/build.zig b/lib/std/build.zig index e11402e493..efeea4adb7 100644 --- a/lib/std/build.zig +++ b/lib/std/build.zig @@ -790,7 +790,7 @@ pub const Builder = struct { var list = ArrayList([]const u8).init(self.allocator); list.append(s) catch unreachable; list.append(value) catch unreachable; - _ = self.user_input_options.put(name, UserInputOption{ + self.user_input_options.put(name, UserInputOption{ .name = name, .value = UserValue{ .List = list }, .used = false, @@ -799,7 +799,7 @@ pub const Builder = struct { UserValue.List => |*list| { // append to the list list.append(value) catch unreachable; - _ = self.user_input_options.put(name, UserInputOption{ + self.user_input_options.put(name, UserInputOption{ .name = name, .value = UserValue{ .List = list.* }, .used = false, diff --git a/lib/std/hash_map.zig b/lib/std/hash_map.zig index 679575875d..e2e0f056e1 100644 --- a/lib/std/hash_map.zig +++ b/lib/std/hash_map.zig @@ -563,7 +563,6 @@ pub fn HashMapUnmanaged( } /// Insert an entry if the associated key is not already present, otherwise update preexisting value. - /// Returns true if the key was already present. pub fn put(self: *Self, allocator: *Allocator, key: K, value: V) !void { const result = try self.getOrPut(allocator, key); result.entry.value = value; @@ -1116,7 +1115,7 @@ test "std.hash_map put" { var i: u32 = 0; while (i < 16) : (i += 1) { - _ = try map.put(i, i); + try map.put(i, i); } i = 0; diff --git a/lib/std/json.zig b/lib/std/json.zig index f9fc371049..96ad066db3 100644 --- a/lib/std/json.zig +++ b/lib/std/json.zig @@ -2077,27 +2077,27 @@ pub const Parser = struct { p.state = .ArrayValue; }, .String => |s| { - _ = try object.put(key, try p.parseString(allocator, s, input, i)); + try object.put(key, try p.parseString(allocator, s, input, i)); _ = p.stack.pop(); p.state = .ObjectKey; }, .Number => |n| { - _ = try object.put(key, try p.parseNumber(n, input, i)); + try object.put(key, try p.parseNumber(n, input, i)); _ = p.stack.pop(); p.state = .ObjectKey; }, .True => { - _ = try object.put(key, Value{ .Bool = true }); + try object.put(key, Value{ .Bool = true }); _ = p.stack.pop(); p.state = .ObjectKey; }, .False => { - _ = try object.put(key, Value{ .Bool = false }); + try object.put(key, Value{ .Bool = false }); _ = p.stack.pop(); p.state = .ObjectKey; }, .Null => { - _ = try object.put(key, Value.Null); + try object.put(key, Value.Null); _ = p.stack.pop(); p.state = .ObjectKey; }, @@ -2184,7 +2184,7 @@ pub const Parser = struct { _ = p.stack.pop(); var object = &p.stack.items[p.stack.items.len - 1].Object; - _ = try object.put(key, value.*); + try object.put(key, value.*); p.state = .ObjectKey; }, // Array Parent -> [ ..., , value ] diff --git a/lib/std/json/write_stream.zig b/lib/std/json/write_stream.zig index b4a8aed84c..1cff0ed2b7 100644 --- a/lib/std/json/write_stream.zig +++ b/lib/std/json/write_stream.zig @@ -293,7 +293,7 @@ test "json write stream" { fn getJsonObject(allocator: *std.mem.Allocator) !std.json.Value { var value = std.json.Value{ .Object = std.json.ObjectMap.init(allocator) }; - _ = try value.Object.put("one", std.json.Value{ .Integer = @intCast(i64, 1) }); - _ = try value.Object.put("two", std.json.Value{ .Float = 2.0 }); + try value.Object.put("one", std.json.Value{ .Integer = @intCast(i64, 1) }); + try value.Object.put("two", std.json.Value{ .Float = 2.0 }); return value; } diff --git a/lib/std/priority_queue.zig b/lib/std/priority_queue.zig index f5c01edff5..ff671c9ff7 100644 --- a/lib/std/priority_queue.zig +++ b/lib/std/priority_queue.zig @@ -410,7 +410,7 @@ test "std.PriorityQueue: iterator" { const items = [_]u32{ 54, 12, 7, 23, 25, 13 }; for (items) |e| { _ = try queue.add(e); - _ = try map.put(e, {}); + try map.put(e, {}); } var it = queue.iterator(); diff --git a/src/link/Elf.zig b/src/link/Elf.zig index e1a6a1dff1..1b6fbb0f0f 100644 --- a/src/link/Elf.zig +++ b/src/link/Elf.zig @@ -2165,7 +2165,7 @@ pub fn freeDecl(self: *Elf, decl: *Module.Decl) void { // is desired for both. _ = self.dbg_line_fn_free_list.remove(&decl.fn_link.elf); if (decl.fn_link.elf.prev) |prev| { - _ = self.dbg_line_fn_free_list.put(self.base.allocator, prev, {}) catch {}; + self.dbg_line_fn_free_list.put(self.base.allocator, prev, {}) catch {}; prev.next = decl.fn_link.elf.next; if (decl.fn_link.elf.next) |next| { next.prev = prev; @@ -2423,7 +2423,7 @@ pub fn updateDecl(self: *Elf, module: *Module, decl: *Module.Decl) !void { if (src_fn.off + src_fn.len + min_nop_size > next.off) { // It grew too big, so we move it to a new location. if (src_fn.prev) |prev| { - _ = self.dbg_line_fn_free_list.put(self.base.allocator, prev, {}) catch {}; + self.dbg_line_fn_free_list.put(self.base.allocator, prev, {}) catch {}; prev.next = src_fn.next; } assert(src_fn.prev != next); @@ -2579,7 +2579,7 @@ fn updateDeclDebugInfoAllocation(self: *Elf, text_block: *TextBlock, len: u32) ! if (text_block.dbg_info_off + text_block.dbg_info_len + min_nop_size > next.dbg_info_off) { // It grew too big, so we move it to a new location. if (text_block.dbg_info_prev) |prev| { - _ = self.dbg_info_decl_free_list.put(self.base.allocator, prev, {}) catch {}; + self.dbg_info_decl_free_list.put(self.base.allocator, prev, {}) catch {}; prev.dbg_info_next = text_block.dbg_info_next; } next.dbg_info_prev = text_block.dbg_info_prev; diff --git a/src/link/MachO/DebugSymbols.zig b/src/link/MachO/DebugSymbols.zig index 645e17068b..042c1a12cf 100644 --- a/src/link/MachO/DebugSymbols.zig +++ b/src/link/MachO/DebugSymbols.zig @@ -1096,7 +1096,7 @@ pub fn commitDeclDebugInfo( if (src_fn.off + src_fn.len + min_nop_size > next.off) { // It grew too big, so we move it to a new location. if (src_fn.prev) |prev| { - _ = self.dbg_line_fn_free_list.put(allocator, prev, {}) catch {}; + self.dbg_line_fn_free_list.put(allocator, prev, {}) catch {}; prev.next = src_fn.next; } next.prev = src_fn.prev; @@ -1256,7 +1256,7 @@ fn updateDeclDebugInfoAllocation( if (text_block.dbg_info_off + text_block.dbg_info_len + min_nop_size > next.dbg_info_off) { // It grew too big, so we move it to a new location. if (text_block.dbg_info_prev) |prev| { - _ = self.dbg_info_decl_free_list.put(allocator, prev, {}) catch {}; + self.dbg_info_decl_free_list.put(allocator, prev, {}) catch {}; prev.dbg_info_next = text_block.dbg_info_next; } next.dbg_info_prev = text_block.dbg_info_prev; diff --git a/src/liveness.zig b/src/liveness.zig index b0aafa28f1..d652e7e954 100644 --- a/src/liveness.zig +++ b/src/liveness.zig @@ -119,7 +119,7 @@ fn analyzeInst( if (!else_table.contains(then_death)) { try else_entry_deaths.append(then_death); } - _ = try table.put(then_death, {}); + try table.put(then_death, {}); } } // Now we have to correctly populate new_set. @@ -195,7 +195,7 @@ fn analyzeInst( } } // undo resetting the table - _ = try table.put(case_death, {}); + try table.put(case_death, {}); } } diff --git a/src/translate_c.zig b/src/translate_c.zig index e82583bd07..170e6ef2e1 100644 --- a/src/translate_c.zig +++ b/src/translate_c.zig @@ -377,7 +377,7 @@ fn prepopulateGlobalNameTable(ast_unit: *clang.ASTUnit, c: *Context) !void { const macro = @ptrCast(*clang.MacroDefinitionRecord, entity); const raw_name = macro.getName_getNameStart(); const name = try c.str(raw_name); - _ = try c.global_names.put(c.gpa, name, {}); + try c.global_names.put(c.gpa, name, {}); }, else => {}, } @@ -399,7 +399,7 @@ fn declVisitorC(context: ?*c_void, decl: *const clang.Decl) callconv(.C) bool { fn declVisitorNamesOnly(c: *Context, decl: *const clang.Decl) Error!void { if (decl.castToNamedDecl()) |named_decl| { const decl_name = try c.str(named_decl.getName_bytes_begin()); - _ = try c.global_names.put(c.gpa, decl_name, {}); + try c.global_names.put(c.gpa, decl_name, {}); } } @@ -788,7 +788,7 @@ fn transRecordDecl(c: *Context, scope: *Scope, record_decl: *const clang.RecordD const is_pub = toplevel and !is_unnamed; const init_node = blk: { const record_def = record_decl.getDefinition() orelse { - _ = try c.opaque_demotes.put(c.gpa, @ptrToInt(record_decl.getCanonicalDecl()), {}); + try c.opaque_demotes.put(c.gpa, @ptrToInt(record_decl.getCanonicalDecl()), {}); break :blk Tag.opaque_literal.init(); }; @@ -805,13 +805,13 @@ fn transRecordDecl(c: *Context, scope: *Scope, record_decl: *const clang.RecordD const field_qt = field_decl.getType(); if (field_decl.isBitField()) { - _ = try c.opaque_demotes.put(c.gpa, @ptrToInt(record_decl.getCanonicalDecl()), {}); + try c.opaque_demotes.put(c.gpa, @ptrToInt(record_decl.getCanonicalDecl()), {}); try warn(c, scope, field_loc, "{s} demoted to opaque type - has bitfield", .{container_kind_name}); break :blk Tag.opaque_literal.init(); } if (qualTypeCanon(field_qt).isIncompleteOrZeroLengthArrayType(c.clang_context)) { - _ = try c.opaque_demotes.put(c.gpa, @ptrToInt(record_decl.getCanonicalDecl()), {}); + try c.opaque_demotes.put(c.gpa, @ptrToInt(record_decl.getCanonicalDecl()), {}); try warn(c, scope, field_loc, "{s} demoted to opaque type - has variable length array", .{container_kind_name}); break :blk Tag.opaque_literal.init(); } @@ -826,7 +826,7 @@ fn transRecordDecl(c: *Context, scope: *Scope, record_decl: *const clang.RecordD } const field_type = transQualType(c, scope, field_qt, field_loc) catch |err| switch (err) { error.UnsupportedType => { - _ = try c.opaque_demotes.put(c.gpa, @ptrToInt(record_decl.getCanonicalDecl()), {}); + try c.opaque_demotes.put(c.gpa, @ptrToInt(record_decl.getCanonicalDecl()), {}); try warn(c, scope, record_loc, "{s} demoted to opaque type - unable to translate type of field {s}", .{ container_kind_name, field_name }); break :blk Tag.opaque_literal.init(); }, @@ -972,7 +972,7 @@ fn transEnumDecl(c: *Context, scope: *Scope, enum_decl: *const clang.EnumDecl) E .fields = try c.arena.dupe(ast.Payload.Enum.Field, fields.items), }); } else blk: { - _ = try c.opaque_demotes.put(c.gpa, @ptrToInt(enum_decl.getCanonicalDecl()), {}); + try c.opaque_demotes.put(c.gpa, @ptrToInt(enum_decl.getCanonicalDecl()), {}); break :blk Tag.opaque_literal.init(); }; @@ -3199,7 +3199,7 @@ fn maybeSuppressResult( } fn addTopLevelDecl(c: *Context, name: []const u8, decl_node: Node) !void { - _ = try c.global_scope.sym_table.put(name, decl_node); + try c.global_scope.sym_table.put(name, decl_node); try c.global_scope.nodes.append(decl_node); } @@ -4235,7 +4235,7 @@ fn transMacroDefine(c: *Context, m: *MacroCtx) ParseError!void { return m.fail(c, "unable to translate C expr: unexpected token .{s}", .{@tagName(last)}); const var_decl = try Tag.pub_var_simple.create(c.arena, .{ .name = m.name, .init = init_node }); - _ = try c.global_scope.macro_table.put(m.name, var_decl); + try c.global_scope.macro_table.put(m.name, var_decl); } fn transMacroFnDefine(c: *Context, m: *MacroCtx) ParseError!void { @@ -4294,7 +4294,7 @@ fn transMacroFnDefine(c: *Context, m: *MacroCtx) ParseError!void { .return_type = return_type, .body = try block_scope.complete(c), }); - _ = try c.global_scope.macro_table.put(m.name, fn_decl); + try c.global_scope.macro_table.put(m.name, fn_decl); } const ParseError = Error || error{ParseError}; diff --git a/tools/update_glibc.zig b/tools/update_glibc.zig index 77be81d6d5..e3652acf1c 100644 --- a/tools/update_glibc.zig +++ b/tools/update_glibc.zig @@ -200,7 +200,7 @@ pub fn main() !void { continue; } if (std.mem.startsWith(u8, ver, "GCC_")) continue; - _ = try global_ver_set.put(ver, undefined); + try global_ver_set.put(ver, undefined); const gop = try global_fn_set.getOrPut(name); if (gop.found_existing) { if (!std.mem.eql(u8, gop.entry.value.lib, "c")) { @@ -242,7 +242,7 @@ pub fn main() !void { var buffered = std.io.bufferedWriter(vers_txt_file.writer()); const vers_txt = buffered.writer(); for (global_ver_list) |name, i| { - _ = global_ver_set.put(name, i) catch unreachable; + global_ver_set.put(name, i) catch unreachable; try vers_txt.print("{s}\n", .{name}); } try buffered.flush();