diff --git a/lib/std/Progress.zig b/lib/std/Progress.zig index 025f10ef0e6b6134e430848ad71df5402d94368a..9afb93348ad967baa170f924e6350beb952c9e9d 100644 --- a/lib/std/Progress.zig +++ b/lib/std/Progress.zig @@ -295,7 +295,7 @@ fn refreshWithHeldLock(self: *Progress) void { end += 1; } - _ = file.write(self.output_buffer[0..end]) catch |e| { + _ = file.write(self.output_buffer[0..end]) catch { // Stop trying to write to this file once it errors. self.terminal = null; }; diff --git a/lib/std/SemanticVersion.zig b/lib/std/SemanticVersion.zig index 8e748184a87e7efa5011b1f258cfa46e5ad5c4a5..e0299525091ec3db1fe236863e1c16beb8a3910a 100644 --- a/lib/std/SemanticVersion.zig +++ b/lib/std/SemanticVersion.zig @@ -162,6 +162,7 @@ pub fn format( options: std.fmt.FormatOptions, out_stream: anytype, ) !void { + _ = options; if (fmt.len != 0) @compileError("Unknown format string: '" ++ fmt ++ "'"); try std.fmt.format(out_stream, "{d}.{d}.{d}", .{ self.major, self.minor, self.patch }); if (self.pre) |pre| try std.fmt.format(out_stream, "-{s}", .{pre}); @@ -259,7 +260,7 @@ test "SemanticVersion format" { // Invalid version string that may overflow. const big_invalid = "99999999999999999999999.999999999999999999.99999999999999999----RC-SNAPSHOT.12.09.1--------------------------------..12"; - if (parse(big_invalid)) |ver| std.debug.panic("expected error, found {}", .{ver}) else |err| {} + if (parse(big_invalid)) |ver| std.debug.panic("expected error, found {}", .{ver}) else |_| {} } test "SemanticVersion precedence" { diff --git a/lib/std/Thread/Condition.zig b/lib/std/Thread/Condition.zig index d88a6de31e0b27a393f1b8585d4d875b36c61626..8485f84aa4ce75a8b622ce0f31e5ed301f0bdafd 100644 --- a/lib/std/Thread/Condition.zig +++ b/lib/std/Thread/Condition.zig @@ -40,12 +40,18 @@ else pub const SingleThreadedCondition = struct { pub fn wait(cond: *SingleThreadedCondition, mutex: *Mutex) void { + _ = cond; + _ = mutex; unreachable; // deadlock detected } - pub fn signal(cond: *SingleThreadedCondition) void {} + pub fn signal(cond: *SingleThreadedCondition) void { + _ = cond; + } - pub fn broadcast(cond: *SingleThreadedCondition) void {} + pub fn broadcast(cond: *SingleThreadedCondition) void { + _ = cond; + } }; pub const WindowsCondition = struct { diff --git a/lib/std/Thread/StaticResetEvent.zig b/lib/std/Thread/StaticResetEvent.zig index 0a6a1d568e21a9e4b102032dc10a7ee5c50f21c7..6f869e0d8992084d1305631127059d8aa8c840fa 100644 --- a/lib/std/Thread/StaticResetEvent.zig +++ b/lib/std/Thread/StaticResetEvent.zig @@ -105,6 +105,7 @@ pub const DebugEvent = struct { } pub fn timedWait(ev: *DebugEvent, timeout: u64) TimedWaitResult { + _ = timeout; switch (ev.state) { .unset => return .timed_out, .set => return .event_set, @@ -174,7 +175,10 @@ pub const AtomicEvent = struct { }; pub const SpinFutex = struct { - fn wake(waiters: *u32, wake_count: u32) void {} + fn wake(waiters: *u32, wake_count: u32) void { + _ = waiters; + _ = wake_count; + } fn wait(waiters: *u32, timeout: ?u64) !void { var timer: time.Timer = undefined; @@ -193,6 +197,7 @@ pub const AtomicEvent = struct { pub const LinuxFutex = struct { fn wake(waiters: *u32, wake_count: u32) void { + _ = wake_count; const waiting = std.math.maxInt(i32); // wake_count const ptr = @ptrCast(*const i32, waiters); const rc = linux.futex_wake(ptr, linux.FUTEX_WAKE | linux.FUTEX_PRIVATE_FLAG, waiting); diff --git a/lib/std/array_hash_map.zig b/lib/std/array_hash_map.zig index 1ddbfce20cc4acb90db3d3b91a498ee7b5f7fc28..aeded3412d417ed31596a0542152c80df29346ec 100644 --- a/lib/std/array_hash_map.zig +++ b/lib/std/array_hash_map.zig @@ -40,9 +40,11 @@ pub fn StringArrayHashMapUnmanaged(comptime V: type) type { pub const StringContext = struct { pub fn hash(self: @This(), s: []const u8) u32 { + _ = self; return hashString(s); } pub fn eql(self: @This(), a: []const u8, b: []const u8) bool { + _ = self; return eqlString(a, b); } }; @@ -1335,6 +1337,7 @@ pub fn ArrayHashMapUnmanaged( } fn removeSlot(self: *Self, removed_slot: usize, header: *IndexHeader, comptime I: type, indexes: []Index(I)) void { + _ = self; const start_index = removed_slot +% 1; const end_index = start_index +% indexes.len; @@ -1626,6 +1629,7 @@ pub fn ArrayHashMapUnmanaged( } } fn dumpIndex(self: Self, header: *IndexHeader, comptime I: type) void { + _ = self; const p = std.debug.print; p(" index len=0x{x} type={}\n", .{ header.length(), header.capacityIndexType() }); const indexes = header.indexes(I); @@ -1918,7 +1922,7 @@ test "iterator hash map" { try testing.expect(count == 3); try testing.expect(it.next() == null); - for (buffer) |v, i| { + for (buffer) |_, i| { try testing.expect(buffer[@intCast(usize, keys[i])] == values[i]); } @@ -1930,7 +1934,7 @@ test "iterator hash map" { if (count >= 2) break; } - for (buffer[0..2]) |v, i| { + for (buffer[0..2]) |_, i| { try testing.expect(buffer[@intCast(usize, keys[i])] == values[i]); } @@ -2154,6 +2158,7 @@ test "compile everything" { pub fn getHashPtrAddrFn(comptime K: type, comptime Context: type) (fn (Context, K) u32) { return struct { fn hash(ctx: Context, key: K) u32 { + _ = ctx; return getAutoHashFn(usize, void)({}, @ptrToInt(key)); } }.hash; @@ -2162,6 +2167,7 @@ pub fn getHashPtrAddrFn(comptime K: type, comptime Context: type) (fn (Context, pub fn getTrivialEqlFn(comptime K: type, comptime Context: type) (fn (Context, K, K) bool) { return struct { fn eql(ctx: Context, a: K, b: K) bool { + _ = ctx; return a == b; } }.eql; @@ -2177,6 +2183,7 @@ pub fn AutoContext(comptime K: type) type { pub fn getAutoHashFn(comptime K: type, comptime Context: type) (fn (Context, K) u32) { return struct { fn hash(ctx: Context, key: K) u32 { + _ = ctx; if (comptime trait.hasUniqueRepresentation(K)) { return @truncate(u32, Wyhash.hash(0, std.mem.asBytes(&key))); } else { @@ -2191,6 +2198,7 @@ pub fn getAutoHashFn(comptime K: type, comptime Context: type) (fn (Context, K) pub fn getAutoEqlFn(comptime K: type, comptime Context: type) (fn (Context, K, K) bool) { return struct { fn eql(ctx: Context, a: K, b: K) bool { + _ = ctx; return meta.eql(a, b); } }.eql; @@ -2217,6 +2225,7 @@ pub fn autoEqlIsCheap(comptime K: type) bool { pub fn getAutoHashStratFn(comptime K: type, comptime Context: type, comptime strategy: std.hash.Strategy) (fn (Context, K) u32) { return struct { fn hash(ctx: Context, key: K) u32 { + _ = ctx; var hasher = Wyhash.init(0); std.hash.autoHashStrat(&hasher, key, strategy); return @truncate(u32, hasher.final()); diff --git a/lib/std/atomic/Atomic.zig b/lib/std/atomic/Atomic.zig index d137bc7552713d6853939d6cbb84c148c1668680..80fb1ae29725d59c38b83cb4d3945967cb807e15 100644 --- a/lib/std/atomic/Atomic.zig +++ b/lib/std/atomic/Atomic.zig @@ -232,6 +232,7 @@ test "Atomic.loadUnchecked" { test "Atomic.storeUnchecked" { inline for (atomicIntTypes()) |Int| { + _ = Int; var x = Atomic(usize).init(5); x.storeUnchecked(10); try testing.expectEqual(x.loadUnchecked(), 10); @@ -250,6 +251,7 @@ test "Atomic.load" { test "Atomic.store" { inline for (atomicIntTypes()) |Int| { inline for (.{ .Unordered, .Monotonic, .Release, .SeqCst }) |ordering| { + _ = Int; var x = Atomic(usize).init(5); x.store(10, ordering); try testing.expectEqual(x.load(.SeqCst), 10); diff --git a/lib/std/bit_set.zig b/lib/std/bit_set.zig index 7187b564d232f2a3ecf62afd0b4f4e0b2d4f6b2a..f7339bfdcf5520e39c3b732a50a72f9b832883dc 100644 --- a/lib/std/bit_set.zig +++ b/lib/std/bit_set.zig @@ -84,6 +84,7 @@ pub fn IntegerBitSet(comptime size: u16) type { /// Returns the number of bits in this bit set pub inline fn capacity(self: Self) usize { + _ = self; return bit_length; } @@ -311,6 +312,7 @@ pub fn ArrayBitSet(comptime MaskIntType: type, comptime size: usize) type { /// Returns the number of bits in this bit set pub inline fn capacity(self: Self) usize { + _ = self; return bit_length; } @@ -373,7 +375,7 @@ pub fn ArrayBitSet(comptime MaskIntType: type, comptime size: usize) type { /// Flips every bit in the bit set. pub fn toggleAll(self: *Self) void { - for (self.masks) |*mask, i| { + for (self.masks) |*mask| { mask.* = ~mask.*; } @@ -642,7 +644,7 @@ pub const DynamicBitSetUnmanaged = struct { if (bit_length == 0) return; const num_masks = numMasks(self.bit_length); - for (self.masks[0..num_masks]) |*mask, i| { + for (self.masks[0..num_masks]) |*mask| { mask.* = ~mask.*; } diff --git a/lib/std/build.zig b/lib/std/build.zig index 96af4a30714201535e0e0dc1458130d3e1d8122a..8626d660f0343dd87fe2b880207c483cbc418295 100644 --- a/lib/std/build.zig +++ b/lib/std/build.zig @@ -390,6 +390,7 @@ pub const Builder = struct { } pub fn version(self: *const Builder, major: u32, minor: u32, patch: u32) LibExeObjStep.SharedLibKind { + _ = self; return .{ .versioned = .{ .major = major, @@ -543,7 +544,7 @@ pub const Builder = struct { return null; }, .scalar => |s| { - const n = std.fmt.parseFloat(T, s) catch |err| { + const n = std.fmt.parseFloat(T, s) catch { warn("Expected -D{s} to be a float of type {s}.\n\n", .{ name, @typeName(T) }); self.markInvalidUserInput(); return null; @@ -3129,7 +3130,9 @@ pub const Step = struct { self.dependencies.append(other) catch unreachable; } - fn makeNoOp(self: *Step) anyerror!void {} + fn makeNoOp(self: *Step) anyerror!void { + _ = self; + } pub fn cast(step: *Step, comptime T: type) ?*T { if (step.id == T.base_id) { diff --git a/lib/std/build/InstallRawStep.zig b/lib/std/build/InstallRawStep.zig index f1d960895161fba7917d3172eab689c8e80c2f67..743b25f3cdeace469db52011c279f4c5235aa46c 100644 --- a/lib/std/build/InstallRawStep.zig +++ b/lib/std/build/InstallRawStep.zig @@ -139,6 +139,7 @@ const BinaryElfOutput = struct { } fn segmentSortCompare(context: void, left: *BinaryElfSegment, right: *BinaryElfSegment) bool { + _ = context; if (left.physicalAddress < right.physicalAddress) { return true; } @@ -149,6 +150,7 @@ const BinaryElfOutput = struct { } fn sectionSortCompare(context: void, left: *BinaryElfSection, right: *BinaryElfSection) bool { + _ = context; return left.binaryOffset < right.binaryOffset; } }; diff --git a/lib/std/builtin.zig b/lib/std/builtin.zig index 4d9350bbdd96a3bc1688b8333e47d70f74885e0c..615df9b9afa203a3cd6b64eb83c825cadb0a65d4 100644 --- a/lib/std/builtin.zig +++ b/lib/std/builtin.zig @@ -65,6 +65,8 @@ pub const StackTrace = struct { options: std.fmt.FormatOptions, writer: anytype, ) !void { + _ = fmt; + _ = options; var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator); defer arena.deinit(); const debug_info = std.debug.getSelfDebugInfo() catch |err| { @@ -521,6 +523,7 @@ pub const Version = struct { options: std.fmt.FormatOptions, out_stream: anytype, ) !void { + _ = options; if (fmt.len == 0) { if (self.patch == 0) { if (self.minor == 0) { diff --git a/lib/std/comptime_string_map.zig b/lib/std/comptime_string_map.zig index 0bf86167f97ffab0c4dd6d7c1d988d594b65fcd7..7da24545eca4507bd7e24404f72b44ce009a3858 100644 --- a/lib/std/comptime_string_map.zig +++ b/lib/std/comptime_string_map.zig @@ -23,6 +23,7 @@ pub fn ComptimeStringMap(comptime V: type, comptime kvs: anytype) type { var sorted_kvs: [kvs.len]KV = undefined; const lenAsc = (struct { fn lenAsc(context: void, a: KV, b: KV) bool { + _ = context; return a.key.len < b.key.len; } }).lenAsc; diff --git a/lib/std/crypto/25519/ed25519.zig b/lib/std/crypto/25519/ed25519.zig index b6321e8d8c17565a0f80ed5fa54fa895db86992b..4940f0dee6cb83fc891dcf7cbb1afe4199a72fe6 100644 --- a/lib/std/crypto/25519/ed25519.zig +++ b/lib/std/crypto/25519/ed25519.zig @@ -346,7 +346,7 @@ test "ed25519 test vectors" { .expected = error.IdentityElement, // 11 - small-order A }, }; - for (entries) |entry, i| { + for (entries) |entry| { var msg: [entry.msg_hex.len / 2]u8 = undefined; _ = try fmt.hexToBytes(&msg, entry.msg_hex); var public_key: [32]u8 = undefined; diff --git a/lib/std/crypto/blake3.zig b/lib/std/crypto/blake3.zig index c4ef40de3d3946efb695ddd35701f023b7b6354a..75aba06da0c58f2592c2f04ccc265013baccad5e 100644 --- a/lib/std/crypto/blake3.zig +++ b/lib/std/crypto/blake3.zig @@ -394,6 +394,7 @@ pub const Blake3 = struct { /// Construct a new `Blake3` for the key derivation function. The context /// string should be hardcoded, globally unique, and application-specific. pub fn initKdf(context: []const u8, options: KdfOptions) Blake3 { + _ = options; var context_hasher = Blake3.init_internal(IV, DERIVE_KEY_CONTEXT); context_hasher.update(context); var context_key: [KEY_LEN]u8 = undefined; diff --git a/lib/std/crypto/gimli.zig b/lib/std/crypto/gimli.zig index b55466e639240cebd03083cffb635fd6536897da..7aa67212e4ff479871777095192a38ac318edc6f 100644 --- a/lib/std/crypto/gimli.zig +++ b/lib/std/crypto/gimli.zig @@ -219,6 +219,7 @@ pub const Hash = struct { const Self = @This(); pub fn init(options: Options) Self { + _ = options; return Self{ .state = State{ .data = [_]u32{0} ** (State.BLOCKBYTES / 4) }, .buf_off = 0, diff --git a/lib/std/crypto/md5.zig b/lib/std/crypto/md5.zig index d4109eed8a539caeb2984b8d704cc84487ae335d..ef9907d18b459cc5bde97b53db643a2bc2bd6d00 100644 --- a/lib/std/crypto/md5.zig +++ b/lib/std/crypto/md5.zig @@ -45,6 +45,7 @@ pub const Md5 = struct { total_len: u64, pub fn init(options: Options) Self { + _ = options; return Self{ .s = [_]u32{ 0x67452301, diff --git a/lib/std/crypto/pcurves/p256/scalar.zig b/lib/std/crypto/pcurves/p256/scalar.zig index 02474bae08ed6a19ac12ed7401288a1d97186164..7a5eded2d66b9311c84780190be63bf2f7f702ff 100644 --- a/lib/std/crypto/pcurves/p256/scalar.zig +++ b/lib/std/crypto/pcurves/p256/scalar.zig @@ -63,6 +63,7 @@ pub fn add(a: CompressedScalar, b: CompressedScalar, endian: builtin.Endian) Non /// Return -s (mod L) pub fn neg(s: CompressedScalar, endian: builtin.Endian) NonCanonicalError!CompressedScalar { + _ = s; return (try Scalar.fromBytes(a, endian)).neg().toBytes(endian); } diff --git a/lib/std/crypto/sha1.zig b/lib/std/crypto/sha1.zig index 6bf6b469e243951d4c5aa92046bb0af071cb9216..e167a5071067d87ecd7c0115c2e80d7a38cbd3b0 100644 --- a/lib/std/crypto/sha1.zig +++ b/lib/std/crypto/sha1.zig @@ -43,6 +43,7 @@ pub const Sha1 = struct { total_len: u64 = 0, pub fn init(options: Options) Self { + _ = options; return Self{ .s = [_]u32{ 0x67452301, diff --git a/lib/std/crypto/sha2.zig b/lib/std/crypto/sha2.zig index ece2a3abfbfa6b1ab7f4ac851237ab64e9b4648e..eb0eccfa84c1d04abb59cf6a6ce9f75a0b9eb7d7 100644 --- a/lib/std/crypto/sha2.zig +++ b/lib/std/crypto/sha2.zig @@ -95,6 +95,7 @@ fn Sha2x32(comptime params: Sha2Params32) type { total_len: u64 = 0, pub fn init(options: Options) Self { + _ = options; return Self{ .s = [_]u32{ params.iv0, @@ -462,6 +463,7 @@ fn Sha2x64(comptime params: Sha2Params64) type { total_len: u128 = 0, pub fn init(options: Options) Self { + _ = options; return Self{ .s = [_]u64{ params.iv0, diff --git a/lib/std/crypto/sha3.zig b/lib/std/crypto/sha3.zig index d642d631e01ebaf0b72e841501cfcd27431d1a35..a4637c7fd4df309f9b9953f9a213aca5b6092f3a 100644 --- a/lib/std/crypto/sha3.zig +++ b/lib/std/crypto/sha3.zig @@ -28,6 +28,7 @@ fn Keccak(comptime bits: usize, comptime delim: u8) type { rate: usize, pub fn init(options: Options) Self { + _ = options; return Self{ .s = [_]u8{0} ** 200, .offset = 0, .rate = 200 - (bits / 4) }; } diff --git a/lib/std/crypto/tlcsprng.zig b/lib/std/crypto/tlcsprng.zig index c2cb119d4ae312456dc77910c5016abedf633349..15a356d3d3bf2e075941eeeac5853241fb213edb 100644 --- a/lib/std/crypto/tlcsprng.zig +++ b/lib/std/crypto/tlcsprng.zig @@ -84,7 +84,7 @@ fn tlsCsprngFill(_: *const std.rand.Random, buffer: []u8) void { os.MAP_PRIVATE | os.MAP_ANONYMOUS, -1, 0, - ) catch |err| { + ) catch { // Could not allocate memory for the local state, fall back to // the OS syscall. return fillWithOsEntropy(buffer); diff --git a/lib/std/debug.zig b/lib/std/debug.zig index 117d2dfd64b19b3361ed7fcfbb32fced2aa13779..68b77de6459b6d6dacde9722798088f732ee39e7 100644 --- a/lib/std/debug.zig +++ b/lib/std/debug.zig @@ -325,6 +325,7 @@ pub fn writeStackTrace( debug_info: *DebugInfo, tty_config: TTY.Config, ) !void { + _ = allocator; if (builtin.strip_debug_info) return error.MissingDebugInfo; var frame_index: usize = 0; var frames_left: usize = std.math.min(stack_trace.index, stack_trace.instruction_addresses.len); @@ -930,6 +931,7 @@ const MachoSymbol = struct { } fn addressLessThan(context: void, lhs: MachoSymbol, rhs: MachoSymbol) bool { + _ = context; return lhs.address() < rhs.address(); } }; @@ -1134,6 +1136,7 @@ pub const DebugInfo = struct { if (os.dl_iterate_phdr(&ctx, anyerror, struct { fn callback(info: *os.dl_phdr_info, size: usize, context: *CtxTy) !void { + _ = size; // The base address is too high if (context.address < info.dlpi_addr) return; @@ -1189,6 +1192,8 @@ pub const DebugInfo = struct { } fn lookupModuleHaiku(self: *DebugInfo, address: usize) !*ModuleDebugInfo { + _ = self; + _ = address; @panic("TODO implement lookup module for Haiku"); } }; diff --git a/lib/std/dwarf.zig b/lib/std/dwarf.zig index 116f5b01ffb4929b83cca6edcb6771570950d5e3..eb22dba7c03833d01ab36add7f44a0dc1cea46de 100644 --- a/lib/std/dwarf.zig +++ b/lib/std/dwarf.zig @@ -283,6 +283,7 @@ fn parseFormValueBlock(allocator: *mem.Allocator, in_stream: anytype, endian: bu } fn parseFormValueConstant(allocator: *mem.Allocator, in_stream: anytype, signed: bool, endian: builtin.Endian, comptime size: i32) !FormValue { + _ = allocator; // TODO: Please forgive me, I've worked around zig not properly spilling some intermediate values here. // `nosuspend` should be removed from all the function calls once it is fixed. return FormValue{ @@ -310,6 +311,7 @@ fn parseFormValueConstant(allocator: *mem.Allocator, in_stream: anytype, signed: // TODO the nosuspends here are workarounds fn parseFormValueRef(allocator: *mem.Allocator, in_stream: anytype, endian: builtin.Endian, size: i32) !FormValue { + _ = allocator; return FormValue{ .Ref = switch (size) { 1 => try nosuspend in_stream.readInt(u8, endian), @@ -453,13 +455,13 @@ pub const DwarfInfo = struct { if (this_die_obj.getAttr(AT_name)) |_| { const name = try this_die_obj.getAttrString(di, AT_name); break :x name; - } else if (this_die_obj.getAttr(AT_abstract_origin)) |ref| { + } else if (this_die_obj.getAttr(AT_abstract_origin)) |_| { // Follow the DIE it points to and repeat const ref_offset = try this_die_obj.getAttrRef(AT_abstract_origin); if (ref_offset > next_offset) return error.InvalidDebugInfo; try seekable.seekTo(this_unit_offset + ref_offset); this_die_obj = (try di.parseDie(in, abbrev_table, is_64)) orelse return error.InvalidDebugInfo; - } else if (this_die_obj.getAttr(AT_specification)) |ref| { + } else if (this_die_obj.getAttr(AT_specification)) |_| { // Follow the DIE it points to and repeat const ref_offset = try this_die_obj.getAttrRef(AT_specification); if (ref_offset > next_offset) return error.InvalidDebugInfo; diff --git a/lib/std/dynamic_library.zig b/lib/std/dynamic_library.zig index 5739bf79b7d04048da6276c2d398fe8e854d9d4e..d1750ef761a0bb5c8a5d841e3b4a89baa2db14d5 100644 --- a/lib/std/dynamic_library.zig +++ b/lib/std/dynamic_library.zig @@ -66,6 +66,7 @@ pub fn get_DYNAMIC() ?[*]elf.Dyn { } pub fn linkmap_iterator(phdrs: []elf.Phdr) !LinkMap.Iterator { + _ = phdrs; const _DYNAMIC = get_DYNAMIC() orelse { // No PT_DYNAMIC means this is either a statically-linked program or a // badly corrupted dynamically-linked one. diff --git a/lib/std/enums.zig b/lib/std/enums.zig index 6a634626e60a4335175ed85da1abbbb7adaff157..95c6fc7ec7eaa917d50f60cfc2f7203aafb8ab2d 100644 --- a/lib/std/enums.zig +++ b/lib/std/enums.zig @@ -18,7 +18,7 @@ const EnumField = std.builtin.TypeInfo.EnumField; pub fn EnumFieldStruct(comptime E: type, comptime Data: type, comptime field_default: ?Data) type { const StructField = std.builtin.TypeInfo.StructField; var fields: []const StructField = &[_]StructField{}; - for (std.meta.fields(E)) |field, i| { + for (std.meta.fields(E)) |field| { fields = fields ++ &[_]StructField{.{ .name = field.name, .field_type = Data, @@ -144,7 +144,7 @@ pub fn directEnumArrayDefault( ) [directEnumArrayLen(E, max_unused_slots)]Data { const len = comptime directEnumArrayLen(E, max_unused_slots); var result: [len]Data = if (default) |d| [_]Data{d} ** len else undefined; - inline for (@typeInfo(@TypeOf(init_values)).Struct.fields) |f, i| { + inline for (@typeInfo(@TypeOf(init_values)).Struct.fields) |f| { const enum_value = @field(E, f.name); const index = @intCast(usize, @enumToInt(enum_value)); result[index] = @field(init_values, f.name); @@ -334,6 +334,7 @@ pub fn EnumArray(comptime E: type, comptime V: type) type { /// TODO: Once #8169 is fixed, consider switching this param /// back to an optional. pub fn NoExtension(comptime Self: type) type { + _ = Self; return NoExt; } const NoExt = struct {}; @@ -729,6 +730,7 @@ test "std.enums.ensureIndexer" { } fn ascByValue(ctx: void, comptime a: EnumField, comptime b: EnumField) bool { + _ = ctx; return a.value < b.value; } pub fn EnumIndexer(comptime E: type) type { @@ -743,9 +745,11 @@ pub fn EnumIndexer(comptime E: type) type { pub const Key = E; pub const count: usize = 0; pub fn indexOf(e: E) usize { + _ = e; unreachable; } pub fn keyForIndex(i: usize) E { + _ = i; unreachable; } }; diff --git a/lib/std/event/loop.zig b/lib/std/event/loop.zig index f0661bac93ba9e41eca2979fad5cdc4e7b9bc5b7..bfc204919cf2aa82c51990614af3c3a97c17bc7c 100644 --- a/lib/std/event/loop.zig +++ b/lib/std/event/loop.zig @@ -345,7 +345,7 @@ pub const Loop = struct { ); errdefer windows.CloseHandle(self.os_data.io_port); - for (self.eventfd_resume_nodes) |*eventfd_node, i| { + for (self.eventfd_resume_nodes) |*eventfd_node| { eventfd_node.* = std.atomic.Stack(ResumeNode.EventFd).Node{ .data = ResumeNode.EventFd{ .base = ResumeNode{ diff --git a/lib/std/fmt.zig b/lib/std/fmt.zig index 41570b12cbe3a65e70ce98dacd8900bb591e606c..9ba7b8262c76f99b645372084fd66ae08e54742b 100644 --- a/lib/std/fmt.zig +++ b/lib/std/fmt.zig @@ -369,6 +369,7 @@ pub fn format( } pub fn formatAddress(value: anytype, options: FormatOptions, writer: anytype) @TypeOf(writer).Error!void { + _ = options; const T = @TypeOf(value); switch (@typeInfo(T)) { @@ -553,7 +554,7 @@ pub fn formatType( .Many, .C => { if (actual_fmt.len == 0) @compileError("cannot format pointer without a specifier (i.e. {s} or {*})"); - if (ptr_info.sentinel) |sentinel| { + if (ptr_info.sentinel) |_| { return formatType(mem.span(value), actual_fmt, options, writer, max_depth); } if (ptr_info.child == u8) { @@ -741,6 +742,8 @@ fn formatSliceHexImpl(comptime case: Case) type { options: std.fmt.FormatOptions, writer: anytype, ) !void { + _ = fmt; + _ = options; var buf: [2]u8 = undefined; for (bytes) |c| { @@ -777,6 +780,8 @@ fn formatSliceEscapeImpl(comptime case: Case) type { options: std.fmt.FormatOptions, writer: anytype, ) !void { + _ = fmt; + _ = options; var buf: [4]u8 = undefined; buf[0] = '\\'; @@ -820,6 +825,7 @@ fn formatSizeImpl(comptime radix: comptime_int) type { options: FormatOptions, writer: anytype, ) !void { + _ = fmt; if (value == 0) { return writer.writeAll("0B"); } @@ -903,6 +909,7 @@ pub fn formatAsciiChar( options: FormatOptions, writer: anytype, ) !void { + _ = options; return writer.writeAll(@as(*const [1]u8, &c)); } @@ -1362,6 +1369,8 @@ pub fn formatIntBuf(out_buf: []u8, value: anytype, base: u8, case: Case, options } fn formatDuration(ns: u64, comptime fmt: []const u8, options: std.fmt.FormatOptions, writer: anytype) !void { + _ = fmt; + _ = options; var ns_remaining = ns; inline for (.{ .{ .ns = 365 * std.time.ns_per_day, .sep = 'y' }, @@ -2152,6 +2161,7 @@ test "custom" { options: FormatOptions, writer: anytype, ) !void { + _ = options; if (fmt.len == 0 or comptime std.mem.eql(u8, fmt, "p")) { return std.fmt.format(writer, "({d:.3},{d:.3})", .{ self.x, self.y }); } else if (comptime std.mem.eql(u8, fmt, "d")) { @@ -2340,6 +2350,7 @@ test "formatType max_depth" { options: FormatOptions, writer: anytype, ) !void { + _ = options; if (fmt.len == 0) { return std.fmt.format(writer, "({d:.3},{d:.3})", .{ self.x, self.y }); } else { diff --git a/lib/std/fs.zig b/lib/std/fs.zig index f7f6e0155f41109190b44397ac0df96ad27d87ce..9a39bc0425def27a2c769fff58d808072a8d5820 100644 --- a/lib/std/fs.zig +++ b/lib/std/fs.zig @@ -1541,7 +1541,7 @@ pub const Dir = struct { self: Dir, target_path: []const u8, sym_link_path: []const u8, - flags: SymLinkFlags, + _: SymLinkFlags, ) !void { return os.symlinkatWasi(target_path, self.fd, sym_link_path); } @@ -1879,6 +1879,7 @@ pub const Dir = struct { /// * NtDll prefixed /// TODO currently this ignores `flags`. pub fn accessW(self: Dir, sub_path_w: [*:0]const u16, flags: File.OpenFlags) AccessError!void { + _ = flags; return os.faccessatW(self.fd, sub_path_w, 0, 0); } diff --git a/lib/std/fs/path.zig b/lib/std/fs/path.zig index fd5c46ff9fbedf29766556e01e59299d347f99a2..04404a61bbdf8abb3f82a95be359fa81bffd2448 100644 --- a/lib/std/fs/path.zig +++ b/lib/std/fs/path.zig @@ -579,7 +579,7 @@ pub fn resolveWindows(allocator: *Allocator, paths: []const []const u8) ![]u8 { // Now we know the disk designator to use, if any, and what kind it is. And our result // is big enough to append all the paths to. var correct_disk_designator = true; - for (paths[first_index..]) |p, i| { + for (paths[first_index..]) |p| { const parsed = windowsParsePath(p); if (parsed.kind != WindowsPath.Kind.None) { @@ -660,7 +660,7 @@ pub fn resolvePosix(allocator: *Allocator, paths: []const []const u8) ![]u8 { } errdefer allocator.free(result); - for (paths[first_index..]) |p, i| { + for (paths[first_index..]) |p| { var it = mem.tokenize(p, "/"); while (it.next()) |component| { if (mem.eql(u8, component, ".")) { diff --git a/lib/std/fs/test.zig b/lib/std/fs/test.zig index a20ec4c1bccf53f7268a2a1388bfb9dda13b0796..3c7a95432c09e93169bae4c79aa78118c0837075 100644 --- a/lib/std/fs/test.zig +++ b/lib/std/fs/test.zig @@ -541,6 +541,7 @@ test "makePath, put some files in it, deleteTree" { try tmp.dir.writeFile("os_test_tmp" ++ fs.path.sep_str ++ "b" ++ fs.path.sep_str ++ "file2.txt", "blah"); try tmp.dir.deleteTree("os_test_tmp"); if (tmp.dir.openDir("os_test_tmp", .{})) |dir| { + _ = dir; @panic("expected error"); } else |err| { try testing.expect(err == error.FileNotFound); @@ -638,6 +639,7 @@ test "access file" { try tmp.dir.makePath("os_test_tmp"); if (tmp.dir.access("os_test_tmp" ++ fs.path.sep_str ++ "file.txt", .{})) |ok| { + _ = ok; @panic("expected error"); } else |err| { try testing.expect(err == error.FileNotFound); diff --git a/lib/std/fs/wasi.zig b/lib/std/fs/wasi.zig index adc20883e54481a01ff5dd02975985cac035f4eb..c41c9a7614bae354c1aa876ff2dcfd6776a5c90b 100644 --- a/lib/std/fs/wasi.zig +++ b/lib/std/fs/wasi.zig @@ -36,6 +36,8 @@ pub const PreopenType = union(PreopenTypeTag) { } pub fn format(self: Self, comptime fmt: []const u8, options: std.fmt.FormatOptions, out_stream: anytype) !void { + _ = fmt; + _ = options; try out_stream.print("PreopenType{{ ", .{}); switch (self) { PreopenType.Dir => |path| try out_stream.print(".Dir = '{}'", .{std.zig.fmtId(path)}), diff --git a/lib/std/hash/cityhash.zig b/lib/std/hash/cityhash.zig index 9658cee13a1db79b8e1b5371539065c1f102e5e1..8796eb00757dc652a79c730f4ecdeac9a06cf9ac 100644 --- a/lib/std/hash/cityhash.zig +++ b/lib/std/hash/cityhash.zig @@ -375,6 +375,7 @@ fn SMHasherTest(comptime hash_fn: anytype) u32 { } fn CityHash32hashIgnoreSeed(str: []const u8, seed: u32) u32 { + _ = seed; return CityHash32.hash(str); } diff --git a/lib/std/hash_map.zig b/lib/std/hash_map.zig index 6975408fc3a45b543bdf75c4c69bb35d7a9a57c2..d64e122aaf5deec472346ce4d86cebe85d779c46 100644 --- a/lib/std/hash_map.zig +++ b/lib/std/hash_map.zig @@ -29,6 +29,7 @@ pub fn getAutoHashFn(comptime K: type, comptime Context: type) (fn (Context, K) return struct { fn hash(ctx: Context, key: K) u64 { + _ = ctx; if (comptime trait.hasUniqueRepresentation(K)) { return Wyhash.hash(0, std.mem.asBytes(&key)); } else { @@ -43,6 +44,7 @@ pub fn getAutoHashFn(comptime K: type, comptime Context: type) (fn (Context, K) pub fn getAutoEqlFn(comptime K: type, comptime Context: type) (fn (Context, K, K) bool) { return struct { fn eql(ctx: Context, a: K, b: K) bool { + _ = ctx; return meta.eql(a, b); } }.eql; @@ -78,9 +80,11 @@ pub fn StringHashMapUnmanaged(comptime V: type) type { pub const StringContext = struct { pub fn hash(self: @This(), s: []const u8) u64 { + _ = self; return hashString(s); } pub fn eql(self: @This(), a: []const u8, b: []const u8) bool { + _ = self; return eqlString(a, b); } }; @@ -1887,9 +1891,11 @@ test "std.hash_map clone" { test "std.hash_map getOrPutAdapted" { const AdaptedContext = struct { fn eql(self: @This(), adapted_key: []const u8, test_key: u64) bool { + _ = self; return std.fmt.parseInt(u64, adapted_key, 10) catch unreachable == test_key; } fn hash(self: @This(), adapted_key: []const u8) u64 { + _ = self; const key = std.fmt.parseInt(u64, adapted_key, 10) catch unreachable; return (AutoContext(u64){}).hash(key); } diff --git a/lib/std/heap.zig b/lib/std/heap.zig index a5150e50feda66c6c0c973ce0abb1e6231fb4ecb..088d6b39bbf772d0f79afe4ad1eba7a9068d996d 100644 --- a/lib/std/heap.zig +++ b/lib/std/heap.zig @@ -108,6 +108,8 @@ const CAllocator = struct { len_align: u29, return_address: usize, ) error{OutOfMemory}![]u8 { + _ = allocator; + _ = return_address; assert(len > 0); assert(std.math.isPowerOfTwo(alignment)); @@ -134,6 +136,9 @@ const CAllocator = struct { len_align: u29, return_address: usize, ) Allocator.Error!usize { + _ = allocator; + _ = buf_align; + _ = return_address; if (new_len == 0) { alignedFree(buf.ptr); return 0; @@ -178,6 +183,9 @@ fn rawCAlloc( len_align: u29, ret_addr: usize, ) Allocator.Error![]u8 { + _ = self; + _ = len_align; + _ = ret_addr; assert(ptr_align <= @alignOf(std.c.max_align_t)); const ptr = @ptrCast([*]u8, c.malloc(len) orelse return error.OutOfMemory); return ptr[0..len]; @@ -191,6 +199,9 @@ fn rawCResize( len_align: u29, ret_addr: usize, ) Allocator.Error!usize { + _ = self; + _ = old_align; + _ = ret_addr; if (new_len == 0) { c.free(buf.ptr); return 0; @@ -231,6 +242,8 @@ pub var next_mmap_addr_hint: ?[*]align(mem.page_size) u8 = null; const PageAllocator = struct { fn alloc(allocator: *Allocator, n: usize, alignment: u29, len_align: u29, ra: usize) error{OutOfMemory}![]u8 { + _ = allocator; + _ = ra; assert(n > 0); const aligned_len = mem.alignForward(n, mem.page_size); @@ -334,6 +347,9 @@ const PageAllocator = struct { len_align: u29, return_address: usize, ) Allocator.Error!usize { + _ = allocator; + _ = buf_align; + _ = return_address; const new_size_aligned = mem.alignForward(new_size, mem.page_size); if (builtin.os.tag == .windows) { @@ -482,6 +498,8 @@ const WasmPageAllocator = struct { } fn alloc(allocator: *Allocator, len: usize, alignment: u29, len_align: u29, ra: usize) error{OutOfMemory}![]u8 { + _ = allocator; + _ = ra; const page_count = nPages(len); const page_idx = try allocPages(page_count, alignment); return @intToPtr([*]u8, page_idx * mem.page_size)[0..alignPageAllocLen(page_count * mem.page_size, len, len_align)]; @@ -542,6 +560,9 @@ const WasmPageAllocator = struct { len_align: u29, return_address: usize, ) error{OutOfMemory}!usize { + _ = allocator; + _ = buf_align; + _ = return_address; const aligned_len = mem.alignForward(buf.len, mem.page_size); if (new_len > aligned_len) return error.OutOfMemory; const current_n = nPages(aligned_len); @@ -588,6 +609,7 @@ pub const HeapAllocator = switch (builtin.os.tag) { len_align: u29, return_address: usize, ) error{OutOfMemory}![]u8 { + _ = return_address; const self = @fieldParentPtr(HeapAllocator, "allocator", allocator); const amt = n + ptr_align - 1 + @sizeOf(usize); @@ -622,6 +644,8 @@ pub const HeapAllocator = switch (builtin.os.tag) { len_align: u29, return_address: usize, ) error{OutOfMemory}!usize { + _ = buf_align; + _ = return_address; const self = @fieldParentPtr(HeapAllocator, "allocator", allocator); if (new_size == 0) { os.windows.HeapFree(self.heap_handle.?, 0, @intToPtr(*c_void, getRecordPtr(buf).*)); @@ -694,6 +718,8 @@ pub const FixedBufferAllocator = struct { } fn alloc(allocator: *Allocator, n: usize, ptr_align: u29, len_align: u29, ra: usize) ![]u8 { + _ = len_align; + _ = ra; const self = @fieldParentPtr(FixedBufferAllocator, "allocator", allocator); const adjust_off = mem.alignPointerOffset(self.buffer.ptr + self.end_index, ptr_align) orelse return error.OutOfMemory; @@ -716,6 +742,8 @@ pub const FixedBufferAllocator = struct { len_align: u29, return_address: usize, ) Allocator.Error!usize { + _ = buf_align; + _ = return_address; const self = @fieldParentPtr(FixedBufferAllocator, "allocator", allocator); assert(self.ownsSlice(buf)); // sanity check @@ -766,6 +794,8 @@ pub const ThreadSafeFixedBufferAllocator = blk: { } fn alloc(allocator: *Allocator, n: usize, ptr_align: u29, len_align: u29, ra: usize) ![]u8 { + _ = len_align; + _ = ra; const self = @fieldParentPtr(ThreadSafeFixedBufferAllocator, "allocator", allocator); var end_index = @atomicLoad(usize, &self.end_index, builtin.AtomicOrder.SeqCst); while (true) { diff --git a/lib/std/heap/arena_allocator.zig b/lib/std/heap/arena_allocator.zig index 1b301bbb505211d123b2144e5e9f9005886bd585..356d5c5d8155cc12f32cd3baaa843a77c3877856 100644 --- a/lib/std/heap/arena_allocator.zig +++ b/lib/std/heap/arena_allocator.zig @@ -66,6 +66,8 @@ pub const ArenaAllocator = struct { } fn alloc(allocator: *Allocator, n: usize, ptr_align: u29, len_align: u29, ra: usize) ![]u8 { + _ = len_align; + _ = ra; const self = @fieldParentPtr(ArenaAllocator, "allocator", allocator); var cur_node = if (self.state.buffer_list.first) |first_node| first_node else try self.createNode(0, n + ptr_align); @@ -95,6 +97,9 @@ pub const ArenaAllocator = struct { } fn resize(allocator: *Allocator, buf: []u8, buf_align: u29, new_len: usize, len_align: u29, ret_addr: usize) Allocator.Error!usize { + _ = buf_align; + _ = len_align; + _ = ret_addr; const self = @fieldParentPtr(ArenaAllocator, "allocator", allocator); const cur_node = self.state.buffer_list.first orelse return error.OutOfMemory; diff --git a/lib/std/heap/log_to_writer_allocator.zig b/lib/std/heap/log_to_writer_allocator.zig index 96c6971f3853958da83620127ed65f5c8028e195..c2fd687e0cc97b12369dd459a3c50bb5e4bd7e76 100644 --- a/lib/std/heap/log_to_writer_allocator.zig +++ b/lib/std/heap/log_to_writer_allocator.zig @@ -37,9 +37,9 @@ pub fn LogToWriterAllocator(comptime Writer: type) type { const self = @fieldParentPtr(Self, "allocator", allocator); self.writer.print("alloc : {}", .{len}) catch {}; const result = self.parent_allocator.allocFn(self.parent_allocator, len, ptr_align, len_align, ra); - if (result) |buff| { + if (result) |_| { self.writer.print(" success!\n", .{}) catch {}; - } else |err| { + } else |_| { self.writer.print(" failure!\n", .{}) catch {}; } return result; diff --git a/lib/std/heap/logging_allocator.zig b/lib/std/heap/logging_allocator.zig index ea63a76b72c8fba8d9c4a92572812ab35ed1356b..7baa857f00f64235ff348d331dcfd623798ad7e6 100644 --- a/lib/std/heap/logging_allocator.zig +++ b/lib/std/heap/logging_allocator.zig @@ -65,7 +65,7 @@ pub fn ScopedLoggingAllocator( ) error{OutOfMemory}![]u8 { const self = @fieldParentPtr(Self, "allocator", allocator); const result = self.parent_allocator.allocFn(self.parent_allocator, len, ptr_align, len_align, ra); - if (result) |buff| { + if (result) |_| { logHelper( success_log_level, "alloc - success - len: {}, ptr_align: {}, len_align: {}", diff --git a/lib/std/io.zig b/lib/std/io.zig index 1264ba4aef6b3888d0e151116385c72173513c41..8bb9c4d2c09861e0dc2af10434c37d6740378ab4 100644 --- a/lib/std/io.zig +++ b/lib/std/io.zig @@ -161,6 +161,7 @@ pub const null_writer = @as(NullWriter, .{ .context = {} }); const NullWriter = Writer(void, error{}, dummyWrite); fn dummyWrite(context: void, data: []const u8) error{}!usize { + _ = context; return data.len; } diff --git a/lib/std/io/bit_reader.zig b/lib/std/io/bit_reader.zig index 16411b4fa6de91ba62f3fafc2ccaff2b8b73bd93..9092c8a62d766c32e35a54454bf28fb4098e38f2 100644 --- a/lib/std/io/bit_reader.zig +++ b/lib/std/io/bit_reader.zig @@ -149,7 +149,7 @@ pub fn BitReader(endian: builtin.Endian, comptime ReaderType: type) type { var out_bits_total = @as(usize, 0); //@NOTE: I'm not sure this is a good idea, maybe alignToByte should be forced if (self.bit_count > 0) { - for (buffer) |*b, i| { + for (buffer) |*b| { b.* = try self.readBits(u8, u8_bit_count, &out_bits); out_bits_total += out_bits; } diff --git a/lib/std/io/bit_writer.zig b/lib/std/io/bit_writer.zig index 7f80251543c11089af032958456ed94f6d042b7a..daa0718a18c46e2e1628fb88109e304742e6b050 100644 --- a/lib/std/io/bit_writer.zig +++ b/lib/std/io/bit_writer.zig @@ -128,7 +128,7 @@ pub fn BitWriter(endian: builtin.Endian, comptime WriterType: type) type { pub fn write(self: *Self, buffer: []const u8) Error!usize { // TODO: I'm not sure this is a good idea, maybe flushBits should be forced if (self.bit_count > 0) { - for (buffer) |b, i| + for (buffer) |b| try self.writeBits(b, u8_bit_count); return buffer.len; } diff --git a/lib/std/json.zig b/lib/std/json.zig index 847d38f08d5c287eee76966cac14bed4ca2ef60f..8759469327002857e686d83be180c4325c7b1200 100644 --- a/lib/std/json.zig +++ b/lib/std/json.zig @@ -1221,11 +1221,11 @@ test "json.token premature object close" { pub fn validate(s: []const u8) bool { var p = StreamingParser.init(); - for (s) |c, i| { + for (s) |c| { var token1: ?Token = undefined; var token2: ?Token = undefined; - p.feed(c, &token1, &token2) catch |err| { + p.feed(c, &token1, &token2) catch { return false; }; } @@ -1410,7 +1410,7 @@ fn parsedEqual(a: anytype, b: @TypeOf(a)) bool { if (a == null or b == null) return false; return parsedEqual(a.?, b.?); }, - .Union => |unionInfo| { + .Union => { if (info.tag_type) |UnionTag| { const tag_a = std.meta.activeTag(a); const tag_b = std.meta.activeTag(b); @@ -1771,7 +1771,7 @@ fn parseInternal(comptime T: type, token: Token, tokens: *TokenStream, options: const source_slice = stringToken.slice(tokens.slice, tokens.i - 1); switch (stringToken.escapes) { .None => return allocator.dupe(u8, source_slice), - .Some => |some_escapes| { + .Some => { const output = try allocator.alloc(u8, stringToken.decodedLength()); errdefer allocator.free(output); try unescapeValidString(output, source_slice); @@ -2391,7 +2391,7 @@ pub const Parser = struct { const slice = s.slice(input, i); switch (s.escapes) { .None => return Value{ .String = if (p.copy_strings) try allocator.dupe(u8, slice) else slice }, - .Some => |some_escapes| { + .Some => { const output = try allocator.alloc(u8, s.decodedLength()); errdefer allocator.free(output); try unescapeValidString(output, slice); @@ -2401,6 +2401,7 @@ pub const Parser = struct { } fn parseNumber(p: *Parser, n: std.meta.TagPayload(Token, Token.Number), input: []const u8, i: usize) !Value { + _ = p; return if (n.is_integer) Value{ .Integer = std.fmt.parseInt(i64, n.slice(input, i), 10) catch |e| switch (e) { @@ -2815,7 +2816,7 @@ pub fn stringify( if (child_options.whitespace) |*child_whitespace| { child_whitespace.indent_level += 1; } - inline for (S.fields) |Field, field_i| { + inline for (S.fields) |Field| { // don't include void fields if (Field.field_type == void) continue; @@ -3114,6 +3115,7 @@ test "stringify struct with custom stringifier" { options: StringifyOptions, out_stream: anytype, ) !void { + _ = value; try out_stream.writeAll("[\"something special\","); try stringify(42, options, out_stream); try out_stream.writeByte(']'); diff --git a/lib/std/linked_list.zig b/lib/std/linked_list.zig index 7bab3e21886b094db209a4a28696a8b65ac9cc95..fe984d66808f62583e0050b9626107c9b75f0328 100644 --- a/lib/std/linked_list.zig +++ b/lib/std/linked_list.zig @@ -63,7 +63,7 @@ pub fn SinglyLinkedList(comptime T: type) type { pub fn countChildren(node: *const Node) usize { var count: usize = 0; var it: ?*const Node = node.next; - while (it) |n| : (it = n.next) { + while (it) |_| : (it = n.next) { count += 1; } return count; diff --git a/lib/std/math/big/int.zig b/lib/std/math/big/int.zig index 4a74347758358a06ac5177f55c877a971b4d590f..cbae123189c116f0d9972e534da590c2be9a0e80 100644 --- a/lib/std/math/big/int.zig +++ b/lib/std/math/big/int.zig @@ -458,6 +458,7 @@ pub const Mutable = struct { /// If `allocator` is provided, it will be used for temporary storage to improve /// multiplication performance. `error.OutOfMemory` is handled with a fallback algorithm. pub fn sqrNoAlias(rma: *Mutable, a: Const, opt_allocator: ?*Allocator) void { + _ = opt_allocator; assert(rma.limbs.ptr != a.limbs.ptr); // illegal aliasing mem.set(Limb, rma.limbs, 0); @@ -676,6 +677,7 @@ pub const Mutable = struct { /// /// `limbs_buffer` is used for temporary storage during the operation. pub fn gcdNoAlias(rma: *Mutable, x: Const, y: Const, limbs_buffer: *std.ArrayList(Limb)) !void { + _ = limbs_buffer; assert(rma.limbs.ptr != x.limbs.ptr); // illegal aliasing assert(rma.limbs.ptr != y.limbs.ptr); // illegal aliasing return gcdLehmer(rma, x, y, allocator); @@ -1141,6 +1143,7 @@ pub const Const = struct { options: std.fmt.FormatOptions, out_stream: anytype, ) !void { + _ = options; comptime var radix = 10; comptime var case: std.fmt.Case = .lower; @@ -1618,6 +1621,7 @@ pub const Managed = struct { /// Converts self to a string in the requested base. Memory is allocated from the provided /// allocator and not the one present in self. pub fn toString(self: Managed, allocator: *Allocator, base: u8, case: std.fmt.Case) ![]u8 { + _ = allocator; if (base < 2 or base > 16) return error.InvalidBase; return self.toConst().toStringAlloc(self.allocator, base, case); } diff --git a/lib/std/mem.zig b/lib/std/mem.zig index ecdad6d31458f91a3f828200b40e0136486aacf1..2273db34cb7c95e4bc7b38951cf7353e3f1a8111 100644 --- a/lib/std/mem.zig +++ b/lib/std/mem.zig @@ -139,6 +139,11 @@ var failAllocator = Allocator{ .resizeFn = Allocator.noResize, }; fn failAllocatorAlloc(self: *Allocator, n: usize, alignment: u29, len_align: u29, ra: usize) Allocator.Error![]u8 { + _ = self; + _ = n; + _ = alignment; + _ = len_align; + _ = ra; return error.OutOfMemory; } diff --git a/lib/std/mem/Allocator.zig b/lib/std/mem/Allocator.zig index 6cc888fa1098e65b9f2f39ebb1566c7fc336403c..1e13ed97b74d55472ec5c064870383782a3933cd 100644 --- a/lib/std/mem/Allocator.zig +++ b/lib/std/mem/Allocator.zig @@ -55,6 +55,10 @@ pub fn noResize( len_align: u29, ret_addr: usize, ) Error!usize { + _ = self; + _ = buf_align; + _ = len_align; + _ = ret_addr; if (new_len > buf.len) return error.OutOfMemory; return new_len; diff --git a/lib/std/meta.zig b/lib/std/meta.zig index 72a3b5a1989571ca8a740146951df8c25ee141fa..03fb4f80f145a5c6c96a9c40ecd987bcefb81c85 100644 --- a/lib/std/meta.zig +++ b/lib/std/meta.zig @@ -843,6 +843,7 @@ pub const refAllDecls = @compileError("refAllDecls has been moved from std.meta pub fn declList(comptime Namespace: type, comptime Decl: type) []const *const Decl { const S = struct { fn declNameLessThan(context: void, lhs: *const Decl, rhs: *const Decl) bool { + _ = context; return mem.lessThan(u8, lhs.name, rhs.name); } }; diff --git a/lib/std/meta/trailer_flags.zig b/lib/std/meta/trailer_flags.zig index 94f2043b0027133a646f9c320e24e643ba10b125..248a0d6146767ce5f78b063f16dbf4e703bbd240 100644 --- a/lib/std/meta/trailer_flags.zig +++ b/lib/std/meta/trailer_flags.zig @@ -108,6 +108,7 @@ pub fn TrailerFlags(comptime Fields: type) type { } pub fn offset(self: Self, p: [*]align(@alignOf(Fields)) const u8, comptime field: FieldEnum) usize { + _ = p; var off: usize = 0; inline for (@typeInfo(Fields).Struct.fields) |field_info, i| { const active = (self.bits & (1 << i)) != 0; diff --git a/lib/std/multi_array_list.zig b/lib/std/multi_array_list.zig index 7a071a8928f95d3f93e82865a927d029e9fa11c9..9707c0634aa9847b21ab2a39e4c4bb995f01aad0 100644 --- a/lib/std/multi_array_list.zig +++ b/lib/std/multi_array_list.zig @@ -92,6 +92,7 @@ pub fn MultiArrayList(comptime S: type) type { } const Sort = struct { fn lessThan(trash: *i32, lhs: Data, rhs: Data) bool { + _ = trash; return lhs.alignment > rhs.alignment; } }; @@ -221,7 +222,7 @@ pub fn MultiArrayList(comptime S: type) type { /// retain list ordering. pub fn swapRemove(self: *Self, index: usize) void { const slices = self.slice(); - inline for (fields) |field_info, i| { + inline for (fields) |_, i| { const field_slice = slices.items(@intToEnum(Field, i)); field_slice[index] = field_slice[self.len - 1]; field_slice[self.len - 1] = undefined; @@ -233,7 +234,7 @@ pub fn MultiArrayList(comptime S: type) type { /// after it to preserve order. pub fn orderedRemove(self: *Self, index: usize) void { const slices = self.slice(); - inline for (fields) |field_info, field_index| { + inline for (fields) |_, field_index| { const field_slice = slices.items(@intToEnum(Field, field_index)); var i = index; while (i < self.len - 1) : (i += 1) { diff --git a/lib/std/net.zig b/lib/std/net.zig index ff0e299a7e011e5bbe733f7ff00a647185b5f9e9..46d9bee15da04e1605853e9f261aa696f92551af 100644 --- a/lib/std/net.zig +++ b/lib/std/net.zig @@ -270,6 +270,8 @@ pub const Ip4Address = extern struct { options: std.fmt.FormatOptions, out_stream: anytype, ) !void { + _ = fmt; + _ = options; const bytes = @ptrCast(*const [4]u8, &self.sa.addr); try std.fmt.format(out_stream, "{}.{}.{}.{}:{}", .{ bytes[0], @@ -281,6 +283,7 @@ pub const Ip4Address = extern struct { } pub fn getOsSockLen(self: Ip4Address) os.socklen_t { + _ = self; return @sizeOf(os.sockaddr_in); } }; @@ -556,6 +559,8 @@ pub const Ip6Address = extern struct { options: std.fmt.FormatOptions, out_stream: anytype, ) !void { + _ = fmt; + _ = options; const port = mem.bigToNative(u16, self.sa.port); if (mem.eql(u8, self.sa.addr[0..12], &[_]u8{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xff, 0xff })) { try std.fmt.format(out_stream, "[::ffff:{}.{}.{}.{}]:{}", .{ @@ -598,6 +603,7 @@ pub const Ip6Address = extern struct { } pub fn getOsSockLen(self: Ip6Address) os.socklen_t { + _ = self; return @sizeOf(os.sockaddr_in6); } }; @@ -1062,6 +1068,7 @@ fn IN6_IS_ADDR_SITELOCAL(a: [16]u8) bool { // Parameters `b` and `a` swapped to make this descending. fn addrCmpLessThan(context: void, b: LookupAddr, a: LookupAddr) bool { + _ = context; return a.sortkey < b.sortkey; } diff --git a/lib/std/once.zig b/lib/std/once.zig index c56e57257059735375503a06ea1c04b8f2eb0395..05f003c796e9f9770a0566f22326c824f440936a 100644 --- a/lib/std/once.zig +++ b/lib/std/once.zig @@ -61,6 +61,7 @@ test "Once executes its function just once" { for (threads) |*handle| { handle.* = try std.Thread.spawn(struct { fn thread_fn(x: u8) void { + _ = x; global_once.call(); } }.thread_fn, 0); diff --git a/lib/std/os.zig b/lib/std/os.zig index 307cc6990ad4c854a48d44a8be103d4312f58e05..968d0a26f60ea1d5c66e6bf6271366cfea6fd3df 100644 --- a/lib/std/os.zig +++ b/lib/std/os.zig @@ -1164,6 +1164,7 @@ fn openOptionsFromFlags(flags: u32) windows.OpenFileOptions { /// TODO currently, this function does not handle all flag combinations /// or makes use of perm argument. pub fn openW(file_path_w: []const u16, flags: u32, perm: mode_t) OpenError!fd_t { + _ = perm; var options = openOptionsFromFlags(flags); options.dir = std.fs.cwd().fd; return windows.OpenFile(file_path_w, options) catch |err| switch (err) { @@ -1273,6 +1274,7 @@ pub fn openatZ(dir_fd: fd_t, file_path: [*:0]const u8, flags: u32, mode: mode_t) /// TODO currently, this function does not handle all flag combinations /// or makes use of perm argument. pub fn openatW(dir_fd: fd_t, file_path_w: []const u16, flags: u32, mode: mode_t) OpenError!fd_t { + _ = mode; var options = openOptionsFromFlags(flags); options.dir = dir_fd; return windows.OpenFile(file_path_w, options) catch |err| switch (err) { @@ -2169,6 +2171,7 @@ pub fn mkdirat(dir_fd: fd_t, sub_dir_path: []const u8, mode: u32) MakeDirError!v pub const mkdiratC = @compileError("deprecated: renamed to mkdiratZ"); pub fn mkdiratWasi(dir_fd: fd_t, sub_dir_path: []const u8, mode: u32) MakeDirError!void { + _ = mode; switch (wasi.path_create_directory(dir_fd, sub_dir_path.ptr, sub_dir_path.len)) { wasi.ESUCCESS => return, wasi.EACCES => return error.AccessDenied, @@ -2216,6 +2219,7 @@ pub fn mkdiratZ(dir_fd: fd_t, sub_dir_path: [*:0]const u8, mode: u32) MakeDirErr } pub fn mkdiratW(dir_fd: fd_t, sub_path_w: []const u16, mode: u32) MakeDirError!void { + _ = mode; const sub_dir_handle = windows.OpenFile(sub_path_w, .{ .dir = dir_fd, .access_mask = windows.GENERIC_READ | windows.SYNCHRONIZE, @@ -2291,6 +2295,7 @@ pub fn mkdirZ(dir_path: [*:0]const u8, mode: u32) MakeDirError!void { /// Windows-only. Same as `mkdir` but the parameters is WTF16 encoded. pub fn mkdirW(dir_path_w: []const u16, mode: u32) MakeDirError!void { + _ = mode; const sub_dir_handle = windows.OpenFile(dir_path_w, .{ .dir = std.fs.cwd().fd, .access_mask = windows.GENERIC_READ | windows.SYNCHRONIZE, @@ -3868,6 +3873,7 @@ pub fn accessZ(path: [*:0]const u8, mode: u32) AccessError!void { /// Otherwise use `access` or `accessC`. /// TODO currently this ignores `mode`. pub fn accessW(path: [*:0]const u16, mode: u32) windows.GetFileAttributesError!void { + _ = mode; const ret = try windows.GetFileAttributesW(path); if (ret != windows.INVALID_FILE_ATTRIBUTES) { return; @@ -3918,6 +3924,8 @@ pub fn faccessatZ(dirfd: fd_t, path: [*:0]const u8, mode: u32, flags: u32) Acces /// is NtDll-prefixed, null-terminated, WTF-16 encoded. /// TODO currently this ignores `mode` and `flags` pub fn faccessatW(dirfd: fd_t, sub_path_w: [*:0]const u16, mode: u32, flags: u32) AccessError!void { + _ = mode; + _ = flags; if (sub_path_w[0] == '.' and sub_path_w[1] == 0) { return; } @@ -4895,6 +4903,8 @@ pub fn res_mkquery( newrr: ?[*]const u8, buf: []u8, ) usize { + _ = data; + _ = newrr; // This implementation is ported from musl libc. // A more idiomatic "ziggy" implementation would be welcome. var name = dname; diff --git a/lib/std/os/bits/linux.zig b/lib/std/os/bits/linux.zig index d4491da6d03caacd032c45b9de2a7df499f0b5b1..7501d54bbeb0c31b009a49169d38d01ff4ada141 100644 --- a/lib/std/os/bits/linux.zig +++ b/lib/std/os/bits/linux.zig @@ -1286,7 +1286,7 @@ pub const CAP_BLOCK_SUSPEND = 36; pub const CAP_AUDIT_READ = 37; pub const CAP_LAST_CAP = CAP_AUDIT_READ; -pub fn cap_valid(u8: x) bool { +pub fn cap_valid(x: u8) bool { return x >= 0 and x <= CAP_LAST_CAP; } diff --git a/lib/std/os/linux.zig b/lib/std/os/linux.zig index 792b4dff96028e8a6dbe4cc563696871ae082429..a4ad8e33f9a5ce05650a042700092714a5620bb1 100644 --- a/lib/std/os/linux.zig +++ b/lib/std/os/linux.zig @@ -70,6 +70,7 @@ fn splitValueLE64(val: i64) [2]u32 { }; } fn splitValueBE64(val: i64) [2]u32 { + _ = val; return [2]u32{ @truncate(u32, u >> 32), @truncate(u32, u), @@ -1022,7 +1023,7 @@ pub fn sendmmsg(fd: i32, msgvec: [*]mmsghdr_const, vlen: u32, flags: u32) usize for (msgvec[0..kvlen]) |*msg, i| { var size: i32 = 0; const msg_iovlen = @intCast(usize, msg.msg_hdr.msg_iovlen); // kernel side this is treated as unsigned - for (msg.msg_hdr.msg_iov[0..msg_iovlen]) |iov, j| { + for (msg.msg_hdr.msg_iov[0..msg_iovlen]) |iov| { if (iov.iov_len > std.math.maxInt(i32) or @addWithOverflow(i32, size, @intCast(i32, iov.iov_len), &size)) { // batch-send all messages up to the current message if (next_unsent < i) { diff --git a/lib/std/os/linux/bpf.zig b/lib/std/os/linux/bpf.zig index 4249e7774bbc0e1a41a0595301beaf5a1ee33a76..502676a7bc99e4bbec72c9ff210820196b83e952 100644 --- a/lib/std/os/linux/bpf.zig +++ b/lib/std/os/linux/bpf.zig @@ -1513,7 +1513,7 @@ pub fn map_create(map_type: MapType, key_size: u32, value_size: u32, max_entries EINVAL => error.MapTypeOrAttrInvalid, ENOMEM => error.SystemResources, EPERM => error.AccessDenied, - else => |err| unexpectedErrno(rc), + else => unexpectedErrno(rc), }; } @@ -1539,7 +1539,7 @@ pub fn map_lookup_elem(fd: fd_t, key: []const u8, value: []u8) !void { EINVAL => return error.FieldInAttrNeedsZeroing, ENOENT => return error.NotFound, EPERM => return error.AccessDenied, - else => |err| return unexpectedErrno(rc), + else => return unexpectedErrno(rc), } } diff --git a/lib/std/os/linux/io_uring.zig b/lib/std/os/linux/io_uring.zig index 22caac90382e5301ff4b2e38b613bb3a22d69ecd..dd7956f0c15301c6d718ad94f48198497956086b 100644 --- a/lib/std/os/linux/io_uring.zig +++ b/lib/std/os/linux/io_uring.zig @@ -284,6 +284,7 @@ pub const IO_Uring = struct { } fn copy_cqes_ready(self: *IO_Uring, cqes: []io_uring_cqe, wait_nr: u32) u32 { + _ = wait_nr; const ready = self.cq_ready(); const count = std.math.min(cqes.len, ready); var head = self.cq.head.*; @@ -320,6 +321,7 @@ pub const IO_Uring = struct { /// Not idempotent, calling more than once will result in other CQEs being lost. /// Matches the implementation of cqe_seen() in liburing. pub fn cqe_seen(self: *IO_Uring, cqe: *io_uring_cqe) void { + _ = cqe; self.cq_advance(1); } @@ -728,6 +730,7 @@ pub const CompletionQueue = struct { } pub fn deinit(self: *CompletionQueue) void { + _ = self; // A no-op since we now share the mmap with the submission queue. // Here for symmetry with the submission queue, and for any future feature support. } diff --git a/lib/std/os/linux/mips.zig b/lib/std/os/linux/mips.zig index ddb3103cfa075bbea85ade2d99c883faa8585c3b..26f62bfe0f01b917574222277ef51c99a412ecb8 100644 --- a/lib/std/os/linux/mips.zig +++ b/lib/std/os/linux/mips.zig @@ -18,6 +18,7 @@ pub fn syscall0(number: SYS) usize { } pub fn syscall_pipe(fd: *[2]i32) usize { + _ = fd; return asm volatile ( \\ .set noat \\ .set noreorder diff --git a/lib/std/os/test.zig b/lib/std/os/test.zig index 6e2aa2aeb965f32b1aa24f0d6a3e7fa12034a5f1..7a88ecd7caf246fb1db163e47cb2c558cae194e6 100644 --- a/lib/std/os/test.zig +++ b/lib/std/os/test.zig @@ -353,6 +353,7 @@ test "spawn threads" { } fn start1(ctx: void) u8 { + _ = ctx; return 0; } @@ -379,6 +380,7 @@ test "thread local storage" { threadlocal var x: i32 = 1234; fn testTls(context: void) !void { + _ = context; if (x != 1234) return error.TlsBadStartValue; x += 1; if (x != 1235) return error.TlsBadEndValue; @@ -425,6 +427,7 @@ const IterFnError = error{ }; fn iter_fn(info: *dl_phdr_info, size: usize, counter: *usize) IterFnError!void { + _ = size; // Count how many libraries are loaded counter.* += @as(usize, 1); @@ -731,6 +734,7 @@ test "sigaction" { const S = struct { fn handler(sig: i32, info: *const os.siginfo_t, ctx_ptr: ?*const c_void) callconv(.C) void { + _ = ctx_ptr; // Check that we received the correct signal. switch (native_os) { .netbsd => { diff --git a/lib/std/os/uefi.zig b/lib/std/os/uefi.zig index 19421659992b2d417c733b793b5ce46b1e906e1c..4bb8e375599e13087bce2eee604ccfa69e77a70f 100644 --- a/lib/std/os/uefi.zig +++ b/lib/std/os/uefi.zig @@ -37,6 +37,7 @@ pub const Guid = extern struct { options: std.fmt.FormatOptions, writer: anytype, ) !void { + _ = options; if (f.len == 0) { return std.fmt.format(writer, "{x:0>8}-{x:0>4}-{x:0>4}-{x:0>2}{x:0>2}-{x:0>12}", .{ self.time_low, diff --git a/lib/std/os/uefi/protocols/managed_network_protocol.zig b/lib/std/os/uefi/protocols/managed_network_protocol.zig index 6652107a1a5d6d8485e5169bc9a756039cb375a1..0da6d902f32c3656d32f9e639dab3593b06750b9 100644 --- a/lib/std/os/uefi/protocols/managed_network_protocol.zig +++ b/lib/std/os/uefi/protocols/managed_network_protocol.zig @@ -35,6 +35,7 @@ pub const ManagedNetworkProtocol = extern struct { /// Translates an IP multicast address to a hardware (MAC) multicast address. /// This function may be unsupported in some MNP implementations. pub fn mcastIpToMac(self: *const ManagedNetworkProtocol, ipv6flag: bool, ipaddress: *const c_void, mac_address: *MacAddress) Status { + _ = mac_address; return self._mcast_ip_to_mac(self, ipv6flag, ipaddress); } diff --git a/lib/std/packed_int_array.zig b/lib/std/packed_int_array.zig index ec401e98e2b532c0a31fa64c67c0cd9a1d26b389..571aae6e4d013afdb17f45fa293366d5dd803068 100644 --- a/lib/std/packed_int_array.zig +++ b/lib/std/packed_int_array.zig @@ -194,6 +194,7 @@ pub fn PackedIntArrayEndian(comptime Int: type, comptime endian: Endian, comptim ///Returns the number of elements in the packed array pub fn len(self: Self) usize { + _ = self; return int_count; } diff --git a/lib/std/pdb.zig b/lib/std/pdb.zig index d6d28084d91a9fccc9f47ac5ef31a1174e0aa6db..30b98941b0661282dc17c07497e726501c94c57b 100644 --- a/lib/std/pdb.zig +++ b/lib/std/pdb.zig @@ -675,6 +675,7 @@ pub const Pdb = struct { } pub fn getSymbolName(self: *Pdb, module: *Module, address: u64) ?[]const u8 { + _ = self; std.debug.assert(module.populated); var symbol_i: usize = 0; @@ -906,7 +907,7 @@ const Msf = struct { // These streams are not used, but still participate in the file // and must be taken into account when resolving stream indices. const Nil = 0xFFFFFFFF; - for (stream_sizes) |*s, i| { + for (stream_sizes) |*s| { const size = try directory.reader().readIntLittle(u32); s.* = if (size == Nil) 0 else blockCountFromSize(size, superblock.BlockSize); } diff --git a/lib/std/priority_dequeue.zig b/lib/std/priority_dequeue.zig index 0bb1f1350356f50e43188e99e3e58cba989f1994..81329a0a74c9b37467830c49d94665eacd256829 100644 --- a/lib/std/priority_dequeue.zig +++ b/lib/std/priority_dequeue.zig @@ -428,7 +428,7 @@ pub fn PriorityDequeue(comptime T: type) type { warn("{}, ", .{e}); } warn("array: ", .{}); - for (self.items) |e, i| { + for (self.items) |e| { warn("{}, ", .{e}); } warn("len: {} ", .{self.len}); diff --git a/lib/std/priority_queue.zig b/lib/std/priority_queue.zig index 4e5320a92b7d4caeeb423d859d23a07a39ebe555..de68442ea75fa83d2f76b03f3fe0860ed4802049 100644 --- a/lib/std/priority_queue.zig +++ b/lib/std/priority_queue.zig @@ -249,7 +249,7 @@ pub fn PriorityQueue(comptime T: type) type { warn("{}, ", .{e}); } warn("array: ", .{}); - for (self.items) |e, i| { + for (self.items) |e| { warn("{}, ", .{e}); } warn("len: {} ", .{self.len}); diff --git a/lib/std/process.zig b/lib/std/process.zig index d5a20456992cd126e5a8007b5e4d53c3dd3e01a3..83926ee5af4d9810d52a775663e8fd2f38a9dd6c 100644 --- a/lib/std/process.zig +++ b/lib/std/process.zig @@ -419,6 +419,7 @@ pub const ArgIteratorWindows = struct { }; } fn emitBackslashes(self: *ArgIteratorWindows, buf: *std.ArrayList(u16), emit_count: usize) !void { + _ = self; var i: usize = 0; while (i < emit_count) : (i += 1) { try buf.append(std.mem.nativeToLittle(u16, '\\')); @@ -748,6 +749,7 @@ pub fn getSelfExeSharedLibPaths(allocator: *Allocator) error{OutOfMemory}![][:0] } try os.dl_iterate_phdr(&paths, error{OutOfMemory}, struct { fn callback(info: *os.dl_phdr_info, size: usize, list: *List) !void { + _ = size; const name = info.dlpi_name orelse return; if (name[0] == '/') { const item = try list.allocator.dupeZ(u8, mem.spanZ(name)); diff --git a/lib/std/sort.zig b/lib/std/sort.zig index 2d84beaef63b207890f8873321cc437734e420f8..67a4394b1ebba1709ef7046492f910065461d699 100644 --- a/lib/std/sort.zig +++ b/lib/std/sort.zig @@ -37,9 +37,11 @@ pub fn binarySearch( test "binarySearch" { const S = struct { fn order_u32(context: void, lhs: u32, rhs: u32) math.Order { + _ = context; return math.order(lhs, rhs); } fn order_i32(context: void, lhs: i32, rhs: i32) math.Order { + _ = context; return math.order(lhs, rhs); } }; @@ -1133,6 +1135,7 @@ fn swap( pub fn asc(comptime T: type) fn (void, T, T) bool { const impl = struct { fn inner(context: void, a: T, b: T) bool { + _ = context; return a < b; } }; @@ -1144,6 +1147,7 @@ pub fn asc(comptime T: type) fn (void, T, T) bool { pub fn desc(comptime T: type) fn (void, T, T) bool { const impl = struct { fn inner(context: void, a: T, b: T) bool { + _ = context; return a > b; } }; diff --git a/lib/std/special/c.zig b/lib/std/special/c.zig index 1377212870b934e445d1c30693217c0364318a24..a6de965f9047bd2667af9218b3704d41ae9d2be5 100644 --- a/lib/std/special/c.zig +++ b/lib/std/special/c.zig @@ -160,6 +160,7 @@ fn strncmp(_l: [*:0]const u8, _r: [*:0]const u8, _n: usize) callconv(.C) c_int { } fn strerror(errnum: c_int) callconv(.C) [*:0]const u8 { + _ = errnum; return "TODO strerror implementation"; } @@ -173,6 +174,7 @@ test "strncmp" { // Avoid dragging in the runtime safety mechanisms into this .o file, // unless we're trying to test this file. pub fn panic(msg: []const u8, error_return_trace: ?*builtin.StackTrace) noreturn { + _ = error_return_trace; if (builtin.is_test) { @setCold(true); std.debug.panic("{s}", .{msg}); diff --git a/lib/std/special/compiler_rt.zig b/lib/std/special/compiler_rt.zig index a777067800e47e9cf6397623357afa2602b1934f..dcbdebec739e00cb5a5481e52e40ae8ef2c34afb 100644 --- a/lib/std/special/compiler_rt.zig +++ b/lib/std/special/compiler_rt.zig @@ -602,6 +602,7 @@ pub usingnamespace @import("compiler_rt/atomics.zig"); // Avoid dragging in the runtime safety mechanisms into this .o file, // unless we're trying to test this file. pub fn panic(msg: []const u8, error_return_trace: ?*builtin.StackTrace) noreturn { + _ = error_return_trace; @setCold(true); if (is_test) { std.debug.panic("{s}", .{msg}); diff --git a/lib/std/special/compiler_rt/atomics.zig b/lib/std/special/compiler_rt/atomics.zig index e448a580ca5cffff488a394af9ffa2dd83dee6cd..1b592da0196d4ae9281e39674e302f6bd169b63b 100644 --- a/lib/std/special/compiler_rt/atomics.zig +++ b/lib/std/special/compiler_rt/atomics.zig @@ -80,18 +80,21 @@ var spinlocks: SpinlockTable = SpinlockTable{}; // Those work on any object no matter the pointer alignment nor its size. fn __atomic_load(size: u32, src: [*]u8, dest: [*]u8, model: i32) callconv(.C) void { + _ = model; var sl = spinlocks.get(@ptrToInt(src)); defer sl.release(); @memcpy(dest, src, size); } fn __atomic_store(size: u32, dest: [*]u8, src: [*]u8, model: i32) callconv(.C) void { + _ = model; var sl = spinlocks.get(@ptrToInt(dest)); defer sl.release(); @memcpy(dest, src, size); } fn __atomic_exchange(size: u32, ptr: [*]u8, val: [*]u8, old: [*]u8, model: i32) callconv(.C) void { + _ = model; var sl = spinlocks.get(@ptrToInt(ptr)); defer sl.release(); @memcpy(old, ptr, size); @@ -106,6 +109,8 @@ fn __atomic_compare_exchange( success: i32, failure: i32, ) callconv(.C) i32 { + _ = success; + _ = failure; var sl = spinlocks.get(@ptrToInt(ptr)); defer sl.release(); for (ptr[0..size]) |b, i| { @@ -135,6 +140,7 @@ comptime { fn atomicLoadFn(comptime T: type) fn (*T, i32) callconv(.C) T { return struct { fn atomic_load_N(src: *T, model: i32) callconv(.C) T { + _ = model; if (@sizeOf(T) > largest_atomic_size) { var sl = spinlocks.get(@ptrToInt(src)); defer sl.release(); @@ -162,6 +168,7 @@ comptime { fn atomicStoreFn(comptime T: type) fn (*T, T, i32) callconv(.C) void { return struct { fn atomic_store_N(dst: *T, value: T, model: i32) callconv(.C) void { + _ = model; if (@sizeOf(T) > largest_atomic_size) { var sl = spinlocks.get(@ptrToInt(dst)); defer sl.release(); @@ -189,6 +196,7 @@ comptime { fn atomicExchangeFn(comptime T: type) fn (*T, T, i32) callconv(.C) T { return struct { fn atomic_exchange_N(ptr: *T, val: T, model: i32) callconv(.C) T { + _ = model; if (@sizeOf(T) > largest_atomic_size) { var sl = spinlocks.get(@ptrToInt(ptr)); defer sl.release(); @@ -218,6 +226,8 @@ comptime { fn atomicCompareExchangeFn(comptime T: type) fn (*T, *T, T, i32, i32) callconv(.C) i32 { return struct { fn atomic_compare_exchange_N(ptr: *T, expected: *T, desired: T, success: i32, failure: i32) callconv(.C) i32 { + _ = success; + _ = failure; if (@sizeOf(T) > largest_atomic_size) { var sl = spinlocks.get(@ptrToInt(ptr)); defer sl.release(); @@ -255,6 +265,7 @@ comptime { fn fetchFn(comptime T: type, comptime op: builtin.AtomicRmwOp) fn (*T, T, i32) callconv(.C) T { return struct { pub fn fetch_op_N(ptr: *T, val: T, model: i32) callconv(.C) T { + _ = model; if (@sizeOf(T) > largest_atomic_size) { var sl = spinlocks.get(@ptrToInt(ptr)); defer sl.release(); diff --git a/lib/std/special/compiler_rt/comparedf2_test.zig b/lib/std/special/compiler_rt/comparedf2_test.zig index b0916c10ae5533e9505f6066de49ad172aab88fa..ad3e26f915dde847c06ae9b83b50405b79b2e074 100644 --- a/lib/std/special/compiler_rt/comparedf2_test.zig +++ b/lib/std/special/compiler_rt/comparedf2_test.zig @@ -101,6 +101,7 @@ const test_vectors = init: { test "compare f64" { for (test_vectors) |vector, i| { + _ = i; try std.testing.expect(test__cmpdf2(vector)); } } diff --git a/lib/std/special/compiler_rt/comparesf2_test.zig b/lib/std/special/compiler_rt/comparesf2_test.zig index 9719873f624bc5b369ef86ec10df18f8627d922f..b50fd59d9d232807b6b3662926115957bc9604f4 100644 --- a/lib/std/special/compiler_rt/comparesf2_test.zig +++ b/lib/std/special/compiler_rt/comparesf2_test.zig @@ -101,6 +101,7 @@ const test_vectors = init: { test "compare f32" { for (test_vectors) |vector, i| { + _ = i; try std.testing.expect(test__cmpsf2(vector)); } } diff --git a/lib/std/special/ssp.zig b/lib/std/special/ssp.zig index 81db44a5347ad084e114b30bb981a6c22d623ffe..6eda11b2e2fa02cbdad9a1dbb46380db5990a097 100644 --- a/lib/std/special/ssp.zig +++ b/lib/std/special/ssp.zig @@ -27,6 +27,8 @@ extern fn memmove(dest: ?[*]u8, src: ?[*]const u8, n: usize) callconv(.C) ?[*]u8 // Avoid dragging in the runtime safety mechanisms into this .o file. pub fn panic(msg: []const u8, error_return_trace: ?*builtin.StackTrace) noreturn { + _ = msg; + _ = error_return_trace; @setCold(true); if (@hasDecl(std.os, "abort")) std.os.abort(); diff --git a/lib/std/target.zig b/lib/std/target.zig index faebe665ab6d8efd6193b249b8553dd37a179b5e..02ce44d47787d55a31e661a7e51ccd02315cafbb 100644 --- a/lib/std/target.zig +++ b/lib/std/target.zig @@ -157,7 +157,7 @@ pub const Target = struct { pub fn format( self: WindowsVersion, comptime fmt: []const u8, - options: std.fmt.FormatOptions, + _: std.fmt.FormatOptions, out_stream: anytype, ) !void { if (fmt.len > 0 and fmt[0] == 's') { diff --git a/lib/std/unicode.zig b/lib/std/unicode.zig index 48310e17dac1353ee16f79c6d19c47aa1ccf62bd..0b0e470efb220ddb0b69bb40c99dbf5a21df8c89 100644 --- a/lib/std/unicode.zig +++ b/lib/std/unicode.zig @@ -210,7 +210,7 @@ pub fn utf8ValidateSlice(s: []const u8) bool { return false; } i += cp_len; - } else |err| { + } else |_| { return false; } } diff --git a/lib/std/x/net/ip.zig b/lib/std/x/net/ip.zig index 7f2d82d2085cef26a4d1d83fbae51edde44a5025..409a8ebadfc595bcb52a2daae0a2d8bd0218e794 100644 --- a/lib/std/x/net/ip.zig +++ b/lib/std/x/net/ip.zig @@ -53,6 +53,8 @@ pub const Address = union(enum) { opts: fmt.FormatOptions, writer: anytype, ) !void { + _ = opts; + _ = layout; switch (self) { .ipv4 => |address| try fmt.format(writer, "{}:{}", .{ address.host, address.port }), .ipv6 => |address| try fmt.format(writer, "{}:{}", .{ address.host, address.port }), diff --git a/lib/std/x/os/net.zig b/lib/std/x/os/net.zig index bbb2c105a77b8fd4fce7a6ee963336855a94fd1f..d94692693257a4947994acb44020c8d854647ee1 100644 --- a/lib/std/x/os/net.zig +++ b/lib/std/x/os/net.zig @@ -143,6 +143,7 @@ pub const IPv4 = extern struct { opts: fmt.FormatOptions, writer: anytype, ) !void { + _ = opts; if (comptime layout.len != 0 and layout[0] != 's') { @compileError("Unsupported format specifier for IPv4 type '" ++ layout ++ "'."); } @@ -352,6 +353,7 @@ pub const IPv6 = extern struct { opts: fmt.FormatOptions, writer: anytype, ) !void { + _ = opts; const specifier = comptime &[_]u8{if (layout.len == 0) 'x' else switch (layout[0]) { 'x', 'X' => |specifier| specifier, 's' => 'x', diff --git a/lib/std/x/os/socket.zig b/lib/std/x/os/socket.zig index 61e47939f8de3bacd964560a85706570f2342d78..9da74d5b0ea26306a5d3e42f39de0d4c2f196c2a 100644 --- a/lib/std/x/os/socket.zig +++ b/lib/std/x/os/socket.zig @@ -117,7 +117,7 @@ pub const Socket = struct { }; } - /// Returns the number of bytes that make up the `sockaddr` equivalent to the address. + /// Returns the number of bytes that make up the `sockaddr` equivalent to the address. pub fn getNativeSize(self: Socket.Address) u32 { return switch (self) { .ipv4 => @sizeOf(os.sockaddr_in), @@ -132,6 +132,8 @@ pub const Socket = struct { opts: fmt.FormatOptions, writer: anytype, ) !void { + _ = opts; + _ = layout; switch (self) { .ipv4 => |address| try fmt.format(writer, "{}:{}", .{ address.host, address.port }), .ipv6 => |address| try fmt.format(writer, "{}:{}", .{ address.host, address.port }), @@ -280,7 +282,7 @@ pub const Socket = struct { /// /// Microsoft's documentation and glibc denote the fields to be unsigned /// short's on Windows, whereas glibc and musl denote the fields to be - /// int's on every other platform. + /// int's on every other platform. pub const Linger = extern struct { pub const Field = switch (native_os.tag) { .windows => c_ushort, diff --git a/lib/std/x/os/socket_windows.zig b/lib/std/x/os/socket_windows.zig index d479d8619ad3fa911ad72704ea23ef92e84e09b6..c08931fedf01c3d270137cdcec3be512da0fdf19 100644 --- a/lib/std/x/os/socket_windows.zig +++ b/lib/std/x/os/socket_windows.zig @@ -292,6 +292,7 @@ pub fn Mixin(comptime Socket: type) type { /// with a set of flags specified. It returns the number of bytes that were /// read into the buffer provided. pub fn readMessage(self: Socket, msg: *Socket.Message, flags: u32) !usize { + _ = flags; const call = try windows.loadWinsockExtensionFunction(ws2_32.LPFN_WSARECVMSG, self.fd, ws2_32.WSAID_WSARECVMSG); var num_bytes: u32 = undefined; @@ -367,16 +368,19 @@ pub fn Mixin(comptime Socket: type) type { /// Query and return the latest cached error on the socket. pub fn getError(self: Socket) !void { + _ = self; return {}; } /// Query the read buffer size of the socket. pub fn getReadBufferSize(self: Socket) !u32 { + _ = self; return 0; } /// Query the write buffer size of the socket. pub fn getWriteBufferSize(self: Socket) !u32 { + _ = self; return 0; } @@ -406,7 +410,7 @@ pub fn Mixin(comptime Socket: type) type { /// On connection-oriented sockets, have keep-alive messages be sent periodically. The timing in which keep-alive /// messages are sent are dependant on operating system settings. It returns `error.UnsupportedSocketOption` if - /// the host does not support periodically sending keep-alive messages on connection-oriented sockets. + /// the host does not support periodically sending keep-alive messages on connection-oriented sockets. pub fn setKeepAlive(self: Socket, enabled: bool) !void { return self.setOption(ws2_32.SOL_SOCKET, ws2_32.SO_KEEPALIVE, mem.asBytes(&@as(u32, @boolToInt(enabled)))); } @@ -438,7 +442,7 @@ pub fn Mixin(comptime Socket: type) type { /// WARNING: Timeouts only affect blocking sockets. It is undefined behavior if a timeout is /// set on a non-blocking socket. - /// + /// /// Set a timeout on the socket that is to occur if no messages are successfully written /// to its bound destination after a specified number of milliseconds. A subsequent write /// to the socket will thereafter return `error.WouldBlock` should the timeout be exceeded. @@ -448,7 +452,7 @@ pub fn Mixin(comptime Socket: type) type { /// WARNING: Timeouts only affect blocking sockets. It is undefined behavior if a timeout is /// set on a non-blocking socket. - /// + /// /// Set a timeout on the socket that is to occur if no messages are successfully read /// from its bound destination after a specified number of milliseconds. A subsequent /// read from the socket will thereafter return `error.WouldBlock` should the timeout be diff --git a/lib/std/zig/ast.zig b/lib/std/zig/ast.zig index 6a7919e0e4443c8bac6795684ed37b4689bab240..59fe2fdff13b48268d26c9caeddc979b479404f3 100644 --- a/lib/std/zig/ast.zig +++ b/lib/std/zig/ast.zig @@ -1866,6 +1866,7 @@ pub const Tree = struct { } fn fullStructInit(tree: Tree, info: full.StructInit.Ast) full.StructInit { + _ = tree; var result: full.StructInit = .{ .ast = info, }; diff --git a/lib/std/zig/c_builtins.zig b/lib/std/zig/c_builtins.zig index d8a23ec8f1ed116334d637fc08611255132eabdc..afa3ae0a873356a165928f55cf0dc6958fff51ce 100644 --- a/lib/std/zig/c_builtins.zig +++ b/lib/std/zig/c_builtins.zig @@ -136,6 +136,7 @@ pub inline fn __builtin_strcmp(s1: [*c]const u8, s2: [*c]const u8) c_int { } pub inline fn __builtin_object_size(ptr: ?*const c_void, ty: c_int) usize { + _ = ptr; // clang semantics match gcc's: https://gcc.gnu.org/onlinedocs/gcc/Object-Size-Checking.html // If it is not possible to determine which objects ptr points to at compile time, // __builtin_object_size should return (size_t) -1 for type 0 or 1 and (size_t) 0 @@ -186,6 +187,7 @@ pub inline fn __builtin_memcpy( /// The return value of __builtin_expect is `expr`. `c` is the expected value /// of `expr` and is used as a hint to the compiler in C. Here it is unused. pub inline fn __builtin_expect(expr: c_long, c: c_long) c_long { + _ = c; return expr; } diff --git a/lib/std/zig/fmt.zig b/lib/std/zig/fmt.zig index 3a55b5df300825c98d3a9d4eb9882f63cc8bedd4..2afbe1d91b23963a003f019a909492529c295b0f 100644 --- a/lib/std/zig/fmt.zig +++ b/lib/std/zig/fmt.zig @@ -8,6 +8,7 @@ pub fn formatId( options: std.fmt.FormatOptions, writer: anytype, ) !void { + _ = fmt; if (isValidId(bytes)) { return writer.writeAll(bytes); } @@ -41,6 +42,7 @@ pub fn formatEscapes( options: std.fmt.FormatOptions, writer: anytype, ) !void { + _ = options; for (bytes) |byte| switch (byte) { '\n' => try writer.writeAll("\\n"), '\r' => try writer.writeAll("\\r"), diff --git a/lib/std/zig/parse.zig b/lib/std/zig/parse.zig index 8f22bde97480e94b3680d080882615f0ecf018b0..5bafcce5b1827529bbec675af40e8db0682d5805 100644 --- a/lib/std/zig/parse.zig +++ b/lib/std/zig/parse.zig @@ -2104,7 +2104,7 @@ const Parser = struct { /// FnCallArguments <- LPAREN ExprList RPAREN /// ExprList <- (Expr COMMA)* Expr? fn parseSuffixExpr(p: *Parser) !Node.Index { - if (p.eatToken(.keyword_async)) |async_token| { + if (p.eatToken(.keyword_async)) |_| { var res = try p.expectPrimaryTypeExpr(); while (true) { const node = try p.parseSuffixOp(res); diff --git a/lib/std/zig/system.zig b/lib/std/zig/system.zig index 5fb948c64a20c6e9bac8bd14211c99cd6306f389..a4939b83474bb92c8ff00c6cbe74da9ed7a0d6dc 100644 --- a/lib/std/zig/system.zig +++ b/lib/std/zig/system.zig @@ -200,6 +200,7 @@ pub const NativePaths = struct { } fn appendArray(self: *NativePaths, array: *ArrayList([:0]u8), s: []const u8) !void { + _ = self; const item = try array.allocator.dupeZ(u8, s); errdefer array.allocator.free(item); try array.append(item); @@ -332,7 +333,7 @@ pub const NativeTargetInfo = struct { if (std.builtin.Version.parse(buf[0 .. len - 1])) |ver| { os.version_range.semver.min = ver; os.version_range.semver.max = ver; - } else |err| { + } else |_| { return error.OSVersionDetectionFail; } }, diff --git a/lib/std/zig/system/macos.zig b/lib/std/zig/system/macos.zig index 0b3e639582af695fbf3c7d5563912d09143bfcea..ae450ecae5dad2feb8a76ec7489fc428500743f3 100644 --- a/lib/std/zig/system/macos.zig +++ b/lib/std/zig/system/macos.zig @@ -68,10 +68,10 @@ pub fn detect(target_os: *Target.Os) !void { return; } continue; - } else |err| { + } else |_| { return error.OSVersionDetectionFail; } - } else |err| { + } else |_| { return error.OSVersionDetectionFail; } } diff --git a/lib/std/zig/system/x86.zig b/lib/std/zig/system/x86.zig index 9a33a1daafe867b9f1ea0ed84776d715021be18c..1d9a22d5d20a8a4a2d7c4facb6a6276414080abe 100644 --- a/lib/std/zig/system/x86.zig +++ b/lib/std/zig/system/x86.zig @@ -28,6 +28,7 @@ inline fn hasMask(input: u32, mask: u32) bool { } pub fn detectNativeCpuAndFeatures(arch: Target.Cpu.Arch, os: Target.Os, cross_target: CrossTarget) Target.Cpu { + _ = cross_target; var cpu = Target.Cpu{ .arch = arch, .model = Target.Cpu.Model.generic(arch), diff --git a/src/AstGen.zig b/src/AstGen.zig index 84f06e5423d17a050c2f077231b9b8379461852b..ec6f9518b16acf6773e852cb822905feda55a1d2 100644 --- a/src/AstGen.zig +++ b/src/AstGen.zig @@ -925,6 +925,7 @@ fn suspendExpr( rl: ResultLoc, node: ast.Node.Index, ) InnerError!Zir.Inst.Ref { + _ = rl; const astgen = gz.astgen; const gpa = astgen.gpa; const tree = astgen.tree; @@ -1208,6 +1209,7 @@ fn arrayInitExprRlNone( elements: []const ast.Node.Index, tag: Zir.Inst.Tag, ) InnerError!Zir.Inst.Ref { + _ = rl; const astgen = gz.astgen; const gpa = astgen.gpa; const elem_list = try gpa.alloc(Zir.Inst.Ref, elements.len); @@ -1233,6 +1235,9 @@ fn arrayInitExprRlTy( elem_ty_inst: Zir.Inst.Ref, tag: Zir.Inst.Tag, ) InnerError!Zir.Inst.Ref { + _ = rl; + _ = array_ty_inst; + _ = elem_ty_inst; const astgen = gz.astgen; const gpa = astgen.gpa; @@ -1259,6 +1264,7 @@ fn arrayInitExprRlPtr( elements: []const ast.Node.Index, result_ptr: Zir.Inst.Ref, ) InnerError!Zir.Inst.Ref { + _ = rl; const astgen = gz.astgen; const gpa = astgen.gpa; @@ -1368,6 +1374,7 @@ fn structInitExprRlNone( struct_init: ast.full.StructInit, tag: Zir.Inst.Tag, ) InnerError!Zir.Inst.Ref { + _ = rl; const astgen = gz.astgen; const gpa = astgen.gpa; const tree = astgen.tree; @@ -1403,6 +1410,7 @@ fn structInitExprRlPtr( struct_init: ast.full.StructInit, result_ptr: Zir.Inst.Ref, ) InnerError!Zir.Inst.Ref { + _ = rl; const astgen = gz.astgen; const gpa = astgen.gpa; const tree = astgen.tree; @@ -1439,6 +1447,7 @@ fn structInitExprRlTy( ty_inst: Zir.Inst.Ref, tag: Zir.Inst.Tag, ) InnerError!Zir.Inst.Ref { + _ = rl; const astgen = gz.astgen; const gpa = astgen.gpa; const tree = astgen.tree; @@ -1781,6 +1790,7 @@ fn blockExprStmts( node: ast.Node.Index, statements: []const ast.Node.Index, ) !void { + _ = node; const astgen = gz.astgen; const tree = astgen.tree; const node_tags = tree.nodes.items(.tag); @@ -2117,6 +2127,7 @@ fn genDefers( inner_scope: *Scope, err_code: Zir.Inst.Ref, ) InnerError!void { + _ = err_code; const astgen = gz.astgen; const tree = astgen.tree; const node_datas = tree.nodes.items(.data); @@ -2201,6 +2212,7 @@ fn deferStmt( block_arena: *Allocator, scope_tag: Scope.Tag, ) InnerError!*Scope { + _ = gz; const defer_scope = try block_arena.create(Scope.Defer); defer_scope.* = .{ .base = .{ .tag = scope_tag }, @@ -4703,6 +4715,8 @@ fn finishThenElseBlock( then_break_block: Zir.Inst.Index, break_tag: Zir.Inst.Tag, ) InnerError!Zir.Inst.Ref { + _ = then_src; + _ = else_src; // We now have enough information to decide whether the result instruction should // be communicated via result location pointer or break instructions. const strat = rl.strategy(block_scope); @@ -4886,7 +4900,7 @@ fn ifExpr( inst: Zir.Inst.Ref, bool_bit: Zir.Inst.Ref, } = c: { - if (if_full.error_token) |error_token| { + if (if_full.error_token) |_| { const cond_rl: ResultLoc = if (payload_is_ref) .ref else .none; const err_union = try expr(&block_scope, &block_scope.base, cond_rl, if_full.ast.cond_expr); const tag: Zir.Inst.Tag = if (payload_is_ref) .is_err_ptr else .is_err; @@ -4894,7 +4908,7 @@ fn ifExpr( .inst = err_union, .bool_bit = try block_scope.addUnNode(tag, err_union, node), }; - } else if (if_full.payload_token) |payload_token| { + } else if (if_full.payload_token) |_| { const cond_rl: ResultLoc = if (payload_is_ref) .ref else .none; const optional = try expr(&block_scope, &block_scope.base, cond_rl, if_full.ast.cond_expr); const tag: Zir.Inst.Tag = if (payload_is_ref) .is_non_null_ptr else .is_non_null; @@ -5146,7 +5160,7 @@ fn whileExpr( inst: Zir.Inst.Ref, bool_bit: Zir.Inst.Ref, } = c: { - if (while_full.error_token) |error_token| { + if (while_full.error_token) |_| { const cond_rl: ResultLoc = if (payload_is_ref) .ref else .none; const err_union = try expr(&continue_scope, &continue_scope.base, cond_rl, while_full.ast.cond_expr); const tag: Zir.Inst.Tag = if (payload_is_ref) .is_err_ptr else .is_err; @@ -5154,7 +5168,7 @@ fn whileExpr( .inst = err_union, .bool_bit = try continue_scope.addUnNode(tag, err_union, node), }; - } else if (while_full.payload_token) |payload_token| { + } else if (while_full.payload_token) |_| { const cond_rl: ResultLoc = if (payload_is_ref) .ref else .none; const optional = try expr(&continue_scope, &continue_scope.base, cond_rl, while_full.ast.cond_expr); const tag: Zir.Inst.Tag = if (payload_is_ref) .is_non_null_ptr else .is_non_null; @@ -6665,6 +6679,7 @@ fn unionInitRlPtr( union_type: Zir.Inst.Ref, field_name: Zir.Inst.Ref, ) InnerError!Zir.Inst.Ref { + _ = rl; const union_init_ptr = try parent_gz.addPlNode(.union_init_ptr, node, Zir.Inst.UnionInitPtr{ .result_ptr = result_ptr, .union_type = union_type, @@ -6753,6 +6768,8 @@ fn bitCastRlPtr( result_ptr: Zir.Inst.Ref, rhs: ast.Node.Index, ) InnerError!Zir.Inst.Ref { + _ = rl; + _ = scope; const casted_result_ptr = try gz.addPlNode(.bitcast_result_ptr, node, Zir.Inst.Bin{ .lhs = dest_type, .rhs = result_ptr, @@ -8013,6 +8030,7 @@ fn rvalue( result: Zir.Inst.Ref, src_node: ast.Node.Index, ) InnerError!Zir.Inst.Ref { + _ = scope; switch (rl) { .none, .none_or_ref => return result, .discard => { diff --git a/src/Compilation.zig b/src/Compilation.zig index f73d9410f2c8a41fdfcc0eefe9ba6423b2da214e..ec8b0c79bb07368cb99df8885ef6933a6b24a0a8 100644 --- a/src/Compilation.zig +++ b/src/Compilation.zig @@ -523,6 +523,7 @@ pub const AllErrors = struct { errors: *std.ArrayList(Message), msg: []const u8, ) !void { + _ = arena; try errors.append(.{ .plain = .{ .msg = msg } }); } diff --git a/src/Module.zig b/src/Module.zig index f2462e704cb65a40a94384dff560674753b66b84..e6bed16bbbfe95ddcbd0d043b069b61968edbf8f 100644 --- a/src/Module.zig +++ b/src/Module.zig @@ -774,7 +774,10 @@ pub const Fn = struct { ir.dumpFn(mod, func); } - pub fn deinit(func: *Fn, gpa: *Allocator) void {} + pub fn deinit(func: *Fn, gpa: *Allocator) void { + _ = func; + _ = gpa; + } }; pub const Var = struct { @@ -2209,6 +2212,7 @@ comptime { } pub fn astGenFile(mod: *Module, file: *Scope.File, prog_node: *std.Progress.Node) !void { + _ = prog_node; const tracy = trace(@src()); defer tracy.end(); @@ -3128,6 +3132,7 @@ pub const ImportFileResult = struct { }; pub fn importPkg(mod: *Module, cur_pkg: *Package, pkg: *Package) !ImportFileResult { + _ = cur_pkg; const gpa = mod.gpa; // The resolved path is used as the key in the import table, to detect if @@ -3384,7 +3389,7 @@ fn scanDecl(iter: *ScanDeclIter, decl_sub_index: usize, flags: u4) InnerError!vo decl.has_align = has_align; decl.has_linksection = has_linksection; decl.zir_decl_index = @intCast(u32, decl_sub_index); - if (decl.getFunction()) |func| { + if (decl.getFunction()) |_| { switch (mod.comp.bin_file.tag) { .coff => { // TODO Implement for COFF @@ -3753,6 +3758,7 @@ pub fn analyzeExport( errdefer de_gop.value_ptr.* = mod.gpa.shrink(de_gop.value_ptr.*, de_gop.value_ptr.len - 1); } pub fn constInst(mod: *Module, arena: *Allocator, src: LazySrcLoc, typed_value: TypedValue) !*ir.Inst { + _ = mod; const const_inst = try arena.create(ir.Inst.Constant); const_inst.* = .{ .base = .{ @@ -4121,6 +4127,7 @@ pub fn floatAdd( lhs: Value, rhs: Value, ) !Value { + _ = src; switch (float_type.tag()) { .f16 => { @panic("TODO add __trunctfhf2 to compiler-rt"); @@ -4154,6 +4161,7 @@ pub fn floatSub( lhs: Value, rhs: Value, ) !Value { + _ = src; switch (float_type.tag()) { .f16 => { @panic("TODO add __trunctfhf2 to compiler-rt"); @@ -4187,6 +4195,7 @@ pub fn floatDiv( lhs: Value, rhs: Value, ) !Value { + _ = src; switch (float_type.tag()) { .f16 => { @panic("TODO add __trunctfhf2 to compiler-rt"); @@ -4220,6 +4229,7 @@ pub fn floatMul( lhs: Value, rhs: Value, ) !Value { + _ = src; switch (float_type.tag()) { .f16 => { @panic("TODO add __trunctfhf2 to compiler-rt"); @@ -4253,6 +4263,7 @@ pub fn simplePtrType( mutable: bool, size: std.builtin.TypeInfo.Pointer.Size, ) Allocator.Error!Type { + _ = mod; if (!mutable and size == .Slice and elem_ty.eql(Type.initTag(.u8))) { return Type.initTag(.const_slice_u8); } @@ -4287,6 +4298,7 @@ pub fn ptrType( @"volatile": bool, size: std.builtin.TypeInfo.Pointer.Size, ) Allocator.Error!Type { + _ = mod; assert(host_size == 0 or bit_offset < host_size * 8); // TODO check if type can be represented by simplePtrType @@ -4304,6 +4316,7 @@ pub fn ptrType( } pub fn optionalType(mod: *Module, arena: *Allocator, child_type: Type) Allocator.Error!Type { + _ = mod; switch (child_type.tag()) { .single_const_pointer => return Type.Tag.optional_single_const_pointer.create( arena, @@ -4324,6 +4337,7 @@ pub fn arrayType( sentinel: ?Value, elem_type: Type, ) Allocator.Error!Type { + _ = mod; if (elem_type.eql(Type.initTag(.u8))) { if (sentinel) |some| { if (some.eql(Value.initTag(.zero))) { @@ -4354,6 +4368,7 @@ pub fn errorUnionType( error_set: Type, payload: Type, ) Allocator.Error!Type { + _ = mod; assert(error_set.zigTypeTag() == .ErrorSet); if (error_set.eql(Type.initTag(.anyerror)) and payload.eql(Type.initTag(.void))) { return Type.initTag(.anyerror_void_error_union); diff --git a/src/Sema.zig b/src/Sema.zig index 73a1cdf27e89acfd1830c209f20b5672f7c6da56..ce00578142f91e3ebdd986c7c286e23cb0d1e99b 100644 --- a/src/Sema.zig +++ b/src/Sema.zig @@ -702,6 +702,7 @@ fn zirBitcastResultPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) I } fn zirCoerceResultPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { + _ = inst; const tracy = trace(@src()); defer tracy.end(); return sema.mod.fail(&block.base, sema.src, "TODO implement zirCoerceResultPtr", .{}); @@ -776,6 +777,7 @@ fn zirStructDecl( } fn createTypeName(sema: *Sema, block: *Scope.Block, name_strategy: Zir.Inst.NameStrategy) ![:0]u8 { + _ = block; switch (name_strategy) { .anon => { // It would be neat to have "struct:line:column" but this name has @@ -1067,6 +1069,7 @@ fn zirOpaqueDecl( inst: Zir.Inst.Index, name_strategy: Zir.Inst.NameStrategy, ) InnerError!*Inst { + _ = name_strategy; const tracy = trace(@src()); defer tracy.end(); @@ -1242,6 +1245,7 @@ fn zirArg(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*In // TODO check if arg_name shadows a Decl if (block.inlining) |inlining| { + _ = inlining; return sema.param_inst_list[arg_index]; } @@ -1640,6 +1644,7 @@ fn zirStr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*In } fn zirInt(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { + _ = block; const tracy = trace(@src()); defer tracy.end(); @@ -1648,6 +1653,7 @@ fn zirInt(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*In } fn zirIntBig(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { + _ = block; const tracy = trace(@src()); defer tracy.end(); @@ -1665,6 +1671,7 @@ fn zirIntBig(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError! } fn zirFloat(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { + _ = block; const arena = sema.arena; const inst_data = sema.code.instructions.items(.data)[inst].float; const src = inst_data.src(); @@ -1677,6 +1684,7 @@ fn zirFloat(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!* } fn zirFloat128(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { + _ = block; const arena = sema.arena; const inst_data = sema.code.instructions.items(.data)[inst].pl_node; const extra = sema.code.extraData(Zir.Inst.Float128, inst_data.payload_index).data; @@ -2358,6 +2366,7 @@ fn analyzeCall( } fn zirIntType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { + _ = block; const tracy = trace(@src()); defer tracy.end(); @@ -2466,6 +2475,7 @@ fn zirErrorUnionType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Inn } fn zirErrorValue(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { + _ = block; const tracy = trace(@src()); defer tracy.end(); @@ -2626,6 +2636,7 @@ fn zirMergeErrorSets(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Inn } fn zirEnumLiteral(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { + _ = block; const tracy = trace(@src()); defer tracy.end(); @@ -3056,6 +3067,7 @@ fn funcCommon( src_locs: Zir.Inst.Func.SrcLocs, opt_lib_name: ?[]const u8, ) InnerError!*Inst { + _ = inferred_error_set; const src: LazySrcLoc = .{ .node_offset = src_node_offset }; const ret_ty_src: LazySrcLoc = .{ .node_offset_fn_type_ret_ty = src_node_offset }; const return_type = try sema.resolveType(block, ret_ty_src, zir_return_type); @@ -3492,6 +3504,8 @@ fn zirSwitchCapture( is_multi: bool, is_ref: bool, ) InnerError!*Inst { + _ = is_ref; + _ = is_multi; const tracy = trace(@src()); defer tracy.end(); @@ -3509,6 +3523,7 @@ fn zirSwitchCaptureElse( inst: Zir.Inst.Index, is_ref: bool, ) InnerError!*Inst { + _ = is_ref; const tracy = trace(@src()); defer tracy.end(); @@ -4511,12 +4526,15 @@ fn zirImport(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError! } fn zirShl(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { + _ = block; + _ = inst; const tracy = trace(@src()); defer tracy.end(); return sema.mod.fail(&block.base, sema.src, "TODO implement zirShl", .{}); } fn zirShr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { + _ = inst; const tracy = trace(@src()); defer tracy.end(); return sema.mod.fail(&block.base, sema.src, "TODO implement zirShr", .{}); @@ -4586,18 +4604,21 @@ fn zirBitwise( } fn zirBitNot(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { + _ = inst; const tracy = trace(@src()); defer tracy.end(); return sema.mod.fail(&block.base, sema.src, "TODO implement zirBitNot", .{}); } fn zirArrayCat(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { + _ = inst; const tracy = trace(@src()); defer tracy.end(); return sema.mod.fail(&block.base, sema.src, "TODO implement zirArrayCat", .{}); } fn zirArrayMul(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { + _ = inst; const tracy = trace(@src()); defer tracy.end(); return sema.mod.fail(&block.base, sema.src, "TODO implement zirArrayMul", .{}); @@ -5059,6 +5080,7 @@ fn zirTypeInfo(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerErro } fn zirTypeof(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { + _ = block; const zir_datas = sema.code.instructions.items(.data); const inst_data = zir_datas[inst].un_node; const src = inst_data.src(); @@ -5067,6 +5089,7 @@ fn zirTypeof(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError! } fn zirTypeofElem(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { + _ = block; const inst_data = sema.code.instructions.items(.data)[inst].un_node; const src = inst_data.src(); const operand_ptr = try sema.resolveInst(inst_data.operand); @@ -5504,6 +5527,7 @@ fn zirUnionInitPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Inner } fn zirStructInit(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index, is_ref: bool) InnerError!*Inst { + _ = is_ref; const mod = sema.mod; const gpa = sema.gpa; const zir_datas = sema.code.instructions.items(.data); @@ -5613,18 +5637,21 @@ fn zirStructInit(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index, is_ref: } fn zirStructInitAnon(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index, is_ref: bool) InnerError!*Inst { + _ = is_ref; const inst_data = sema.code.instructions.items(.data)[inst].pl_node; const src = inst_data.src(); return sema.mod.fail(&block.base, src, "TODO: Sema.zirStructInitAnon", .{}); } fn zirArrayInit(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index, is_ref: bool) InnerError!*Inst { + _ = is_ref; const inst_data = sema.code.instructions.items(.data)[inst].pl_node; const src = inst_data.src(); return sema.mod.fail(&block.base, src, "TODO: Sema.zirArrayInit", .{}); } fn zirArrayInitAnon(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index, is_ref: bool) InnerError!*Inst { + _ = is_ref; const inst_data = sema.code.instructions.items(.data)[inst].pl_node; const src = inst_data.src(); return sema.mod.fail(&block.base, src, "TODO: Sema.zirArrayInitAnon", .{}); @@ -6021,6 +6048,7 @@ fn zirAwait( inst: Zir.Inst.Index, is_nosuspend: bool, ) InnerError!*Inst { + _ = is_nosuspend; const inst_data = sema.code.instructions.items(.data)[inst].un_node; const src = inst_data.src(); return sema.mod.fail(&block.base, src, "TODO: Sema.zirAwait", .{}); @@ -6302,6 +6330,8 @@ fn addSafetyCheck(sema: *Sema, parent_block: *Scope.Block, ok: *Inst, panic_id: } fn safetyPanic(sema: *Sema, block: *Scope.Block, src: LazySrcLoc, panic_id: PanicId) !Zir.Inst.Index { + _ = sema; + _ = panic_id; // TODO Once we have a panic function to call, call it here instead of breakpoint. _ = try block.addNoOp(src, Type.initTag(.void), .breakpoint); _ = try block.addNoOp(src, Type.initTag(.noreturn), .unreach); @@ -6600,6 +6630,8 @@ fn elemPtrArray( elem_index: *Inst, elem_index_src: LazySrcLoc, ) InnerError!*Inst { + _ = elem_index; + _ = elem_index_src; if (array_ptr.value()) |array_ptr_val| { if (elem_index.value()) |index_val| { // Both array pointer and index are compile-time known. @@ -7510,6 +7542,8 @@ fn resolveBuiltinTypeFields( ty: Type, name: []const u8, ) InnerError!Type { + _ = ty; + _ = name; const resolved_ty = try sema.getBuiltinType(block, src, name); return sema.resolveTypeFields(block, src, resolved_ty); } diff --git a/src/Zir.zig b/src/Zir.zig index e743adb3edaace6e3d6b0c333dc424f636e026fa..ad96ff14b74b620a7bb41159de378954c43be907 100644 --- a/src/Zir.zig +++ b/src/Zir.zig @@ -4433,6 +4433,7 @@ const Writer = struct { } fn writeInstIndex(self: *Writer, stream: anytype, inst: Inst.Index) !void { + _ = self; return stream.print("%{d}", .{inst}); } @@ -4453,6 +4454,7 @@ const Writer = struct { name: []const u8, flag: bool, ) !void { + _ = self; if (!flag) return; try stream.writeAll(name); } diff --git a/src/air.zig b/src/air.zig index 4731b847e6e94f00b8a26d4dae832997deb83e05..37126f8153cb5a4ee2269a54f871bc29ff06c9ab 100644 --- a/src/air.zig +++ b/src/air.zig @@ -304,9 +304,12 @@ pub const Inst = struct { base: Inst, pub fn operandCount(self: *const NoOp) usize { + _ = self; return 0; } pub fn getOperand(self: *const NoOp, index: usize) ?*Inst { + _ = self; + _ = index; return null; } }; @@ -316,6 +319,7 @@ pub const Inst = struct { operand: *Inst, pub fn operandCount(self: *const UnOp) usize { + _ = self; return 1; } pub fn getOperand(self: *const UnOp, index: usize) ?*Inst { @@ -331,6 +335,7 @@ pub const Inst = struct { rhs: *Inst, pub fn operandCount(self: *const BinOp) usize { + _ = self; return 2; } pub fn getOperand(self: *const BinOp, index: usize) ?*Inst { @@ -356,9 +361,12 @@ pub const Inst = struct { name: [*:0]const u8, pub fn operandCount(self: *const Arg) usize { + _ = self; return 0; } pub fn getOperand(self: *const Arg, index: usize) ?*Inst { + _ = self; + _ = index; return null; } }; @@ -391,9 +399,12 @@ pub const Inst = struct { body: Body, pub fn operandCount(self: *const Block) usize { + _ = self; return 0; } pub fn getOperand(self: *const Block, index: usize) ?*Inst { + _ = self; + _ = index; return null; } }; @@ -412,9 +423,12 @@ pub const Inst = struct { body: Body, pub fn operandCount(self: *const BrBlockFlat) usize { + _ = self; return 0; } pub fn getOperand(self: *const BrBlockFlat, index: usize) ?*Inst { + _ = self; + _ = index; return null; } }; @@ -427,9 +441,11 @@ pub const Inst = struct { operand: *Inst, pub fn operandCount(self: *const Br) usize { + _ = self; return 1; } pub fn getOperand(self: *const Br, index: usize) ?*Inst { + _ = self; if (index == 0) return self.operand; return null; @@ -443,9 +459,12 @@ pub const Inst = struct { block: *Block, pub fn operandCount(self: *const BrVoid) usize { + _ = self; return 0; } pub fn getOperand(self: *const BrVoid, index: usize) ?*Inst { + _ = self; + _ = index; return null; } }; @@ -490,6 +509,7 @@ pub const Inst = struct { else_death_count: u32 = 0, pub fn operandCount(self: *const CondBr) usize { + _ = self; return 1; } pub fn getOperand(self: *const CondBr, index: usize) ?*Inst { @@ -516,9 +536,12 @@ pub const Inst = struct { val: Value, pub fn operandCount(self: *const Constant) usize { + _ = self; return 0; } pub fn getOperand(self: *const Constant, index: usize) ?*Inst { + _ = self; + _ = index; return null; } }; @@ -530,9 +553,12 @@ pub const Inst = struct { body: Body, pub fn operandCount(self: *const Loop) usize { + _ = self; return 0; } pub fn getOperand(self: *const Loop, index: usize) ?*Inst { + _ = self; + _ = index; return null; } }; @@ -544,9 +570,12 @@ pub const Inst = struct { variable: *Module.Var, pub fn operandCount(self: *const VarPtr) usize { + _ = self; return 0; } pub fn getOperand(self: *const VarPtr, index: usize) ?*Inst { + _ = self; + _ = index; return null; } }; @@ -559,9 +588,12 @@ pub const Inst = struct { field_index: usize, pub fn operandCount(self: *const StructFieldPtr) usize { + _ = self; return 1; } pub fn getOperand(self: *const StructFieldPtr, index: usize) ?*Inst { + _ = self; + _ = index; var i = index; if (i < 1) @@ -593,6 +625,7 @@ pub const Inst = struct { }; pub fn operandCount(self: *const SwitchBr) usize { + _ = self; return 1; } pub fn getOperand(self: *const SwitchBr, index: usize) ?*Inst { @@ -621,9 +654,12 @@ pub const Inst = struct { column: u32, pub fn operandCount(self: *const DbgStmt) usize { + _ = self; return 0; } pub fn getOperand(self: *const DbgStmt, index: usize) ?*Inst { + _ = self; + _ = index; return null; } }; diff --git a/src/codegen.zig b/src/codegen.zig index f2eec8cd8b12c9127f9fa92aeab8a902795159fa..4b156c6289ba1b44c65f6ae290cd4cc41f6c6e62 100644 --- a/src/codegen.zig +++ b/src/codegen.zig @@ -564,7 +564,7 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type { .r11 = true, // fp .r14 = true, // lr }; - inline for (callee_preserved_regs) |reg, i| { + inline for (callee_preserved_regs) |reg| { if (self.register_manager.isRegAllocated(reg)) { @field(saved_regs, @tagName(reg)) = true; } @@ -602,7 +602,7 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type { } else { if (math.cast(i26, amt)) |offset| { writeInt(u32, self.code.items[jmp_reloc..][0..4], Instruction.b(.al, offset).toU32()); - } else |err| { + } else |_| { return self.failSymbol("exitlude jump is too large", .{}); } } @@ -675,7 +675,7 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type { } else { if (math.cast(i28, amt)) |offset| { writeInt(u32, self.code.items[jmp_reloc..][0..4], Instruction.b(offset).toU32()); - } else |err| { + } else |_| { return self.failSymbol("exitlude jump is too large", .{}); } } @@ -1497,6 +1497,7 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type { swap_lhs_and_rhs: bool, op: ir.Inst.Tag, ) !void { + _ = src; assert(lhs_mcv == .register or rhs_mcv == .register); const op1 = if (swap_lhs_and_rhs) rhs_mcv.register else lhs_mcv.register; @@ -1905,6 +1906,7 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type { try self.genX8664ModRMRegToStack(src, dst_ty, off, src_reg, mr + 0x1); }, .immediate => |imm| { + _ = imm; return self.fail(src, "TODO implement x86 ADD/SUB/CMP source immediate", .{}); }, .embedded_in_code, .memory, .stack_offset => { @@ -2054,6 +2056,7 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type { return self.genSetStack(src, dst_ty, off, MCValue{ .register = dst_reg }); }, .immediate => |imm| { + _ = imm; return self.fail(src, "TODO implement x86 multiply source immediate", .{}); }, .embedded_in_code, .memory, .stack_offset => { @@ -2982,14 +2985,14 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type { .arm, .armeb => { if (math.cast(i26, @intCast(i32, index) - @intCast(i32, self.code.items.len + 8))) |delta| { writeInt(u32, try self.code.addManyAsArray(4), Instruction.b(.al, delta).toU32()); - } else |err| { + } else |_| { return self.fail(src, "TODO: enable larger branch offset", .{}); } }, .aarch64, .aarch64_be, .aarch64_32 => { if (math.cast(i28, @intCast(i32, index) - @intCast(i32, self.code.items.len + 8))) |delta| { writeInt(u32, try self.code.addManyAsArray(4), Instruction.b(delta).toU32()); - } else |err| { + } else |_| { return self.fail(src, "TODO: enable larger branch offset", .{}); } }, @@ -3307,16 +3310,18 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type { } }, .compare_flags_unsigned => |op| { + _ = op; return self.fail(src, "TODO implement set stack variable with compare flags value (unsigned)", .{}); }, .compare_flags_signed => |op| { + _ = op; return self.fail(src, "TODO implement set stack variable with compare flags value (signed)", .{}); }, .immediate => { const reg = try self.copyToTmpRegister(src, ty, mcv); return self.genSetStack(src, ty, stack_offset, MCValue{ .register = reg }); }, - .embedded_in_code => |code_offset| { + .embedded_in_code => { return self.fail(src, "TODO implement set stack variable from embedded_in_code", .{}); }, .register => |reg| { @@ -3352,7 +3357,7 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type { else => return self.fail(src, "TODO implement storing other types abi_size={}", .{abi_size}), } }, - .memory => |vaddr| { + .memory => { return self.fail(src, "TODO implement set stack variable from memory vaddr", .{}); }, .stack_offset => |off| { @@ -3380,10 +3385,10 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type { else => return self.fail(src, "TODO implement memset", .{}), } }, - .compare_flags_unsigned => |op| { + .compare_flags_unsigned => { return self.fail(src, "TODO implement set stack variable with compare flags value (unsigned)", .{}); }, - .compare_flags_signed => |op| { + .compare_flags_signed => { return self.fail(src, "TODO implement set stack variable with compare flags value (signed)", .{}); }, .immediate => |x_big| { @@ -3435,13 +3440,13 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type { }, } }, - .embedded_in_code => |code_offset| { + .embedded_in_code => { return self.fail(src, "TODO implement set stack variable from embedded_in_code", .{}); }, .register => |reg| { try self.genX8664ModRMRegToStack(src, ty, stack_offset, reg, 0x89); }, - .memory => |vaddr| { + .memory => { return self.fail(src, "TODO implement set stack variable from memory vaddr", .{}); }, .stack_offset => |off| { @@ -3469,17 +3474,17 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type { else => return self.fail(src, "TODO implement memset", .{}), } }, - .compare_flags_unsigned => |op| { + .compare_flags_unsigned => { return self.fail(src, "TODO implement set stack variable with compare flags value (unsigned)", .{}); }, - .compare_flags_signed => |op| { + .compare_flags_signed => { return self.fail(src, "TODO implement set stack variable with compare flags value (signed)", .{}); }, .immediate => { const reg = try self.copyToTmpRegister(src, ty, mcv); return self.genSetStack(src, ty, stack_offset, MCValue{ .register = reg }); }, - .embedded_in_code => |code_offset| { + .embedded_in_code => { return self.fail(src, "TODO implement set stack variable from embedded_in_code", .{}); }, .register => |reg| { @@ -3511,7 +3516,7 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type { else => return self.fail(src, "TODO implement storing other types abi_size={}", .{abi_size}), } }, - .memory => |vaddr| { + .memory => { return self.fail(src, "TODO implement set stack variable from memory vaddr", .{}); }, .stack_offset => |off| { @@ -3842,6 +3847,7 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type { ); }, .compare_flags_signed => |op| { + _ = op; return self.fail(src, "TODO set register with compare flags value (signed)", .{}); }, .immediate => |x| { @@ -4460,6 +4466,7 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type { dummy, pub fn allocIndex(self: Register) ?u4 { + _ = self; return null; } }; diff --git a/src/codegen/arm.zig b/src/codegen/arm.zig index cc6abe2e52a0840c62eb27093de9e6a08022e157..891a9e100bb58a531711bf2b1cd3fbf75405fa31 100644 --- a/src/codegen/arm.zig +++ b/src/codegen/arm.zig @@ -674,7 +674,7 @@ pub const Instruction = union(enum) { }; const imm4h: u4 = switch (offset) { .immediate => |imm| @truncate(u4, imm >> 4), - .register => |reg| 0b0000, + .register => 0b0000, }; return Instruction{ diff --git a/src/codegen/c.zig b/src/codegen/c.zig index 11006265530102e3dc02d97dc77a06ba08170493..ae439693b88c8840d455a6f4c2091334068df379 100644 --- a/src/codegen/c.zig +++ b/src/codegen/c.zig @@ -47,6 +47,8 @@ fn formatTypeAsCIdentifier( options: std.fmt.FormatOptions, writer: anytype, ) !void { + _ = fmt; + _ = options; var buffer = [1]u8{0} ** 128; // We don't care if it gets cut off, it's still more unique than a number var buf = std.fmt.bufPrint(&buffer, "{}", .{data}) catch &buffer; @@ -63,6 +65,8 @@ fn formatIdent( options: std.fmt.FormatOptions, writer: anytype, ) !void { + _ = fmt; + _ = options; for (ident) |c, i| { switch (c) { 'a'...'z', 'A'...'Z', '_' => try writer.writeByte(c), @@ -747,6 +751,7 @@ pub fn genBody(o: *Object, body: ir.Body) error{ AnalysisFail, OutOfMemory }!voi } fn genVarPtr(o: *Object, inst: *Inst.VarPtr) !CValue { + _ = o; return CValue{ .decl_ref = inst.variable.owner_decl }; } @@ -937,6 +942,8 @@ fn genCall(o: *Object, inst: *Inst.Call) !CValue { } fn genDbgStmt(o: *Object, inst: *Inst.DbgStmt) !CValue { + _ = o; + _ = inst; // TODO emit #line directive here with line number and filename return CValue.none; } @@ -1016,11 +1023,13 @@ fn genBitcast(o: *Object, inst: *Inst.UnOp) !CValue { } fn genBreakpoint(o: *Object, inst: *Inst.NoOp) !CValue { + _ = inst; try o.writer().writeAll("zig_breakpoint();\n"); return CValue.none; } fn genUnreach(o: *Object, inst: *Inst.NoOp) !CValue { + _ = inst; try o.writer().writeAll("zig_unreachable();\n"); return CValue.none; } diff --git a/src/codegen/llvm.zig b/src/codegen/llvm.zig index 4e4621ca293e790d614a67512b40636887dccf7d..2baedf8c9d425e38dd1996a1c60cd5a67e0c50e3 100644 --- a/src/codegen/llvm.zig +++ b/src/codegen/llvm.zig @@ -154,6 +154,7 @@ pub const Object = struct { object_pathZ: [:0]const u8, pub fn create(allocator: *Allocator, sub_path: []const u8, options: link.Options) !*Object { + _ = sub_path; const self = try allocator.create(Object); errdefer allocator.destroy(self); @@ -742,6 +743,7 @@ pub const FuncGen = struct { } fn genRetVoid(self: *FuncGen, inst: *Inst.NoOp) ?*const llvm.Value { + _ = inst; _ = self.builder.buildRetVoid(); return null; } @@ -873,6 +875,7 @@ pub const FuncGen = struct { } fn genUnreach(self: *FuncGen, inst: *Inst.NoOp) ?*const llvm.Value { + _ = inst; _ = self.builder.buildUnreachable(); return null; } @@ -1013,6 +1016,7 @@ pub const FuncGen = struct { } fn genBreakpoint(self: *FuncGen, inst: *Inst.NoOp) !?*const llvm.Value { + _ = inst; const llvn_fn = self.getIntrinsic("llvm.debugtrap"); _ = self.builder.buildCall(llvn_fn, null, 0, ""); return null; diff --git a/src/codegen/wasm.zig b/src/codegen/wasm.zig index a830ca36e0d2f3d97f2bebe5d22b6513d43418b3..39930e22b4ae56e14738b98ad10091071ef34588 100644 --- a/src/codegen/wasm.zig +++ b/src/codegen/wasm.zig @@ -702,7 +702,7 @@ pub const Context = struct { try writer.writeByte(wasm.valtype(.i32)); // error code is always an i32 integer. try writer.writeByte(val_type); }, - else => |ret_type| { + else => { try leb.writeULEB128(writer, @as(u32, 1)); // Can we maybe get the source index of the return type? const val_type = try self.genValtype(.{ .node_offset = 0 }, return_type); @@ -721,7 +721,7 @@ pub const Context = struct { // TODO: check for and handle death of instructions const mod_fn = blk: { if (typed_value.val.castTag(.function)) |func| break :blk func.data; - if (typed_value.val.castTag(.extern_fn)) |ext_fn| return Result.appended; // don't need code body for extern functions + if (typed_value.val.castTag(.extern_fn)) |_| return Result.appended; // don't need code body for extern functions unreachable; }; @@ -910,7 +910,7 @@ pub const Context = struct { }, else => unreachable, }, - .local => |local| { + .local => { try self.emitWValue(rhs); try writer.writeByte(wasm.opcode(.local_set)); try leb.writeULEB128(writer, lhs.local); @@ -925,6 +925,7 @@ pub const Context = struct { } fn genArg(self: *Context, inst: *Inst.Arg) InnerError!WValue { + _ = inst; // arguments share the index with locals defer self.local_index += 1; return WValue{ .local = self.local_index }; @@ -1213,12 +1214,15 @@ pub const Context = struct { } fn genBreakpoint(self: *Context, breakpoint: *Inst.NoOp) InnerError!WValue { + _ = self; + _ = breakpoint; // unsupported by wasm itself. Can be implemented once we support DWARF // for wasm return .none; } fn genUnreachable(self: *Context, unreach: *Inst.NoOp) InnerError!WValue { + _ = unreach; try self.code.append(wasm.opcode(.@"unreachable")); return .none; } diff --git a/src/link.zig b/src/link.zig index d1508c29cdef0de9b8a90b71a8d139400c721ba3..bae468d0750db71e13835c76e73e7248a48891b2 100644 --- a/src/link.zig +++ b/src/link.zig @@ -517,7 +517,7 @@ pub const File = struct { .target = base.options.target, .output_mode = .Obj, }); - const o_directory = base.options.module.?.zig_cache_artifact_directory; + const o_directory = module.zig_cache_artifact_directory; const full_obj_path = try o_directory.join(arena, &[_][]const u8{obj_basename}); break :blk full_obj_path; } diff --git a/src/link/C.zig b/src/link/C.zig index 6cb219db41167b4c8c6842e688d0d43f8c1fe686..bf18710cf5ff060c526b38b814f3c6cb5030e0bf 100644 --- a/src/link/C.zig +++ b/src/link/C.zig @@ -76,7 +76,12 @@ pub fn deinit(self: *C) void { self.decl_table.deinit(self.base.allocator); } -pub fn allocateDeclIndexes(self: *C, decl: *Module.Decl) !void {} +pub fn allocateDeclIndexes(self: *C, decl: *Module.Decl) !void { + if (false) { + self; + decl; + } +} pub fn freeDecl(self: *C, decl: *Module.Decl) void { _ = self.decl_table.swapRemove(decl); @@ -307,4 +312,11 @@ pub fn updateDeclExports( module: *Module, decl: *Module.Decl, exports: []const *Module.Export, -) !void {} +) !void { + if (false) { + exports; + decl; + module; + self; + } +} diff --git a/src/link/Coff.zig b/src/link/Coff.zig index 9ab1c6d78a2df2a0d6163490c266f661c6d53885..b466cf91369816da3237a64cbe42cd7c55f1ff9b 100644 --- a/src/link/Coff.zig +++ b/src/link/Coff.zig @@ -831,7 +831,7 @@ fn linkWithLLD(self: *Coff, comp: *Compilation) !void { .target = self.base.options.target, .output_mode = .Obj, }); - const o_directory = self.base.options.module.?.zig_cache_artifact_directory; + const o_directory = module.zig_cache_artifact_directory; const full_obj_path = try o_directory.join(arena, &[_][]const u8{obj_basename}); break :blk full_obj_path; } @@ -1340,6 +1340,9 @@ pub fn getDeclVAddr(self: *Coff, decl: *const Module.Decl) u64 { } pub fn updateDeclLineNumber(self: *Coff, module: *Module, decl: *Module.Decl) !void { + _ = self; + _ = module; + _ = decl; // TODO Implement this } diff --git a/src/link/Elf.zig b/src/link/Elf.zig index 84068ffecad0884b183ddac16cafb3cbf6410fbd..f046e8104ffbd61d0342c7c03d0bb2de99033c86 100644 --- a/src/link/Elf.zig +++ b/src/link/Elf.zig @@ -1262,7 +1262,7 @@ fn linkWithLLD(self: *Elf, comp: *Compilation) !void { .target = self.base.options.target, .output_mode = .Obj, }); - const o_directory = self.base.options.module.?.zig_cache_artifact_directory; + const o_directory = module.zig_cache_artifact_directory; const full_obj_path = try o_directory.join(arena, &[_][]const u8{obj_basename}); break :blk full_obj_path; } @@ -1938,6 +1938,11 @@ fn freeTextBlock(self: *Elf, text_block: *TextBlock) void { } fn shrinkTextBlock(self: *Elf, text_block: *TextBlock, new_block_size: u64) void { + if (false) { + self; + text_block; + new_block_size; + } // TODO check the new capacity, and if it crosses the size threshold into a big enough // capacity, insert a free list node for it. } @@ -2706,6 +2711,7 @@ pub fn updateDeclExports( /// Must be called only after a successful call to `updateDecl`. pub fn updateDeclLineNumber(self: *Elf, module: *Module, decl: *const Module.Decl) !void { + _ = module; const tracy = trace(@src()); defer tracy.end(); @@ -2979,6 +2985,7 @@ fn dbgLineNeededHeaderBytes(self: Elf) u32 { } fn dbgInfoNeededHeaderBytes(self: Elf) u32 { + _ = self; return 120; } @@ -3372,7 +3379,7 @@ const CsuObjects = struct { if (result.crtend) |*obj| obj.* = try fs.path.join(arena, &[_][]const u8{ gcc_dir_path, obj.* }); }, else => { - inline for (std.meta.fields(@TypeOf(result))) |f, i| { + inline for (std.meta.fields(@TypeOf(result))) |f| { if (@field(result, f.name)) |*obj| { obj.* = try fs.path.join(arena, &[_][]const u8{ crt_dir_path, obj.* }); } @@ -3380,7 +3387,7 @@ const CsuObjects = struct { }, } } else { - inline for (std.meta.fields(@TypeOf(result))) |f, i| { + inline for (std.meta.fields(@TypeOf(result))) |f| { if (@field(result, f.name)) |*obj| { if (comp.crt_files.get(obj.*)) |crtf| { obj.* = crtf.full_object_path; diff --git a/src/link/MachO.zig b/src/link/MachO.zig index e82589f144975e5626047bb2116fc23b04339508..6e1996f9ff9f1b048125a3db4248acfba64dde66 100644 --- a/src/link/MachO.zig +++ b/src/link/MachO.zig @@ -441,6 +441,7 @@ pub fn flush(self: *MachO, comp: *Compilation) !void { } pub fn flushModule(self: *MachO, comp: *Compilation) !void { + _ = comp; const tracy = trace(@src()); defer tracy.end(); @@ -533,7 +534,7 @@ fn linkWithLLD(self: *MachO, comp: *Compilation) !void { .target = self.base.options.target, .output_mode = .Obj, }); - const o_directory = self.base.options.module.?.zig_cache_artifact_directory; + const o_directory = module.zig_cache_artifact_directory; const full_obj_path = try o_directory.join(arena, &[_][]const u8{obj_basename}); break :blk full_obj_path; } @@ -1254,6 +1255,9 @@ fn freeTextBlock(self: *MachO, text_block: *TextBlock) void { } fn shrinkTextBlock(self: *MachO, text_block: *TextBlock, new_block_size: u64) void { + _ = self; + _ = text_block; + _ = new_block_size; // TODO check the new capacity, and if it crosses the size threshold into a big enough // capacity, insert a free list node for it. } diff --git a/src/link/MachO/DebugSymbols.zig b/src/link/MachO/DebugSymbols.zig index 218911f7ab4c629a33688780e96d4258b1b4fe05..2b10f3307ba5bb87492efebfb6eb0d2e8b37b47d 100644 --- a/src/link/MachO/DebugSymbols.zig +++ b/src/link/MachO/DebugSymbols.zig @@ -899,6 +899,7 @@ fn writeStringTable(self: *DebugSymbols) !void { } pub fn updateDeclLineNumber(self: *DebugSymbols, module: *Module, decl: *const Module.Decl) !void { + _ = module; const tracy = trace(@src()); defer tracy.end(); @@ -926,6 +927,8 @@ pub fn initDeclDebugBuffers( module: *Module, decl: *Module.Decl, ) !DeclDebugBuffers { + _ = self; + _ = module; const tracy = trace(@src()); defer tracy.end(); @@ -1188,6 +1191,7 @@ fn addDbgInfoType( dbg_info_buffer: *std.ArrayList(u8), target: std.Target, ) !void { + _ = self; switch (ty.zigTypeTag()) { .Void => unreachable, .NoReturn => unreachable, @@ -1364,6 +1368,7 @@ fn getRelocDbgInfoSubprogramHighPC() u32 { } fn dbgLineNeededHeaderBytes(self: DebugSymbols, module: *Module) u32 { + _ = self; const directory_entry_format_count = 1; const file_name_entry_format_count = 1; const directory_count = 1; @@ -1378,6 +1383,7 @@ fn dbgLineNeededHeaderBytes(self: DebugSymbols, module: *Module) u32 { } fn dbgInfoNeededHeaderBytes(self: DebugSymbols) u32 { + _ = self; return 120; } diff --git a/src/link/MachO/Zld.zig b/src/link/MachO/Zld.zig index 4b19891c770b54a4db9088858ee1fcfdf041e500..9d9a1315bba60c1bff713009ce41c4935a00e800 100644 --- a/src/link/MachO/Zld.zig +++ b/src/link/MachO/Zld.zig @@ -108,6 +108,7 @@ const TlvOffset = struct { offset: u64, fn cmp(context: void, a: TlvOffset, b: TlvOffset) bool { + _ = context; return a.source_addr < b.source_addr; } }; @@ -437,7 +438,7 @@ fn updateMetadata(self: *Zld) !void { const data_seg = &self.load_commands.items[self.data_segment_cmd_index.?].Segment; // Create missing metadata - for (object.sections.items) |sect, sect_id| { + for (object.sections.items) |sect| { const segname = sect.segname(); const sectname = sect.sectname(); @@ -1373,7 +1374,7 @@ fn allocateTentativeSymbols(self: *Zld) !void { } // Convert tentative definitions into regular symbols. - for (self.tentatives.values()) |sym, i| { + for (self.tentatives.values()) |sym| { const tent = sym.cast(Symbol.Tentative) orelse unreachable; const reg = try self.allocator.create(Symbol.Regular); errdefer self.allocator.destroy(reg); @@ -1758,7 +1759,7 @@ fn resolveSymbolsInObject(self: *Zld, object: *Object) !void { t_sym.alias = sym; sym_ptr.* = sym; - } else if (sym.cast(Symbol.Unresolved)) |und| { + } else if (sym.cast(Symbol.Unresolved)) |_| { if (self.globals.get(sym.name)) |g_sym| { sym.alias = g_sym; continue; diff --git a/src/link/MachO/bind.zig b/src/link/MachO/bind.zig index d234fa8242a70556219bad36a6c53ca2ecafd956..402e74d776e77f821c5f9340d11fe8315620b6b6 100644 --- a/src/link/MachO/bind.zig +++ b/src/link/MachO/bind.zig @@ -10,6 +10,7 @@ pub const Pointer = struct { }; pub fn pointerCmp(context: void, a: Pointer, b: Pointer) bool { + _ = context; if (a.segment_id < b.segment_id) return true; if (a.segment_id == b.segment_id) { return a.offset < b.offset; diff --git a/src/link/SpirV.zig b/src/link/SpirV.zig index 9d64245bbb5762f0b32407850ca7e3d51635d4bb..c0b4e5ebcbf8e87109e32b7878ca80335f77179c 100644 --- a/src/link/SpirV.zig +++ b/src/link/SpirV.zig @@ -102,6 +102,7 @@ pub fn deinit(self: *SpirV) void { } pub fn updateDecl(self: *SpirV, module: *Module, decl: *Module.Decl) !void { + _ = module; // Keep track of all decls so we can iterate over them on flush(). _ = try self.decl_table.getOrPut(self.base.allocator, decl); } @@ -111,7 +112,14 @@ pub fn updateDeclExports( module: *Module, decl: *const Module.Decl, exports: []const *Module.Export, -) !void {} +) !void { + if (false) { + self; + module; + decl; + exports; + } +} pub fn freeDecl(self: *SpirV, decl: *Module.Decl) void { assert(self.decl_table.swapRemove(decl)); diff --git a/src/link/Wasm.zig b/src/link/Wasm.zig index 35da20291d1de91a131a174e02afb02949e95141..50b320d7f6b0fc575e8b17d6cc7333d83c60710a 100644 --- a/src/link/Wasm.zig +++ b/src/link/Wasm.zig @@ -216,7 +216,7 @@ pub fn updateDecl(self: *Wasm, module: *Module, decl: *Module.Decl) !void { try module.failed_decls.put(module.gpa, decl, context.err_msg); return; }, - else => |e| return err, + else => |e| return e, }; const code: []const u8 = switch (result) { @@ -258,7 +258,14 @@ pub fn updateDeclExports( module: *Module, decl: *const Module.Decl, exports: []const *Module.Export, -) !void {} +) !void { + if (false) { + self; + module; + decl; + exports; + } +} pub fn freeDecl(self: *Wasm, decl: *Module.Decl) void { if (self.getFuncidx(decl)) |func_idx| { @@ -300,6 +307,7 @@ pub fn flush(self: *Wasm, comp: *Compilation) !void { } pub fn flushModule(self: *Wasm, comp: *Compilation) !void { + _ = comp; const tracy = trace(@src()); defer tracy.end(); @@ -557,7 +565,7 @@ fn linkWithLLD(self: *Wasm, comp: *Compilation) !void { .target = self.base.options.target, .output_mode = .Obj, }); - const o_directory = self.base.options.module.?.zig_cache_artifact_directory; + const o_directory = module.zig_cache_artifact_directory; const full_obj_path = try o_directory.join(arena, &[_][]const u8{obj_basename}); break :blk full_obj_path; } diff --git a/src/main.zig b/src/main.zig index 4540eaa397d5594059b6f2fbe183dd11cf637338..4b7bff955573fb2212c49bd3e69a4ffebe797309 100644 --- a/src/main.zig +++ b/src/main.zig @@ -500,7 +500,7 @@ const Emit = union(enum) { }; fn optionalBoolEnvVar(arena: *Allocator, name: []const u8) !bool { - if (std.process.getEnvVarOwned(arena, name)) |value| { + if (std.process.getEnvVarOwned(arena, name)) |_| { return true; } else |err| switch (err) { error.EnvironmentVariableNotFound => return false, @@ -2560,7 +2560,7 @@ pub const usage_init = ; pub fn cmdInit( - gpa: *Allocator, + _: *Allocator, arena: *Allocator, args: []const []const u8, output_mode: std.builtin.OutputMode, diff --git a/src/print_env.zig b/src/print_env.zig index d62e1f62fdbf3fe51e692afe52eaa3b3d884976a..8c44e85e65994fa69410adea7643740aa06a99a5 100644 --- a/src/print_env.zig +++ b/src/print_env.zig @@ -5,6 +5,7 @@ const Allocator = std.mem.Allocator; const fatal = @import("main.zig").fatal; pub fn cmdEnv(gpa: *Allocator, args: []const []const u8, stdout: std.fs.File.Writer) !void { + _ = args; const self_exe_path = try std.fs.selfExePathAlloc(gpa); defer gpa.free(self_exe_path); diff --git a/src/print_targets.zig b/src/print_targets.zig index e24a2294a179a3ae13431c6a00da8857f80ba18c..d0a1d5167a86e01696121913902ced5c2bede0b4 100644 --- a/src/print_targets.zig +++ b/src/print_targets.zig @@ -17,6 +17,7 @@ pub fn cmdTargets( stdout: anytype, native_target: Target, ) !void { + _ = args; var zig_lib_directory = introspect.findZigLibDir(allocator) catch |err| { fatal("unable to find zig installation directory: {s}\n", .{@errorName(err)}); }; diff --git a/src/register_manager.zig b/src/register_manager.zig index 6f42fd1ab1b21f59d6ea973c22f159987ba6d366..96cf4f17b7f38e8f3d5bc66d6181cfa12287899e 100644 --- a/src/register_manager.zig +++ b/src/register_manager.zig @@ -265,6 +265,8 @@ fn MockFunction(comptime Register: type) type { } pub fn spillInstruction(self: *Self, src: LazySrcLoc, reg: Register, inst: *ir.Inst) !void { + _ = src; + _ = inst; try self.spilled.append(self.allocator, reg); } }; diff --git a/src/stage1.zig b/src/stage1.zig index 91e7cd8bed124c4be2192f666aed24ce731bb83b..46d70ea335c8aaddcad649858223c4b933e08e0c 100644 --- a/src/stage1.zig +++ b/src/stage1.zig @@ -407,6 +407,8 @@ export fn stage2_add_link_lib( symbol_name_ptr: [*c]const u8, symbol_name_len: usize, ) ?[*:0]const u8 { + _ = symbol_name_len; + _ = symbol_name_ptr; const comp = @intToPtr(*Compilation, stage1.userdata); const lib_name = std.ascii.allocLowerString(comp.gpa, lib_name_ptr[0..lib_name_len]) catch return "out of memory"; const target = comp.getTarget(); diff --git a/src/test.zig b/src/test.zig index a7f11d93dfecc399ba0070f898a6e0e3c73cc936..1d2a552662a9a821e92b15e80ad34df1e1e1e414 100644 --- a/src/test.zig +++ b/src/test.zig @@ -70,6 +70,8 @@ const ErrorMsg = union(enum) { options: std.fmt.FormatOptions, writer: anytype, ) !void { + _ = fmt; + _ = options; switch (self) { .src => |src| { return writer.print("{s}:{d}:{d}: {s}: {s}", .{ @@ -592,6 +594,7 @@ pub const TestContext = struct { thread_pool: *ThreadPool, global_cache_directory: Compilation.Directory, ) !void { + _ = self; const target_info = try std.zig.system.NativeTargetInfo.detect(allocator, case.target); const target = target_info.target; diff --git a/src/tracy.zig b/src/tracy.zig index 6f56a87ce6fad8484cfc8f37ff5e4e97ca0570f1..9ea15d721b9e31605446abc790e998d1d6906da4 100644 --- a/src/tracy.zig +++ b/src/tracy.zig @@ -28,7 +28,9 @@ pub const ___tracy_c_zone_context = extern struct { }; pub const Ctx = if (enable) ___tracy_c_zone_context else struct { - pub fn end(self: Ctx) void {} + pub fn end(self: Ctx) void { + _ = self; + } }; pub inline fn trace(comptime src: std.builtin.SourceLocation) Ctx { diff --git a/src/translate_c.zig b/src/translate_c.zig index 5f1db7fb207755b342f916f265eac779af9ad630..a575c0d13f739e38ea94ca69e6a07b1001bb50de 100644 --- a/src/translate_c.zig +++ b/src/translate_c.zig @@ -206,6 +206,7 @@ const Scope = struct { } fn findBlockReturnType(inner: *Scope, c: *Context) clang.QualType { + _ = c; var scope = inner; while (true) { switch (scope.id) { @@ -601,7 +602,7 @@ fn visitFnDecl(c: *Context, fn_decl: *const clang.FunctionDecl) Error!void { var scope = &block_scope.base; var param_id: c_uint = 0; - for (proto_node.data.params) |*param, i| { + for (proto_node.data.params) |*param| { const param_name = param.name orelse { proto_node.data.is_extern = true; proto_node.data.is_export = false; @@ -785,7 +786,7 @@ const builtin_typedef_map = std.ComptimeStringMap([]const u8, .{ }); fn transTypeDef(c: *Context, scope: *Scope, typedef_decl: *const clang.TypedefNameDecl) Error!void { - if (c.decl_table.get(@ptrToInt(typedef_decl.getCanonicalDecl()))) |name| + if (c.decl_table.get(@ptrToInt(typedef_decl.getCanonicalDecl()))) |_| return; // Avoid processing this decl twice const toplevel = scope.id == .root; const bs: *Scope.Block = if (!toplevel) try scope.findBlockScope(c) else undefined; @@ -935,7 +936,7 @@ fn hasFlexibleArrayField(c: *Context, record_def: *const clang.RecordDecl) bool } fn transRecordDecl(c: *Context, scope: *Scope, record_decl: *const clang.RecordDecl) Error!void { - if (c.decl_table.get(@ptrToInt(record_decl.getCanonicalDecl()))) |name| + if (c.decl_table.get(@ptrToInt(record_decl.getCanonicalDecl()))) |_| return; // Avoid processing this decl twice const record_loc = record_decl.getLocation(); const toplevel = scope.id == .root; @@ -1080,7 +1081,7 @@ fn transRecordDecl(c: *Context, scope: *Scope, record_decl: *const clang.RecordD } fn transEnumDecl(c: *Context, scope: *Scope, enum_decl: *const clang.EnumDecl) Error!void { - if (c.decl_table.get(@ptrToInt(enum_decl.getCanonicalDecl()))) |name| + if (c.decl_table.get(@ptrToInt(enum_decl.getCanonicalDecl()))) |_| return; // Avoid processing this decl twice const enum_loc = enum_decl.getLocation(); const toplevel = scope.id == .root; @@ -1312,6 +1313,7 @@ fn transConvertVectorExpr( source_loc: clang.SourceLocation, expr: *const clang.ConvertVectorExpr, ) TransError!Node { + _ = source_loc; const base_stmt = @ptrCast(*const clang.Stmt, expr); var block_scope = try Scope.Block.init(c, scope, true); @@ -1433,6 +1435,7 @@ fn transSimpleOffsetOfExpr( scope: *Scope, expr: *const clang.OffsetOfExpr, ) TransError!Node { + _ = scope; assert(expr.getNumComponents() == 1); const component = expr.getComponent(0); if (component.getKind() == .Field) { @@ -2269,6 +2272,7 @@ fn transStringLiteralInitializer( /// both operands resolve to addresses. The C standard requires that both operands /// point to elements of the same array object, but we do not verify that here. fn cIsPointerDiffExpr(c: *Context, stmt: *const clang.BinaryOperator) bool { + _ = c; const lhs = @ptrCast(*const clang.Stmt, stmt.getLHS()); const rhs = @ptrCast(*const clang.Stmt, stmt.getRHS()); return stmt.getOpcode() == .Sub and @@ -2572,6 +2576,7 @@ fn transInitListExprVector( expr: *const clang.InitListExpr, ty: *const clang.Type, ) TransError!Node { + _ = ty; const qt = getExprQualType(c, @ptrCast(*const clang.Expr, expr)); const vector_type = try transQualType(c, scope, qt, loc); const init_count = expr.getNumInits(); @@ -2721,6 +2726,7 @@ fn transImplicitValueInitExpr( expr: *const clang.Expr, used: ResultUsed, ) TransError!Node { + _ = used; const source_loc = expr.getBeginLoc(); const qt = getExprQualType(c, expr); const ty = qt.getTypePtr(); @@ -3407,6 +3413,7 @@ fn transUnaryExprOrTypeTraitExpr( stmt: *const clang.UnaryExprOrTypeTraitExpr, result_used: ResultUsed, ) TransError!Node { + _ = result_used; const loc = stmt.getBeginLoc(); const type_node = try transQualType(c, scope, stmt.getTypeOfArgument(), loc); @@ -3893,6 +3900,7 @@ fn maybeSuppressResult( used: ResultUsed, result: Node, ) TransError!Node { + _ = scope; if (used == .used) return result; return Tag.discard.create(c.arena, result); } @@ -4337,7 +4345,7 @@ fn transCreateNodeMacroFn(c: *Context, name: []const u8, ref: Node, proto_alias: var fn_params = std.ArrayList(ast.Payload.Param).init(c.gpa); defer fn_params.deinit(); - for (proto_alias.data.params) |param, i| { + for (proto_alias.data.params) |param| { const param_name = param.name orelse try std.fmt.allocPrint(c.arena, "arg_{d}", .{c.getMangle()}); @@ -5653,6 +5661,7 @@ fn parseCSpecifierQualifierList(c: *Context, m: *MacroCtx, scope: *Scope, allow_ } fn parseCNumericType(c: *Context, m: *MacroCtx, scope: *Scope) ParseError!Node { + _ = scope; const KwCounter = struct { double: u8 = 0, long: u8 = 0, @@ -5754,6 +5763,7 @@ fn parseCNumericType(c: *Context, m: *MacroCtx, scope: *Scope) ParseError!Node { } fn parseCAbstractDeclarator(c: *Context, m: *MacroCtx, scope: *Scope, node: Node) ParseError!Node { + _ = scope; switch (m.next().?) { .Asterisk => { // last token of `node` diff --git a/src/type.zig b/src/type.zig index 0b30a3de02bd105a8a6826c2ce547e62f6b099ad..853a4b79142b6136e76cbdd9cd2cce39adabc47a 100644 --- a/src/type.zig +++ b/src/type.zig @@ -600,9 +600,11 @@ pub const Type = extern union { pub const HashContext = struct { pub fn hash(self: @This(), t: Type) u64 { + _ = self; return t.hash(); } pub fn eql(self: @This(), a: Type, b: Type) bool { + _ = self; return a.eql(b); } }; @@ -777,6 +779,7 @@ pub const Type = extern union { options: std.fmt.FormatOptions, writer: anytype, ) @TypeOf(writer).Error!void { + _ = options; comptime assert(fmt.len == 0); var ty = start_type; while (true) { diff --git a/src/value.zig b/src/value.zig index 696f3d3d88aba77cfc5a275ce2b837b9a57aa532..008cc3c2fea3ee667284315e8ecc366c09873c6f 100644 --- a/src/value.zig +++ b/src/value.zig @@ -626,6 +626,7 @@ pub const Value = extern union { return std.mem.dupe(allocator, u8, payload.data); } if (self.castTag(.repeated)) |payload| { + _ = payload; @panic("TODO implement toAllocatedBytes for this Value tag"); } if (self.castTag(.decl_ref)) |payload| { @@ -747,6 +748,7 @@ pub const Value = extern union { /// Asserts the type is an enum type. pub fn toEnum(val: Value, enum_ty: Type, comptime E: type) E { + _ = enum_ty; // TODO this needs to resolve other kinds of Value tags rather than // assuming the tag will be .enum_field_index. const field_index = val.castTag(.enum_field_index).?.data; @@ -935,6 +937,7 @@ pub const Value = extern union { /// Converts an integer or a float to a float. /// Returns `error.Overflow` if the value does not fit in the new type. pub fn floatCast(self: Value, allocator: *Allocator, ty: Type, target: Target) !Value { + _ = target; switch (ty.tag()) { .f16 => { @panic("TODO add __trunctfhf2 to compiler-rt"); @@ -1292,17 +1295,21 @@ pub const Value = extern union { pub const ArrayHashContext = struct { pub fn hash(self: @This(), v: Value) u32 { + _ = self; return v.hash_u32(); } pub fn eql(self: @This(), a: Value, b: Value) bool { + _ = self; return a.eql(b); } }; pub const HashContext = struct { pub fn hash(self: @This(), v: Value) u64 { + _ = self; return v.hash(); } pub fn eql(self: @This(), a: Value, b: Value) bool { + _ = self; return a.eql(b); } }; @@ -1345,6 +1352,7 @@ pub const Value = extern union { } pub fn fieldValue(val: Value, allocator: *Allocator, index: usize) error{OutOfMemory}!Value { + _ = allocator; switch (val.tag()) { .@"struct" => { const field_values = val.castTag(.@"struct").?.data; diff --git a/test/behavior/align.zig b/test/behavior/align.zig index 06173ef40fc4924feeb6987c7424ee44fe4e333a..e99cf1e0e29bb8ead8c83dd5071106d9bc25d47e 100644 --- a/test/behavior/align.zig +++ b/test/behavior/align.zig @@ -167,6 +167,7 @@ test "generic function with align param" { } fn whyWouldYouEverDoThis(comptime align_bytes: u8) align(align_bytes) u8 { + _ = align_bytes; return 0x1; } diff --git a/test/behavior/async_fn.zig b/test/behavior/async_fn.zig index f0d47fbc7f982f7f8ee9905f8efc29d9228ea6d1..6d734669fc2b6095b02f79f522bc16f05d10f9b9 100644 --- a/test/behavior/async_fn.zig +++ b/test/behavior/async_fn.zig @@ -133,6 +133,7 @@ test "@frameSize" { other(1); } fn other(param: i32) void { + _ = param; var local: i32 = undefined; _ = local; suspend {} @@ -635,6 +636,8 @@ test "returning a const error from async function" { } fn fetchUrl(unused: i32, url: []const u8) ![]u8 { + _ = unused; + _ = url; frame = @frame(); suspend {} ok = true; @@ -711,6 +714,7 @@ fn testAsyncAwaitTypicalUsage( var global_download_frame: anyframe = undefined; fn fetchUrl(allocator: *std.mem.Allocator, url: []const u8) anyerror![]u8 { + _ = url; const result = try std.mem.dupe(allocator, u8, "expected download text"); errdefer allocator.free(result); if (suspend_download) { @@ -724,6 +728,7 @@ fn testAsyncAwaitTypicalUsage( var global_file_frame: anyframe = undefined; fn readFile(allocator: *std.mem.Allocator, filename: []const u8) anyerror![]u8 { + _ = filename; const result = try std.mem.dupe(allocator, u8, "expected file text"); errdefer allocator.free(result); if (suspend_file) { @@ -1226,6 +1231,7 @@ test "suspend in while loop" { suspend {} return val; } else |err| { + err catch {}; return 0; } } @@ -1355,6 +1361,7 @@ test "async function passed 0-bit arg after non-0-bit arg" { } fn bar(x: i32, args: anytype) anyerror!void { + _ = args; global_frame = @frame(); suspend {} global_int = x; @@ -1650,6 +1657,8 @@ test "@asyncCall with pass-by-value arguments" { pub const AT = [5]u8; pub fn f(_fill0: u64, s: ST, _fill1: u64, a: AT, _fill2: u64) callconv(.Async) void { + _ = s; + _ = a; // Check that the array and struct arguments passed by value don't // end up overflowing the adjacent fields in the frame structure. expectEqual(F0, _fill0) catch @panic("test failure"); @@ -1677,6 +1686,7 @@ test "@asyncCall with arguments having non-standard alignment" { const S = struct { pub fn f(_fill0: u32, s: struct { x: u64 align(16) }, _fill1: u64) callconv(.Async) void { + _ = s; // The compiler inserts extra alignment for s, check that the // generated code picks the right slot for fill1. expectEqual(F0, _fill0) catch @panic("test failure"); diff --git a/test/behavior/bugs/1310.zig b/test/behavior/bugs/1310.zig index a291b217ec01d80b4459541747482664b6abbf6c..31911d5014272ff15cfddc7fc4052e41f90112c1 100644 --- a/test/behavior/bugs/1310.zig +++ b/test/behavior/bugs/1310.zig @@ -16,6 +16,8 @@ pub const InvocationTable_ = struct_InvocationTable_; pub const VM_ = struct_VM_; fn agent_callback(_vm: [*]VM, options: [*]u8) callconv(.C) i32 { + _ = _vm; + _ = options; return 11; } diff --git a/test/behavior/bugs/2578.zig b/test/behavior/bugs/2578.zig index cf7d941562ae6901a7cf1a840de2f598014c4be6..547aee9b22ffe8778ff341d978f4284841b039eb 100644 --- a/test/behavior/bugs/2578.zig +++ b/test/behavior/bugs/2578.zig @@ -5,7 +5,9 @@ const Foo = struct { var foo: Foo = undefined; const t = &foo; -fn bar(pointer: ?*c_void) void {} +fn bar(pointer: ?*c_void) void { + _ = pointer; +} test "fixed" { bar(t); diff --git a/test/behavior/bugs/2692.zig b/test/behavior/bugs/2692.zig index 267c3a131ae0c8180007b11e400e4ada9da59178..1bc38a0274478ace20d40f28cfceb73698ea26c7 100644 --- a/test/behavior/bugs/2692.zig +++ b/test/behavior/bugs/2692.zig @@ -1,4 +1,6 @@ -fn foo(a: []u8) void {} +fn foo(a: []u8) void { + _ = a; +} test "address of 0 length array" { var pt: [0]u8 = undefined; diff --git a/test/behavior/bugs/3367.zig b/test/behavior/bugs/3367.zig index 3df3adbff765bfcc8f00710c2f0fae51318d310e..b77b979b8ac22d4825cc3550df4df692fe1a14e5 100644 --- a/test/behavior/bugs/3367.zig +++ b/test/behavior/bugs/3367.zig @@ -3,7 +3,9 @@ const Foo = struct { }; const Mixin = struct { - pub fn two(self: Foo) void {} + pub fn two(self: Foo) void { + _ = self; + } }; test "container member access usingnamespace decls" { diff --git a/test/behavior/bugs/4328.zig b/test/behavior/bugs/4328.zig index 76c3e788fd3f2552550968761a7b1eafe29524b0..26b96d8d6f677a703c5a37b196174f64d9edce60 100644 --- a/test/behavior/bugs/4328.zig +++ b/test/behavior/bugs/4328.zig @@ -53,10 +53,12 @@ test "Peer resolution of extern function calls in @TypeOf" { test "Extern function calls, dereferences and field access in @TypeOf" { const Test = struct { fn test_fn_1(a: c_long) @TypeOf(fopen("test", "r").*) { + _ = a; return .{ .dummy_field = 0 }; } fn test_fn_2(a: anytype) @TypeOf(fopen("test", "r").*.dummy_field) { + _ = a; return 255; } diff --git a/test/behavior/bugs/4560.zig b/test/behavior/bugs/4560.zig index 682d3f212561541a3b3dfe4bbce4bb1bc09762ab..3119bd99b9177ba1031a915a4bc80a52c726af6d 100644 --- a/test/behavior/bugs/4560.zig +++ b/test/behavior/bugs/4560.zig @@ -25,6 +25,10 @@ pub fn StringHashMap(comptime V: type) type { } pub fn HashMap(comptime K: type, comptime V: type) type { + if (false) { + K; + V; + } return struct { size: usize, max_distance_from_start_index: usize, diff --git a/test/behavior/bugs/529_other_file_2.zig b/test/behavior/bugs/529_other_file_2.zig index b493959e506b3b29d1715d35d3c4644a4e9150c4..9f4636dce8f714d34b55bac1e58d11e82d3cbfa4 100644 --- a/test/behavior/bugs/529_other_file_2.zig +++ b/test/behavior/bugs/529_other_file_2.zig @@ -1,4 +1,6 @@ pub const A = extern struct { field: c_int, }; -export fn issue529(a: ?*A) void {} +export fn issue529(a: ?*A) void { + _ = a; +} diff --git a/test/behavior/bugs/5487.zig b/test/behavior/bugs/5487.zig index bf530a8a027157f6b9eca0d69ce08af4ec4db5b8..4f67e6e846a949882fd3c522fc1e6c9922580553 100644 --- a/test/behavior/bugs/5487.zig +++ b/test/behavior/bugs/5487.zig @@ -1,6 +1,7 @@ const io = @import("std").io; pub fn write(_: void, bytes: []const u8) !usize { + _ = bytes; return 0; } pub fn writer() io.Writer(void, @typeInfo(@typeInfo(@TypeOf(write)).Fn.return_type.?).ErrorUnion.error_set, write) { diff --git a/test/behavior/bugs/624.zig b/test/behavior/bugs/624.zig index 4d52aad693521ff0cc50f0873fbf552bb3a7554e..b8bf09f22e349074d634d5bd88936c31d23214eb 100644 --- a/test/behavior/bugs/624.zig +++ b/test/behavior/bugs/624.zig @@ -12,6 +12,7 @@ const ListenerContext = struct { const ContextAllocator = MemoryPool(TestContext); fn MemoryPool(comptime T: type) type { + _ = T; return struct { n: usize, }; diff --git a/test/behavior/bugs/679.zig b/test/behavior/bugs/679.zig index 9b402defca3d4ae1b5b4136392777a9386c831e1..6420e7f99f056751c8a8910b06feffb510f7e701 100644 --- a/test/behavior/bugs/679.zig +++ b/test/behavior/bugs/679.zig @@ -2,6 +2,7 @@ const std = @import("std"); const expect = std.testing.expect; pub fn List(comptime T: type) type { + _ = T; return u32; } diff --git a/test/behavior/bugs/7027.zig b/test/behavior/bugs/7027.zig index 782eebbfc94eb316827be749d0f21ac4d95653a4..064c511ca87ac919703e18567ca9051650a5b49d 100644 --- a/test/behavior/bugs/7027.zig +++ b/test/behavior/bugs/7027.zig @@ -9,7 +9,9 @@ const Foobar = struct { } }; -fn foo(arg: anytype) void {} +fn foo(arg: anytype) void { + _ = arg; +} test "" { comptime var foobar = Foobar.foo(); diff --git a/test/behavior/bugs/704.zig b/test/behavior/bugs/704.zig index 765336c95f8dbe784e2355a72eef515757dab8cb..15fe9419a6ec9bee158e556955bb264c43109bd7 100644 --- a/test/behavior/bugs/704.zig +++ b/test/behavior/bugs/704.zig @@ -1,5 +1,7 @@ const xxx = struct { - pub fn bar(self: *xxx) void {} + pub fn bar(self: *xxx) void { + _ = self; + } }; test "bug 704" { var x: xxx = undefined; diff --git a/test/behavior/bugs/7250.zig b/test/behavior/bugs/7250.zig index b0f1aa15df154932641388e74a5aeb0980f00700..862b75f8513ef62a8ad8a9cd1f011fb19e95fdd8 100644 --- a/test/behavior/bugs/7250.zig +++ b/test/behavior/bugs/7250.zig @@ -3,7 +3,9 @@ const nrfx_uart_t = extern struct { drv_inst_idx: u8, }; -pub fn nrfx_uart_rx(p_instance: [*c]const nrfx_uart_t) void {} +pub fn nrfx_uart_rx(p_instance: [*c]const nrfx_uart_t) void { + _ = p_instance; +} threadlocal var g_uart0 = nrfx_uart_t{ .p_reg = 0, diff --git a/test/behavior/bugs/828.zig b/test/behavior/bugs/828.zig index 8b3f1bf99e0d4ab2c7da484b715e70ea7fa6abb5..d54664f9c6c05afb06460b88774dc0476b6da40d 100644 --- a/test/behavior/bugs/828.zig +++ b/test/behavior/bugs/828.zig @@ -4,6 +4,7 @@ const CountBy = struct { const One = CountBy{ .a = 1 }; pub fn counter(self: *const CountBy) Counter { + _ = self; return Counter{ .i = 0 }; } }; @@ -18,6 +19,7 @@ const Counter = struct { }; fn constCount(comptime cb: *const CountBy, comptime unused: u32) void { + _ = unused; comptime { var cnt = cb.counter(); if (cnt.i != 0) @compileError("Counter instance reused!"); diff --git a/test/behavior/bugs/920.zig b/test/behavior/bugs/920.zig index b148fce57852f9695d52f9a50a3f4028d159e311..8d30f01369147d7fbedb71c99e0263c74d633cfb 100644 --- a/test/behavior/bugs/920.zig +++ b/test/behavior/bugs/920.zig @@ -46,6 +46,8 @@ fn norm_f_inv(y: f64) f64 { return math.sqrt(-2.0 * math.ln(y)); } fn norm_zero_case(random: *Random, u: f64) f64 { + _ = random; + _ = u; return 0.0; } diff --git a/test/behavior/cast.zig b/test/behavior/cast.zig index ff3b11b85dc06c3eedfbf6f1559ca20baa3b322c..e9e2df991e065952afe71b9c887e4f7a222a5f57 100644 --- a/test/behavior/cast.zig +++ b/test/behavior/cast.zig @@ -824,9 +824,13 @@ test "variable initialization uses result locations properly with regards to the test "cast between [*c]T and ?[*:0]T on fn parameter" { const S = struct { const Handler = ?fn ([*c]const u8) callconv(.C) void; - fn addCallback(handler: Handler) void {} + fn addCallback(handler: Handler) void { + _ = handler; + } - fn myCallback(cstr: ?[*:0]const u8) callconv(.C) void {} + fn myCallback(cstr: ?[*:0]const u8) callconv(.C) void { + _ = cstr; + } fn doTheTest() void { addCallback(myCallback); diff --git a/test/behavior/error.zig b/test/behavior/error.zig index 70cf2c24c9b1668642269a9b69eb8f54b1a78670..b1ef55af9ebf9e30e73ac2e65e48eb7cf5bbc1a0 100644 --- a/test/behavior/error.zig +++ b/test/behavior/error.zig @@ -139,7 +139,10 @@ test "comptime test error for empty error set" { const EmptyErrorSet = error{}; fn testComptimeTestErrorEmptySet(x: EmptyErrorSet!i32) !void { - if (x) |v| try expect(v == 1234) else |err| @compileError("bad"); + if (x) |v| try expect(v == 1234) else |err| { + _ = err; + @compileError("bad"); + } } test "syntax: optional operator in front of error union operator" { @@ -394,6 +397,7 @@ test "function pointer with return type that is error union with payload which i const Err = error{UnspecifiedErr}; fn bar(a: i32) anyerror!*Foo { + _ = a; return Err.UnspecifiedErr; } @@ -448,7 +452,9 @@ test "error payload type is correctly resolved" { test "error union comptime caching" { const S = struct { - fn foo(comptime arg: anytype) void {} + fn foo(comptime arg: anytype) void { + arg catch {}; + } }; S.foo(@as(anyerror!void, {})); diff --git a/test/behavior/eval.zig b/test/behavior/eval.zig index 5f186a882540e366c00efd61e3e43cc45a7af898..80a3bccb7cb05e578efc1277626729649aa5b236 100644 --- a/test/behavior/eval.zig +++ b/test/behavior/eval.zig @@ -422,6 +422,7 @@ test { } pub fn TypeWithCompTimeSlice(comptime field_name: []const u8) type { + _ = field_name; return struct { pub const Node = struct {}; }; @@ -698,7 +699,9 @@ test "refer to the type of a generic function" { f(i32); } -fn doNothingWithType(comptime T: type) void {} +fn doNothingWithType(comptime T: type) void { + _ = T; +} test "zero extend from u0 to u1" { var zero_u0: u0 = 0; @@ -819,7 +822,9 @@ test "two comptime calls with array default initialized to undefined" { result.getCpuArch(); } - pub fn getCpuArch(self: CrossTarget) void {} + pub fn getCpuArch(self: CrossTarget) void { + _ = self; + } }; const DynamicLinker = struct { diff --git a/test/behavior/fn.zig b/test/behavior/fn.zig index 75a11310722907dbab9d58304e19d0484aa89c73..2567582cd35a6cf2e8fb751bc55f292876485d3e 100644 --- a/test/behavior/fn.zig +++ b/test/behavior/fn.zig @@ -23,6 +23,7 @@ test "void parameters" { try voidFun(1, void{}, 2, {}); } fn voidFun(a: i32, b: void, c: i32, d: void) !void { + _ = d; const v = b; const vv: void = if (a == 1) v else {}; try expect(a + c == 3); @@ -57,7 +58,9 @@ test "call function with empty string" { acceptsString(""); } -fn acceptsString(foo: []u8) void {} +fn acceptsString(foo: []u8) void { + _ = foo; +} fn @"weird function name"() i32 { return 1234; @@ -70,7 +73,9 @@ test "implicit cast function unreachable return" { wantsFnWithVoid(fnWithUnreachable); } -fn wantsFnWithVoid(f: fn () void) void {} +fn wantsFnWithVoid(f: fn () void) void { + _ = f; +} fn fnWithUnreachable() noreturn { unreachable; @@ -162,6 +167,7 @@ const Point3 = struct { y: i32, fn addPointCoords(self: Point3, comptime T: type) i32 { + _ = T; return self.x + self.y; } }; diff --git a/test/behavior/for.zig b/test/behavior/for.zig index 9f08d41246336ef64849e47b3999dbe633493e2b..b022df0958aee009903d04316aac5a392f7a0230 100644 --- a/test/behavior/for.zig +++ b/test/behavior/for.zig @@ -29,10 +29,14 @@ test "for loop with pointer elem var" { mangleString(target[0..]); try expect(mem.eql(u8, &target, "bcdefgh")); - for (source) |*c, i| + for (source) |*c, i| { + _ = i; try expect(@TypeOf(c) == *const u8); - for (target) |*c, i| + } + for (target) |*c, i| { + _ = i; try expect(@TypeOf(c) == *u8); + } } fn mangleString(s: []u8) void { @@ -53,6 +57,7 @@ test "basic for loop" { buf_index += 1; } for (array) |item, index| { + _ = item; buffer[buf_index] = @intCast(u8, index); buf_index += 1; } @@ -62,6 +67,7 @@ test "basic for loop" { buf_index += 1; } for (array_ptr) |item, index| { + _ = item; buffer[buf_index] = @intCast(u8, index); buf_index += 1; } @@ -70,7 +76,7 @@ test "basic for loop" { buffer[buf_index] = item; buf_index += 1; } - for (unknown_size) |item, index| { + for (unknown_size) |_, index| { buffer[buf_index] = @intCast(u8, index); buf_index += 1; } @@ -118,6 +124,7 @@ test "2 break statements and an else" { var buf: [10]u8 = undefined; var ok = false; ok = for (buf) |item| { + _ = item; if (f) break false; if (t) break true; } else false; @@ -136,6 +143,7 @@ test "for with null and T peer types and inferred result location type" { break item; } } else null) |v| { + _ = v; @panic("fail"); } } diff --git a/test/behavior/if.zig b/test/behavior/if.zig index 1951a9262ac24516e5933a23755069979d181d16..e8c84f4570a44b716cac097daf505cbe9196d31b 100644 --- a/test/behavior/if.zig +++ b/test/behavior/if.zig @@ -45,7 +45,7 @@ var global_with_err: anyerror!u32 = error.SomeError; test "unwrap mutable global var" { if (global_with_val) |v| { try expect(v == 0); - } else |e| { + } else |_| { unreachable; } if (global_with_err) |_| { diff --git a/test/behavior/misc.zig b/test/behavior/misc.zig index 64e6166e61eff9d855043570cb0ae717cdeb0eea..6fabbf487beb2bd96f29140d0c72f85521e9b815 100644 --- a/test/behavior/misc.zig +++ b/test/behavior/misc.zig @@ -245,14 +245,18 @@ var some_mem: [100]u8 = undefined; fn memAlloc(comptime T: type, n: usize) anyerror![]T { return @ptrCast([*]T, &some_mem[0])[0..n]; } -fn memFree(comptime T: type, memory: []T) void {} +fn memFree(comptime T: type, memory: []T) void { + _ = memory; +} test "cast undefined" { const array: [100]u8 = undefined; const slice = @as([]const u8, &array); testCastUndefined(slice); } -fn testCastUndefined(x: []const u8) void {} +fn testCastUndefined(x: []const u8) void { + _ = x; +} test "cast small unsigned to larger signed" { try expect(castSmallUnsignedToLargerSigned1(200) == @as(i16, 200)); @@ -452,6 +456,7 @@ test "@typeName" { } fn TypeFromFn(comptime T: type) type { + _ = T; return struct {}; } @@ -555,7 +560,12 @@ test "packed struct, enum, union parameters in extern function" { }), &(PackedUnion{ .a = 1 })); } -export fn testPackedStuff(a: *const PackedStruct, b: *const PackedUnion) void {} +export fn testPackedStuff(a: *const PackedStruct, b: *const PackedUnion) void { + if (false) { + a; + b; + } +} test "slicing zero length array" { const s1 = ""[0..]; @@ -584,6 +594,7 @@ test "self reference through fn ptr field" { }; fn foo(a: A) u8 { + _ = a; return 12; } }; @@ -753,7 +764,9 @@ test "extern variable with non-pointer opaque type" { test "lazy typeInfo value as generic parameter" { const S = struct { - fn foo(args: anytype) void {} + fn foo(args: anytype) void { + _ = args; + } }; S.foo(@typeInfo(@TypeOf(.{}))); } diff --git a/test/behavior/null.zig b/test/behavior/null.zig index 95c65b829b76b7845d81fd21b3f46ec594bea3c9..3bd652772bc14f62ecb330693e41753fc8a56737 100644 --- a/test/behavior/null.zig +++ b/test/behavior/null.zig @@ -130,6 +130,7 @@ var struct_with_optional: StructWithOptional = undefined; test "unwrap optional which is field of global var" { struct_with_optional.field = null; if (struct_with_optional.field) |payload| { + _ = payload; unreachable; } struct_with_optional.field = 1234; diff --git a/test/behavior/optional.zig b/test/behavior/optional.zig index 5803e854be5de4f2cdf8e460a66b2a16033faa34..29439158691c6aa61d61a0ab5a16ffe589b2ac93 100644 --- a/test/behavior/optional.zig +++ b/test/behavior/optional.zig @@ -161,6 +161,7 @@ test "self-referential struct through a slice of optional" { test "assigning to an unwrapped optional field in an inline loop" { comptime var maybe_pos_arg: ?comptime_int = null; inline for ("ab") |x| { + _ = x; maybe_pos_arg = 0; if (maybe_pos_arg.? != 0) { @compileError("bad"); diff --git a/test/behavior/pointers.zig b/test/behavior/pointers.zig index dede1effe16e01c550fdf48c17ec80f9d07ffcdd..bb95d3c219fea397ea3ad13389efe958dfe0ac13 100644 --- a/test/behavior/pointers.zig +++ b/test/behavior/pointers.zig @@ -179,6 +179,7 @@ test "assign null directly to C pointer and test null equality" { try expect(!(x != null)); try expect(!(null != x)); if (x) |same_x| { + _ = same_x; @panic("fail"); } var otherx: i32 = undefined; @@ -189,7 +190,10 @@ test "assign null directly to C pointer and test null equality" { comptime try expect(null == y); comptime try expect(!(y != null)); comptime try expect(!(null != y)); - if (y) |same_y| @panic("fail"); + if (y) |same_y| { + _ = same_y; + @panic("fail"); + } const othery: i32 = undefined; comptime try expect((y orelse &othery) == &othery); diff --git a/test/behavior/reflection.zig b/test/behavior/reflection.zig index 3e5e4087c41bc7719060f39d7f2208fb8b50cc42..e8596c28445a09abd655ef21cdeee0af1e81a65c 100644 --- a/test/behavior/reflection.zig +++ b/test/behavior/reflection.zig @@ -15,6 +15,11 @@ test "reflection: function return type, var args, and param types" { } fn dummy(a: bool, b: i32, c: f32) i32 { + if (false) { + a; + b; + c; + } return 1234; } diff --git a/test/behavior/struct.zig b/test/behavior/struct.zig index a400ffa343d5f93c3e93f02d9a90f5881f6817a7..4f7e0c2d7104fe11ac70f71662eb690d3ee6768a 100644 --- a/test/behavior/struct.zig +++ b/test/behavior/struct.zig @@ -182,6 +182,7 @@ test "empty struct method call" { } const EmptyStruct = struct { fn method(es: *const EmptyStruct) i32 { + _ = es; return 1234; } }; @@ -452,9 +453,11 @@ fn alloc(comptime T: type) []T { test "call method with mutable reference to struct with no fields" { const S = struct { fn doC(s: *const @This()) bool { + _ = s; return true; } fn do(s: *@This()) bool { + _ = s; return true; } }; @@ -625,11 +628,13 @@ test "for loop over pointers to struct, getting field from struct pointer" { var ok = true; fn eql(a: []const u8) bool { + _ = a; return true; } const ArrayList = struct { fn toSlice(self: *ArrayList) []*Foo { + _ = self; return @as([*]*Foo, undefined)[0..0]; } }; diff --git a/test/behavior/switch.zig b/test/behavior/switch.zig index ad32d2edaf895ba7b3c0d23ce51b49e597dbf1e7..e512565b806ca08253f44f2f47aefe2b61649e95 100644 --- a/test/behavior/switch.zig +++ b/test/behavior/switch.zig @@ -386,6 +386,7 @@ test "switch with null and T peer types and inferred result location type" { 0 => true, else => null, }) |v| { + _ = v; @panic("fail"); } } @@ -411,12 +412,18 @@ test "switch prongs with cases with identical payload types" { try expect(@TypeOf(e) == usize); try expect(e == 8); }, - .B => |e| @panic("fail"), + .B => |e| { + _ = e; + @panic("fail"); + }, } } fn doTheSwitch2(u: Union) !void { switch (u) { - .A, .C => |e| @panic("fail"), + .A, .C => |e| { + _ = e; + @panic("fail"); + }, .B => |e| { try expect(@TypeOf(e) == isize); try expect(e == -8); @@ -508,7 +515,10 @@ test "switch on error set with single else" { fn doTheTest() !void { var some: error{Foo} = error.Foo; try expect(switch (some) { - else => |a| true, + else => |a| blk: { + a catch {}; + break :blk true; + }, }); } }; diff --git a/test/behavior/type.zig b/test/behavior/type.zig index 44408a6d8ee3d7c1a8616a27d06347b377660805..fbd86f27cf4bf78d18691612bd46978a7833b846 100644 --- a/test/behavior/type.zig +++ b/test/behavior/type.zig @@ -431,6 +431,10 @@ test "Type.Fn" { const foo = struct { fn func(a: usize, b: bool) align(4) callconv(.C) usize { + if (false) { + a; + b; + } return 0; } }.func; @@ -444,7 +448,9 @@ test "Type.BoundFn" { if (builtin.target.cpu.arch == .wasm32 or builtin.target.cpu.arch == .wasm64) return error.SkipZigTest; const TestStruct = packed struct { - pub fn foo(self: *const @This()) align(4) callconv(.Unspecified) void {} + pub fn foo(self: *const @This()) align(4) callconv(.Unspecified) void { + _ = self; + } }; const test_instance: TestStruct = undefined; try testing.expect(std.meta.eql( diff --git a/test/behavior/type_info.zig b/test/behavior/type_info.zig index f81a9ed9bec86f639d7c007198dad8798e5d920e..8e8039372cb9832a5d4977ea298c812b913e3e9b 100644 --- a/test/behavior/type_info.zig +++ b/test/behavior/type_info.zig @@ -277,7 +277,9 @@ const TestStruct = packed struct { fieldC: *Self, fieldD: u32 = 4, - pub fn foo(self: *const Self) void {} + pub fn foo(self: *const Self) void { + _ = self; + } const Self = @This(); }; @@ -326,7 +328,9 @@ extern fn fooAligned(a: usize, b: bool, ...) align(4) callconv(.C) usize; test "typeInfo with comptime parameter in struct fn def" { const S = struct { - pub fn func(comptime x: f32) void {} + pub fn func(comptime x: f32) void { + _ = x; + } }; comptime var info = @typeInfo(S); _ = info; @@ -369,6 +373,7 @@ test "type info: pass to function" { } fn passTypeInfo(comptime info: TypeInfo) type { + _ = info; return void; } diff --git a/test/behavior/underscore.zig b/test/behavior/underscore.zig index 516d33a4ebf8e5b9b77d1d04d203607fc861a2a3..abe219f3e057bf2d453d00baf0b320d7a11c8441 100644 --- a/test/behavior/underscore.zig +++ b/test/behavior/underscore.zig @@ -7,7 +7,9 @@ test "ignore lval with underscore" { test "ignore lval with underscore (for loop)" { for ([_]void{}) |_, i| { + _ = i; for ([_]void{}) |_, j| { + _ = j; break; } break; diff --git a/test/behavior/union.zig b/test/behavior/union.zig index e9e8d638ace34f54a19f16edb0471b4fc071a2ad..f7c0c93696144583314a24051ed3ad0381b63362 100644 --- a/test/behavior/union.zig +++ b/test/behavior/union.zig @@ -374,7 +374,9 @@ const Attribute = union(enum) { B: u8, }; -fn setAttribute(attr: Attribute) void {} +fn setAttribute(attr: Attribute) void { + _ = attr; +} fn Setter(attr: Attribute) type { return struct { @@ -465,7 +467,9 @@ test "union no tag with struct member" { const Struct = struct {}; const Union = union { s: Struct, - pub fn foo(self: *@This()) void {} + pub fn foo(self: *@This()) void { + _ = self; + } }; var u = Union{ .s = Struct{} }; u.foo(); @@ -703,6 +707,7 @@ test "method call on an empty union" { X2: [0]u8, pub fn useIt(self: *@This()) bool { + _ = self; return true; } }; @@ -771,6 +776,7 @@ test "@unionInit on union w/ tag but no fields" { no_op: void, pub fn decode(buf: []const u8) Data { + _ = buf; return @unionInit(Data, "no_op", {}); } }; diff --git a/test/behavior/var_args.zig b/test/behavior/var_args.zig index d9a8bf297e66185502c8dc9af14605caa94db737..40770e1334aae6c54bf9d6d286073334c183a6d3 100644 --- a/test/behavior/var_args.zig +++ b/test/behavior/var_args.zig @@ -48,6 +48,7 @@ test "runtime parameter before var args" { } fn extraFn(extra: u32, args: anytype) !usize { + _ = extra; if (args.len >= 1) { try expect(args[0] == false); } @@ -63,9 +64,11 @@ const foos = [_]fn (anytype) bool{ }; fn foo1(args: anytype) bool { + _ = args; return true; } fn foo2(args: anytype) bool { + _ = args; return false; } diff --git a/test/behavior/while.zig b/test/behavior/while.zig index a237b4b8666a4aac0d0d6d402b18764cd48562c6..e52adfdbcf4527d8bc314f762a3bc6e9aed7e62f 100644 --- a/test/behavior/while.zig +++ b/test/behavior/while.zig @@ -151,14 +151,14 @@ test "while on optional with else result follow break prong" { test "while on error union with else result follow else prong" { const result = while (returnError()) |value| { break value; - } else |err| @as(i32, 2); + } else |_| @as(i32, 2); try expect(result == 2); } test "while on error union with else result follow break prong" { const result = while (returnSuccess(10)) |value| { break value; - } else |err| @as(i32, 2); + } else |_| @as(i32, 2); try expect(result == 10); } diff --git a/test/stage2/cbe.zig b/test/stage2/cbe.zig index 1221788e9de1ee5b24e95a8c6f1d080ac9252740..fd55015dd5f4d1b16aa875d84a29d48abfad494f 100644 --- a/test/stage2/cbe.zig +++ b/test/stage2/cbe.zig @@ -823,31 +823,35 @@ pub fn addCases(ctx: *TestContext) !void { \\ ); ctx.h("header with single param function", linux_x64, - \\export fn start(a: u8) void{} + \\export fn start(a: u8) void{ + \\ _ = a; + \\} , \\ZIG_EXTERN_C void start(uint8_t a0); \\ ); ctx.h("header with multiple param function", linux_x64, - \\export fn start(a: u8, b: u8, c: u8) void{} + \\export fn start(a: u8, b: u8, c: u8) void{ + \\ _ = a; _ = b; _ = c; + \\} , \\ZIG_EXTERN_C void start(uint8_t a0, uint8_t a1, uint8_t a2); \\ ); ctx.h("header with u32 param function", linux_x64, - \\export fn start(a: u32) void{} + \\export fn start(a: u32) void{ _ = a; } , \\ZIG_EXTERN_C void start(uint32_t a0); \\ ); ctx.h("header with usize param function", linux_x64, - \\export fn start(a: usize) void{} + \\export fn start(a: usize) void{ _ = a; } , \\ZIG_EXTERN_C void start(uintptr_t a0); \\ ); ctx.h("header with bool param function", linux_x64, - \\export fn start(a: bool) void{} + \\export fn start(a: bool) void{_ = a;} , \\ZIG_EXTERN_C void start(bool a0); \\ @@ -871,7 +875,7 @@ pub fn addCases(ctx: *TestContext) !void { \\ ); ctx.h("header with multiple includes", linux_x64, - \\export fn start(a: u32, b: usize) void{} + \\export fn start(a: u32, b: usize) void{ _ = a; _ = b; } , \\ZIG_EXTERN_C void start(uint32_t a0, uintptr_t a1); \\ diff --git a/test/stage2/test.zig b/test/stage2/test.zig index d49863032942acf60fb225581da0c4ab88d411ef..8ce46f206475a09a38d260f61ef47e694b489a13 100644 --- a/test/stage2/test.zig +++ b/test/stage2/test.zig @@ -1392,7 +1392,9 @@ pub fn addCases(ctx: *TestContext) !void { \\pub fn main() void { \\ doNothing(0); \\} - \\fn doNothing(arg: u0) void {} + \\fn doNothing(arg: u0) void { + \\ _ = arg; + \\} , "", ); diff --git a/test/stage2/wasm.zig b/test/stage2/wasm.zig index bed2ae2684dd59b2173183b001f2d5fb2efa54a1..07386e8212c620e17cb33ce70eda80b8c92d7eb0 100644 --- a/test/stage2/wasm.zig +++ b/test/stage2/wasm.zig @@ -64,7 +64,7 @@ pub fn addCases(ctx: *TestContext) !void { \\ foo(10, 20); \\ return 5; \\} - \\fn foo(x: u32, y: u32) void {} + \\fn foo(x: u32, y: u32) void { _ = x; _ = y; } , "5\n"); } @@ -95,6 +95,7 @@ pub fn addCases(ctx: *TestContext) !void { \\ return i; \\} \\fn foo(x: u32, y: u32) void { + \\ _ = y; \\ var i: u32 = 10; \\ i = x; \\} diff --git a/test/standalone/hello_world/hello_libc.zig b/test/standalone/hello_world/hello_libc.zig index 5c0a233f1ccf632ea1d469fcc35a11407f783ea6..42ba4db4b194dc35dc348246c2177b03c195e238 100644 --- a/test/standalone/hello_world/hello_libc.zig +++ b/test/standalone/hello_world/hello_libc.zig @@ -8,6 +8,8 @@ const c = @cImport({ const msg = "Hello, world!\n"; pub export fn main(argc: c_int, argv: **u8) c_int { + _ = argv; + _ = argc; if (c.printf(msg) != @intCast(c_int, c.strlen(msg))) return -1; return 0; } diff --git a/test/standalone/issue_339/test.zig b/test/standalone/issue_339/test.zig index 2d0c14c0f5cb5a3a3d6895efdac17da4d91f32a5..5e0aafc182a84cc5f91f5c0f00fad85921f91c07 100644 --- a/test/standalone/issue_339/test.zig +++ b/test/standalone/issue_339/test.zig @@ -1,5 +1,7 @@ const StackTrace = @import("std").builtin.StackTrace; pub fn panic(msg: []const u8, stack_trace: ?*StackTrace) noreturn { + _ = msg; + _ = stack_trace; @breakpoint(); while (true) {} } diff --git a/test/standalone/issue_8550/main.zig b/test/standalone/issue_8550/main.zig index 7dae7f856c32362d0768382db77b7d1b8300d314..393f72460be4137c0e381a34420344e270589feb 100644 --- a/test/standalone/issue_8550/main.zig +++ b/test/standalone/issue_8550/main.zig @@ -1,6 +1,8 @@ -export fn main(r0: u32, r1: u32, atags: u32) callconv(.C) noreturn { +export fn main() callconv(.C) noreturn { unreachable; // never gets run so it doesn't matter } pub fn panic(msg: []const u8, error_return_trace: ?*@import("std").builtin.StackTrace) noreturn { + _ = msg; + _ = error_return_trace; while (true) {} } diff --git a/test/tests.zig b/test/tests.zig index 84830f85b42d2fb284ed69733cf9dd8d623b3c46..8871c184281a3c98c4d133e7dd6484529b655cef 100644 --- a/test/tests.zig +++ b/test/tests.zig @@ -417,6 +417,8 @@ pub fn addStandaloneTests(b: *build.Builder, test_filter: ?[]const u8, modes: [] } pub fn addCliTests(b: *build.Builder, test_filter: ?[]const u8, modes: []const Mode) *build.Step { + _ = test_filter; + _ = modes; const step = b.step("test-cli", "Test the command line interface"); const exe = b.addExecutable("test-cli", "test/cli.zig"); diff --git a/tools/process_headers.zig b/tools/process_headers.zig index c0876887325b14b1b9008102a2153ccd9ca2ee37..51fc69e5794ace0271d36df4a987b75f08ab2389 100644 --- a/tools/process_headers.zig +++ b/tools/process_headers.zig @@ -236,12 +236,14 @@ const DestTarget = struct { const HashContext = struct { pub fn hash(self: @This(), a: DestTarget) u32 { + _ = self; return @enumToInt(a.arch) +% (@enumToInt(a.os) *% @as(u32, 4202347608)) +% (@enumToInt(a.abi) *% @as(u32, 4082223418)); } pub fn eql(self: @This(), a: DestTarget, b: DestTarget) bool { + _ = self; return a.arch.eql(b.arch) and a.os == b.os and a.abi == b.abi; @@ -256,6 +258,7 @@ const Contents = struct { is_generic: bool, fn hitCountLessThan(context: void, lhs: *const Contents, rhs: *const Contents) bool { + _ = context; return lhs.hit_count < rhs.hit_count; } }; diff --git a/tools/update_clang_options.zig b/tools/update_clang_options.zig index f5f5cc8e2465d0963302b2f2ddd2797dd25210af..04cdbf44de8901cd84955e9618ce4b3b0cb630fa 100644 --- a/tools/update_clang_options.zig +++ b/tools/update_clang_options.zig @@ -585,6 +585,8 @@ const Syntax = union(enum) { options: std.fmt.FormatOptions, out_stream: anytype, ) !void { + _ = fmt; + _ = options; switch (self) { .multi_arg => |n| return out_stream.print(".{{.{s}={}}}", .{ @tagName(self), n }), else => return out_stream.print(".{s}", .{@tagName(self)}), @@ -663,6 +665,7 @@ fn syntaxMatchesWithEql(syntax: Syntax) bool { } fn objectLessThan(context: void, a: *json.ObjectMap, b: *json.ObjectMap) bool { + _ = context; // Priority is determined by exact matches first, followed by prefix matches in descending // length, with key as a final tiebreaker. const a_syntax = objSyntax(a); diff --git a/tools/update_cpu_features.zig b/tools/update_cpu_features.zig index dfaeec28626bfc716aa5ef776f3435957f962f2b..68d9b233a7402d82a63e25edb4f9f89a0bc6f775 100644 --- a/tools/update_cpu_features.zig +++ b/tools/update_cpu_features.zig @@ -1227,14 +1227,17 @@ fn usageAndExit(file: fs.File, arg0: []const u8, code: u8) noreturn { } fn featureLessThan(context: void, a: Feature, b: Feature) bool { + _ = context; return std.ascii.lessThanIgnoreCase(a.zig_name, b.zig_name); } fn cpuLessThan(context: void, a: Cpu, b: Cpu) bool { + _ = context; return std.ascii.lessThanIgnoreCase(a.zig_name, b.zig_name); } fn asciiLessThan(context: void, a: []const u8, b: []const u8) bool { + _ = context; return std.ascii.lessThanIgnoreCase(a, b); } diff --git a/tools/update_glibc.zig b/tools/update_glibc.zig index 94e4ab756ed3525eafbc4a3a19627a5d7aeec44e..ba12f6e0e66bf23d81cdb5067b647e2d058f6769 100644 --- a/tools/update_glibc.zig +++ b/tools/update_glibc.zig @@ -155,7 +155,7 @@ pub fn main() !void { } const fn_set = &target_funcs_gop.value_ptr.list; - for (lib_names) |lib_name, lib_name_index| { + for (lib_names) |lib_name| { const lib_prefix = if (std.mem.eql(u8, lib_name, "ld")) "" else "lib"; const basename = try fmt.allocPrint(allocator, "{s}{s}.abilist", .{ lib_prefix, lib_name }); const abi_list_filename = blk: { @@ -263,7 +263,7 @@ pub fn main() !void { // Now the mapping of version and function to integer index is complete. // Here we create a mapping of function name to list of versions. - for (abi_lists) |*abi_list, abi_index| { + for (abi_lists) |*abi_list| { const value = target_functions.getPtr(@ptrToInt(abi_list)).?; const fn_vers_list = &value.fn_vers_list; for (value.list.items) |*ver_fn| { @@ -286,7 +286,7 @@ pub fn main() !void { const abilist_txt = buffered.writer(); // first iterate over the abi lists - for (abi_lists) |*abi_list, abi_index| { + for (abi_lists) |*abi_list| { const fn_vers_list = &target_functions.getPtr(@ptrToInt(abi_list)).?.fn_vers_list; for (abi_list.targets) |target, it_i| { if (it_i != 0) try abilist_txt.writeByte(' '); @@ -312,10 +312,12 @@ pub fn main() !void { } pub fn strCmpLessThan(context: void, a: []const u8, b: []const u8) bool { + _ = context; return std.mem.order(u8, a, b) == .lt; } pub fn versionLessThan(context: void, a: []const u8, b: []const u8) bool { + _ = context; const sep_chars = "GLIBC_."; var a_tokens = std.mem.tokenize(a, sep_chars); var b_tokens = std.mem.tokenize(b, sep_chars); diff --git a/tools/update_spirv_features.zig b/tools/update_spirv_features.zig index 5f2bab6c286236eed4135743d96173de6e491618..0de1c56934947e335d295b1ce8c6f6f25c2957bb 100644 --- a/tools/update_spirv_features.zig +++ b/tools/update_spirv_features.zig @@ -37,6 +37,7 @@ const Version = struct { } fn lessThan(ctx: void, a: Version, b: Version) bool { + _ = ctx; return if (a.major == b.major) a.minor < b.minor else