authorgravatar for jacoblevgw@gmail.comJacob G-W <jacoblevgw@gmail.com> 2021-06-19 21:10:22-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-06-21 17:03:03-07:00
log9fffffb07b081858db0c2102a0680aa166b48263
tree36caed31c5b2aaa8e08bb8e6e90e9b2c30910ff3
parentb83b3883ba0b5e965f8f7f1298c77c6d766741af

fix code broken from previous commit


162 files changed, 720 insertions(+), 148 deletions(-)

lib/std/Progress.zig+1-1
......@@ -295,7 +295,7 @@ fn refreshWithHeldLock(self: *Progress) void {
295295 end += 1;
296296 }
297297
298 _ = file.write(self.output_buffer[0..end]) catch |e| {
298 _ = file.write(self.output_buffer[0..end]) catch {
299299 // Stop trying to write to this file once it errors.
300300 self.terminal = null;
301301 };
lib/std/SemanticVersion.zig+2-1
......@@ -162,6 +162,7 @@ pub fn format(
162162 options: std.fmt.FormatOptions,
163163 out_stream: anytype,
164164) !void {
165 _ = options;
165166 if (fmt.len != 0) @compileError("Unknown format string: '" ++ fmt ++ "'");
166167 try std.fmt.format(out_stream, "{d}.{d}.{d}", .{ self.major, self.minor, self.patch });
167168 if (self.pre) |pre| try std.fmt.format(out_stream, "-{s}", .{pre});
......@@ -259,7 +260,7 @@ test "SemanticVersion format" {
259260
260261 // Invalid version string that may overflow.
261262 const big_invalid = "99999999999999999999999.999999999999999999.99999999999999999----RC-SNAPSHOT.12.09.1--------------------------------..12";
262 if (parse(big_invalid)) |ver| std.debug.panic("expected error, found {}", .{ver}) else |err| {}
263 if (parse(big_invalid)) |ver| std.debug.panic("expected error, found {}", .{ver}) else |_| {}
263264}
264265
265266test "SemanticVersion precedence" {
lib/std/Thread/Condition.zig+8-2
......@@ -40,12 +40,18 @@ else
4040
4141pub const SingleThreadedCondition = struct {
4242 pub fn wait(cond: *SingleThreadedCondition, mutex: *Mutex) void {
43 _ = cond;
44 _ = mutex;
4345 unreachable; // deadlock detected
4446 }
4547
46 pub fn signal(cond: *SingleThreadedCondition) void {}
48 pub fn signal(cond: *SingleThreadedCondition) void {
49 _ = cond;
50 }
4751
48 pub fn broadcast(cond: *SingleThreadedCondition) void {}
52 pub fn broadcast(cond: *SingleThreadedCondition) void {
53 _ = cond;
54 }
4955};
5056
5157pub const WindowsCondition = struct {
lib/std/Thread/StaticResetEvent.zig+6-1
......@@ -105,6 +105,7 @@ pub const DebugEvent = struct {
105105 }
106106
107107 pub fn timedWait(ev: *DebugEvent, timeout: u64) TimedWaitResult {
108 _ = timeout;
108109 switch (ev.state) {
109110 .unset => return .timed_out,
110111 .set => return .event_set,
......@@ -174,7 +175,10 @@ pub const AtomicEvent = struct {
174175 };
175176
176177 pub const SpinFutex = struct {
177 fn wake(waiters: *u32, wake_count: u32) void {}
178 fn wake(waiters: *u32, wake_count: u32) void {
179 _ = waiters;
180 _ = wake_count;
181 }
178182
179183 fn wait(waiters: *u32, timeout: ?u64) !void {
180184 var timer: time.Timer = undefined;
......@@ -193,6 +197,7 @@ pub const AtomicEvent = struct {
193197
194198 pub const LinuxFutex = struct {
195199 fn wake(waiters: *u32, wake_count: u32) void {
200 _ = wake_count;
196201 const waiting = std.math.maxInt(i32); // wake_count
197202 const ptr = @ptrCast(*const i32, waiters);
198203 const rc = linux.futex_wake(ptr, linux.FUTEX_WAKE | linux.FUTEX_PRIVATE_FLAG, waiting);
lib/std/array_hash_map.zig+11-2
......@@ -40,9 +40,11 @@ pub fn StringArrayHashMapUnmanaged(comptime V: type) type {
4040
4141pub const StringContext = struct {
4242 pub fn hash(self: @This(), s: []const u8) u32 {
43 _ = self;
4344 return hashString(s);
4445 }
4546 pub fn eql(self: @This(), a: []const u8, b: []const u8) bool {
47 _ = self;
4648 return eqlString(a, b);
4749 }
4850};
......@@ -1335,6 +1337,7 @@ pub fn ArrayHashMapUnmanaged(
13351337 }
13361338
13371339 fn removeSlot(self: *Self, removed_slot: usize, header: *IndexHeader, comptime I: type, indexes: []Index(I)) void {
1340 _ = self;
13381341 const start_index = removed_slot +% 1;
13391342 const end_index = start_index +% indexes.len;
13401343
......@@ -1626,6 +1629,7 @@ pub fn ArrayHashMapUnmanaged(
16261629 }
16271630 }
16281631 fn dumpIndex(self: Self, header: *IndexHeader, comptime I: type) void {
1632 _ = self;
16291633 const p = std.debug.print;
16301634 p(" index len=0x{x} type={}\n", .{ header.length(), header.capacityIndexType() });
16311635 const indexes = header.indexes(I);
......@@ -1918,7 +1922,7 @@ test "iterator hash map" {
19181922 try testing.expect(count == 3);
19191923 try testing.expect(it.next() == null);
19201924
1921 for (buffer) |v, i| {
1925 for (buffer) |_, i| {
19221926 try testing.expect(buffer[@intCast(usize, keys[i])] == values[i]);
19231927 }
19241928
......@@ -1930,7 +1934,7 @@ test "iterator hash map" {
19301934 if (count >= 2) break;
19311935 }
19321936
1933 for (buffer[0..2]) |v, i| {
1937 for (buffer[0..2]) |_, i| {
19341938 try testing.expect(buffer[@intCast(usize, keys[i])] == values[i]);
19351939 }
19361940
......@@ -2154,6 +2158,7 @@ test "compile everything" {
21542158pub fn getHashPtrAddrFn(comptime K: type, comptime Context: type) (fn (Context, K) u32) {
21552159 return struct {
21562160 fn hash(ctx: Context, key: K) u32 {
2161 _ = ctx;
21572162 return getAutoHashFn(usize, void)({}, @ptrToInt(key));
21582163 }
21592164 }.hash;
......@@ -2162,6 +2167,7 @@ pub fn getHashPtrAddrFn(comptime K: type, comptime Context: type) (fn (Context,
21622167pub fn getTrivialEqlFn(comptime K: type, comptime Context: type) (fn (Context, K, K) bool) {
21632168 return struct {
21642169 fn eql(ctx: Context, a: K, b: K) bool {
2170 _ = ctx;
21652171 return a == b;
21662172 }
21672173 }.eql;
......@@ -2177,6 +2183,7 @@ pub fn AutoContext(comptime K: type) type {
21772183pub fn getAutoHashFn(comptime K: type, comptime Context: type) (fn (Context, K) u32) {
21782184 return struct {
21792185 fn hash(ctx: Context, key: K) u32 {
2186 _ = ctx;
21802187 if (comptime trait.hasUniqueRepresentation(K)) {
21812188 return @truncate(u32, Wyhash.hash(0, std.mem.asBytes(&key)));
21822189 } else {
......@@ -2191,6 +2198,7 @@ pub fn getAutoHashFn(comptime K: type, comptime Context: type) (fn (Context, K)
21912198pub fn getAutoEqlFn(comptime K: type, comptime Context: type) (fn (Context, K, K) bool) {
21922199 return struct {
21932200 fn eql(ctx: Context, a: K, b: K) bool {
2201 _ = ctx;
21942202 return meta.eql(a, b);
21952203 }
21962204 }.eql;
......@@ -2217,6 +2225,7 @@ pub fn autoEqlIsCheap(comptime K: type) bool {
22172225pub fn getAutoHashStratFn(comptime K: type, comptime Context: type, comptime strategy: std.hash.Strategy) (fn (Context, K) u32) {
22182226 return struct {
22192227 fn hash(ctx: Context, key: K) u32 {
2228 _ = ctx;
22202229 var hasher = Wyhash.init(0);
22212230 std.hash.autoHashStrat(&hasher, key, strategy);
22222231 return @truncate(u32, hasher.final());
lib/std/atomic/Atomic.zig+2
......@@ -232,6 +232,7 @@ test "Atomic.loadUnchecked" {
232232
233233test "Atomic.storeUnchecked" {
234234 inline for (atomicIntTypes()) |Int| {
235 _ = Int;
235236 var x = Atomic(usize).init(5);
236237 x.storeUnchecked(10);
237238 try testing.expectEqual(x.loadUnchecked(), 10);
......@@ -250,6 +251,7 @@ test "Atomic.load" {
250251test "Atomic.store" {
251252 inline for (atomicIntTypes()) |Int| {
252253 inline for (.{ .Unordered, .Monotonic, .Release, .SeqCst }) |ordering| {
254 _ = Int;
253255 var x = Atomic(usize).init(5);
254256 x.store(10, ordering);
255257 try testing.expectEqual(x.load(.SeqCst), 10);
lib/std/bit_set.zig+4-2
......@@ -84,6 +84,7 @@ pub fn IntegerBitSet(comptime size: u16) type {
8484
8585 /// Returns the number of bits in this bit set
8686 pub inline fn capacity(self: Self) usize {
87 _ = self;
8788 return bit_length;
8889 }
8990
......@@ -311,6 +312,7 @@ pub fn ArrayBitSet(comptime MaskIntType: type, comptime size: usize) type {
311312
312313 /// Returns the number of bits in this bit set
313314 pub inline fn capacity(self: Self) usize {
315 _ = self;
314316 return bit_length;
315317 }
316318
......@@ -373,7 +375,7 @@ pub fn ArrayBitSet(comptime MaskIntType: type, comptime size: usize) type {
373375
374376 /// Flips every bit in the bit set.
375377 pub fn toggleAll(self: *Self) void {
376 for (self.masks) |*mask, i| {
378 for (self.masks) |*mask| {
377379 mask.* = ~mask.*;
378380 }
379381
......@@ -642,7 +644,7 @@ pub const DynamicBitSetUnmanaged = struct {
642644 if (bit_length == 0) return;
643645
644646 const num_masks = numMasks(self.bit_length);
645 for (self.masks[0..num_masks]) |*mask, i| {
647 for (self.masks[0..num_masks]) |*mask| {
646648 mask.* = ~mask.*;
647649 }
648650
lib/std/build.zig+5-2
......@@ -390,6 +390,7 @@ pub const Builder = struct {
390390 }
391391
392392 pub fn version(self: *const Builder, major: u32, minor: u32, patch: u32) LibExeObjStep.SharedLibKind {
393 _ = self;
393394 return .{
394395 .versioned = .{
395396 .major = major,
......@@ -543,7 +544,7 @@ pub const Builder = struct {
543544 return null;
544545 },
545546 .scalar => |s| {
546 const n = std.fmt.parseFloat(T, s) catch |err| {
547 const n = std.fmt.parseFloat(T, s) catch {
547548 warn("Expected -D{s} to be a float of type {s}.\n\n", .{ name, @typeName(T) });
548549 self.markInvalidUserInput();
549550 return null;
......@@ -3129,7 +3130,9 @@ pub const Step = struct {
31293130 self.dependencies.append(other) catch unreachable;
31303131 }
31313132
3132 fn makeNoOp(self: *Step) anyerror!void {}
3133 fn makeNoOp(self: *Step) anyerror!void {
3134 _ = self;
3135 }
31333136
31343137 pub fn cast(step: *Step, comptime T: type) ?*T {
31353138 if (step.id == T.base_id) {
lib/std/build/InstallRawStep.zig+2
......@@ -139,6 +139,7 @@ const BinaryElfOutput = struct {
139139 }
140140
141141 fn segmentSortCompare(context: void, left: *BinaryElfSegment, right: *BinaryElfSegment) bool {
142 _ = context;
142143 if (left.physicalAddress < right.physicalAddress) {
143144 return true;
144145 }
......@@ -149,6 +150,7 @@ const BinaryElfOutput = struct {
149150 }
150151
151152 fn sectionSortCompare(context: void, left: *BinaryElfSection, right: *BinaryElfSection) bool {
153 _ = context;
152154 return left.binaryOffset < right.binaryOffset;
153155 }
154156};
lib/std/builtin.zig+3
......@@ -65,6 +65,8 @@ pub const StackTrace = struct {
6565 options: std.fmt.FormatOptions,
6666 writer: anytype,
6767 ) !void {
68 _ = fmt;
69 _ = options;
6870 var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator);
6971 defer arena.deinit();
7072 const debug_info = std.debug.getSelfDebugInfo() catch |err| {
......@@ -521,6 +523,7 @@ pub const Version = struct {
521523 options: std.fmt.FormatOptions,
522524 out_stream: anytype,
523525 ) !void {
526 _ = options;
524527 if (fmt.len == 0) {
525528 if (self.patch == 0) {
526529 if (self.minor == 0) {
lib/std/comptime_string_map.zig+1
......@@ -23,6 +23,7 @@ pub fn ComptimeStringMap(comptime V: type, comptime kvs: anytype) type {
2323 var sorted_kvs: [kvs.len]KV = undefined;
2424 const lenAsc = (struct {
2525 fn lenAsc(context: void, a: KV, b: KV) bool {
26 _ = context;
2627 return a.key.len < b.key.len;
2728 }
2829 }).lenAsc;
lib/std/crypto/25519/ed25519.zig+1-1
......@@ -346,7 +346,7 @@ test "ed25519 test vectors" {
346346 .expected = error.IdentityElement, // 11 - small-order A
347347 },
348348 };
349 for (entries) |entry, i| {
349 for (entries) |entry| {
350350 var msg: [entry.msg_hex.len / 2]u8 = undefined;
351351 _ = try fmt.hexToBytes(&msg, entry.msg_hex);
352352 var public_key: [32]u8 = undefined;
lib/std/crypto/blake3.zig+1
......@@ -394,6 +394,7 @@ pub const Blake3 = struct {
394394 /// Construct a new `Blake3` for the key derivation function. The context
395395 /// string should be hardcoded, globally unique, and application-specific.
396396 pub fn initKdf(context: []const u8, options: KdfOptions) Blake3 {
397 _ = options;
397398 var context_hasher = Blake3.init_internal(IV, DERIVE_KEY_CONTEXT);
398399 context_hasher.update(context);
399400 var context_key: [KEY_LEN]u8 = undefined;
lib/std/crypto/gimli.zig+1
......@@ -219,6 +219,7 @@ pub const Hash = struct {
219219 const Self = @This();
220220
221221 pub fn init(options: Options) Self {
222 _ = options;
222223 return Self{
223224 .state = State{ .data = [_]u32{0} ** (State.BLOCKBYTES / 4) },
224225 .buf_off = 0,
lib/std/crypto/md5.zig+1
......@@ -45,6 +45,7 @@ pub const Md5 = struct {
4545 total_len: u64,
4646
4747 pub fn init(options: Options) Self {
48 _ = options;
4849 return Self{
4950 .s = [_]u32{
5051 0x67452301,
lib/std/crypto/pcurves/p256/scalar.zig+1
......@@ -63,6 +63,7 @@ pub fn add(a: CompressedScalar, b: CompressedScalar, endian: builtin.Endian) Non
6363
6464/// Return -s (mod L)
6565pub fn neg(s: CompressedScalar, endian: builtin.Endian) NonCanonicalError!CompressedScalar {
66 _ = s;
6667 return (try Scalar.fromBytes(a, endian)).neg().toBytes(endian);
6768}
6869
lib/std/crypto/sha1.zig+1
......@@ -43,6 +43,7 @@ pub const Sha1 = struct {
4343 total_len: u64 = 0,
4444
4545 pub fn init(options: Options) Self {
46 _ = options;
4647 return Self{
4748 .s = [_]u32{
4849 0x67452301,
lib/std/crypto/sha2.zig+2
......@@ -95,6 +95,7 @@ fn Sha2x32(comptime params: Sha2Params32) type {
9595 total_len: u64 = 0,
9696
9797 pub fn init(options: Options) Self {
98 _ = options;
9899 return Self{
99100 .s = [_]u32{
100101 params.iv0,
......@@ -462,6 +463,7 @@ fn Sha2x64(comptime params: Sha2Params64) type {
462463 total_len: u128 = 0,
463464
464465 pub fn init(options: Options) Self {
466 _ = options;
465467 return Self{
466468 .s = [_]u64{
467469 params.iv0,
lib/std/crypto/sha3.zig+1
......@@ -28,6 +28,7 @@ fn Keccak(comptime bits: usize, comptime delim: u8) type {
2828 rate: usize,
2929
3030 pub fn init(options: Options) Self {
31 _ = options;
3132 return Self{ .s = [_]u8{0} ** 200, .offset = 0, .rate = 200 - (bits / 4) };
3233 }
3334
lib/std/crypto/tlcsprng.zig+1-1
......@@ -84,7 +84,7 @@ fn tlsCsprngFill(_: *const std.rand.Random, buffer: []u8) void {
8484 os.MAP_PRIVATE | os.MAP_ANONYMOUS,
8585 -1,
8686 0,
87 ) catch |err| {
87 ) catch {
8888 // Could not allocate memory for the local state, fall back to
8989 // the OS syscall.
9090 return fillWithOsEntropy(buffer);
lib/std/debug.zig+5
......@@ -325,6 +325,7 @@ pub fn writeStackTrace(
325325 debug_info: *DebugInfo,
326326 tty_config: TTY.Config,
327327) !void {
328 _ = allocator;
328329 if (builtin.strip_debug_info) return error.MissingDebugInfo;
329330 var frame_index: usize = 0;
330331 var frames_left: usize = std.math.min(stack_trace.index, stack_trace.instruction_addresses.len);
......@@ -930,6 +931,7 @@ const MachoSymbol = struct {
930931 }
931932
932933 fn addressLessThan(context: void, lhs: MachoSymbol, rhs: MachoSymbol) bool {
934 _ = context;
933935 return lhs.address() < rhs.address();
934936 }
935937};
......@@ -1134,6 +1136,7 @@ pub const DebugInfo = struct {
11341136
11351137 if (os.dl_iterate_phdr(&ctx, anyerror, struct {
11361138 fn callback(info: *os.dl_phdr_info, size: usize, context: *CtxTy) !void {
1139 _ = size;
11371140 // The base address is too high
11381141 if (context.address < info.dlpi_addr)
11391142 return;
......@@ -1189,6 +1192,8 @@ pub const DebugInfo = struct {
11891192 }
11901193
11911194 fn lookupModuleHaiku(self: *DebugInfo, address: usize) !*ModuleDebugInfo {
1195 _ = self;
1196 _ = address;
11921197 @panic("TODO implement lookup module for Haiku");
11931198 }
11941199};
lib/std/dwarf.zig+4-2
......@@ -283,6 +283,7 @@ fn parseFormValueBlock(allocator: *mem.Allocator, in_stream: anytype, endian: bu
283283}
284284
285285fn parseFormValueConstant(allocator: *mem.Allocator, in_stream: anytype, signed: bool, endian: builtin.Endian, comptime size: i32) !FormValue {
286 _ = allocator;
286287 // TODO: Please forgive me, I've worked around zig not properly spilling some intermediate values here.
287288 // `nosuspend` should be removed from all the function calls once it is fixed.
288289 return FormValue{
......@@ -310,6 +311,7 @@ fn parseFormValueConstant(allocator: *mem.Allocator, in_stream: anytype, signed:
310311
311312// TODO the nosuspends here are workarounds
312313fn parseFormValueRef(allocator: *mem.Allocator, in_stream: anytype, endian: builtin.Endian, size: i32) !FormValue {
314 _ = allocator;
313315 return FormValue{
314316 .Ref = switch (size) {
315317 1 => try nosuspend in_stream.readInt(u8, endian),
......@@ -453,13 +455,13 @@ pub const DwarfInfo = struct {
453455 if (this_die_obj.getAttr(AT_name)) |_| {
454456 const name = try this_die_obj.getAttrString(di, AT_name);
455457 break :x name;
456 } else if (this_die_obj.getAttr(AT_abstract_origin)) |ref| {
458 } else if (this_die_obj.getAttr(AT_abstract_origin)) |_| {
457459 // Follow the DIE it points to and repeat
458460 const ref_offset = try this_die_obj.getAttrRef(AT_abstract_origin);
459461 if (ref_offset > next_offset) return error.InvalidDebugInfo;
460462 try seekable.seekTo(this_unit_offset + ref_offset);
461463 this_die_obj = (try di.parseDie(in, abbrev_table, is_64)) orelse return error.InvalidDebugInfo;
462 } else if (this_die_obj.getAttr(AT_specification)) |ref| {
464 } else if (this_die_obj.getAttr(AT_specification)) |_| {
463465 // Follow the DIE it points to and repeat
464466 const ref_offset = try this_die_obj.getAttrRef(AT_specification);
465467 if (ref_offset > next_offset) return error.InvalidDebugInfo;
lib/std/dynamic_library.zig+1
......@@ -66,6 +66,7 @@ pub fn get_DYNAMIC() ?[*]elf.Dyn {
6666}
6767
6868pub fn linkmap_iterator(phdrs: []elf.Phdr) !LinkMap.Iterator {
69 _ = phdrs;
6970 const _DYNAMIC = get_DYNAMIC() orelse {
7071 // No PT_DYNAMIC means this is either a statically-linked program or a
7172 // badly corrupted dynamically-linked one.
lib/std/enums.zig+6-2
......@@ -18,7 +18,7 @@ const EnumField = std.builtin.TypeInfo.EnumField;
1818pub fn EnumFieldStruct(comptime E: type, comptime Data: type, comptime field_default: ?Data) type {
1919 const StructField = std.builtin.TypeInfo.StructField;
2020 var fields: []const StructField = &[_]StructField{};
21 for (std.meta.fields(E)) |field, i| {
21 for (std.meta.fields(E)) |field| {
2222 fields = fields ++ &[_]StructField{.{
2323 .name = field.name,
2424 .field_type = Data,
......@@ -144,7 +144,7 @@ pub fn directEnumArrayDefault(
144144) [directEnumArrayLen(E, max_unused_slots)]Data {
145145 const len = comptime directEnumArrayLen(E, max_unused_slots);
146146 var result: [len]Data = if (default) |d| [_]Data{d} ** len else undefined;
147 inline for (@typeInfo(@TypeOf(init_values)).Struct.fields) |f, i| {
147 inline for (@typeInfo(@TypeOf(init_values)).Struct.fields) |f| {
148148 const enum_value = @field(E, f.name);
149149 const index = @intCast(usize, @enumToInt(enum_value));
150150 result[index] = @field(init_values, f.name);
......@@ -334,6 +334,7 @@ pub fn EnumArray(comptime E: type, comptime V: type) type {
334334/// TODO: Once #8169 is fixed, consider switching this param
335335/// back to an optional.
336336pub fn NoExtension(comptime Self: type) type {
337 _ = Self;
337338 return NoExt;
338339}
339340const NoExt = struct {};
......@@ -729,6 +730,7 @@ test "std.enums.ensureIndexer" {
729730}
730731
731732fn ascByValue(ctx: void, comptime a: EnumField, comptime b: EnumField) bool {
733 _ = ctx;
732734 return a.value < b.value;
733735}
734736pub fn EnumIndexer(comptime E: type) type {
......@@ -743,9 +745,11 @@ pub fn EnumIndexer(comptime E: type) type {
743745 pub const Key = E;
744746 pub const count: usize = 0;
745747 pub fn indexOf(e: E) usize {
748 _ = e;
746749 unreachable;
747750 }
748751 pub fn keyForIndex(i: usize) E {
752 _ = i;
749753 unreachable;
750754 }
751755 };
lib/std/event/loop.zig+1-1
......@@ -345,7 +345,7 @@ pub const Loop = struct {
345345 );
346346 errdefer windows.CloseHandle(self.os_data.io_port);
347347
348 for (self.eventfd_resume_nodes) |*eventfd_node, i| {
348 for (self.eventfd_resume_nodes) |*eventfd_node| {
349349 eventfd_node.* = std.atomic.Stack(ResumeNode.EventFd).Node{
350350 .data = ResumeNode.EventFd{
351351 .base = ResumeNode{
lib/std/fmt.zig+12-1
......@@ -369,6 +369,7 @@ pub fn format(
369369}
370370
371371pub fn formatAddress(value: anytype, options: FormatOptions, writer: anytype) @TypeOf(writer).Error!void {
372 _ = options;
372373 const T = @TypeOf(value);
373374
374375 switch (@typeInfo(T)) {
......@@ -553,7 +554,7 @@ pub fn formatType(
553554 .Many, .C => {
554555 if (actual_fmt.len == 0)
555556 @compileError("cannot format pointer without a specifier (i.e. {s} or {*})");
556 if (ptr_info.sentinel) |sentinel| {
557 if (ptr_info.sentinel) |_| {
557558 return formatType(mem.span(value), actual_fmt, options, writer, max_depth);
558559 }
559560 if (ptr_info.child == u8) {
......@@ -741,6 +742,8 @@ fn formatSliceHexImpl(comptime case: Case) type {
741742 options: std.fmt.FormatOptions,
742743 writer: anytype,
743744 ) !void {
745 _ = fmt;
746 _ = options;
744747 var buf: [2]u8 = undefined;
745748
746749 for (bytes) |c| {
......@@ -777,6 +780,8 @@ fn formatSliceEscapeImpl(comptime case: Case) type {
777780 options: std.fmt.FormatOptions,
778781 writer: anytype,
779782 ) !void {
783 _ = fmt;
784 _ = options;
780785 var buf: [4]u8 = undefined;
781786
782787 buf[0] = '\\';
......@@ -820,6 +825,7 @@ fn formatSizeImpl(comptime radix: comptime_int) type {
820825 options: FormatOptions,
821826 writer: anytype,
822827 ) !void {
828 _ = fmt;
823829 if (value == 0) {
824830 return writer.writeAll("0B");
825831 }
......@@ -903,6 +909,7 @@ pub fn formatAsciiChar(
903909 options: FormatOptions,
904910 writer: anytype,
905911) !void {
912 _ = options;
906913 return writer.writeAll(@as(*const [1]u8, &c));
907914}
908915
......@@ -1362,6 +1369,8 @@ pub fn formatIntBuf(out_buf: []u8, value: anytype, base: u8, case: Case, options
13621369}
13631370
13641371fn formatDuration(ns: u64, comptime fmt: []const u8, options: std.fmt.FormatOptions, writer: anytype) !void {
1372 _ = fmt;
1373 _ = options;
13651374 var ns_remaining = ns;
13661375 inline for (.{
13671376 .{ .ns = 365 * std.time.ns_per_day, .sep = 'y' },
......@@ -2152,6 +2161,7 @@ test "custom" {
21522161 options: FormatOptions,
21532162 writer: anytype,
21542163 ) !void {
2164 _ = options;
21552165 if (fmt.len == 0 or comptime std.mem.eql(u8, fmt, "p")) {
21562166 return std.fmt.format(writer, "({d:.3},{d:.3})", .{ self.x, self.y });
21572167 } else if (comptime std.mem.eql(u8, fmt, "d")) {
......@@ -2340,6 +2350,7 @@ test "formatType max_depth" {
23402350 options: FormatOptions,
23412351 writer: anytype,
23422352 ) !void {
2353 _ = options;
23432354 if (fmt.len == 0) {
23442355 return std.fmt.format(writer, "({d:.3},{d:.3})", .{ self.x, self.y });
23452356 } else {
lib/std/fs.zig+2-1
......@@ -1541,7 +1541,7 @@ pub const Dir = struct {
15411541 self: Dir,
15421542 target_path: []const u8,
15431543 sym_link_path: []const u8,
1544 flags: SymLinkFlags,
1544 _: SymLinkFlags,
15451545 ) !void {
15461546 return os.symlinkatWasi(target_path, self.fd, sym_link_path);
15471547 }
......@@ -1879,6 +1879,7 @@ pub const Dir = struct {
18791879 /// * NtDll prefixed
18801880 /// TODO currently this ignores `flags`.
18811881 pub fn accessW(self: Dir, sub_path_w: [*:0]const u16, flags: File.OpenFlags) AccessError!void {
1882 _ = flags;
18821883 return os.faccessatW(self.fd, sub_path_w, 0, 0);
18831884 }
18841885
lib/std/fs/path.zig+2-2
......@@ -579,7 +579,7 @@ pub fn resolveWindows(allocator: *Allocator, paths: []const []const u8) ![]u8 {
579579 // Now we know the disk designator to use, if any, and what kind it is. And our result
580580 // is big enough to append all the paths to.
581581 var correct_disk_designator = true;
582 for (paths[first_index..]) |p, i| {
582 for (paths[first_index..]) |p| {
583583 const parsed = windowsParsePath(p);
584584
585585 if (parsed.kind != WindowsPath.Kind.None) {
......@@ -660,7 +660,7 @@ pub fn resolvePosix(allocator: *Allocator, paths: []const []const u8) ![]u8 {
660660 }
661661 errdefer allocator.free(result);
662662
663 for (paths[first_index..]) |p, i| {
663 for (paths[first_index..]) |p| {
664664 var it = mem.tokenize(p, "/");
665665 while (it.next()) |component| {
666666 if (mem.eql(u8, component, ".")) {
lib/std/fs/test.zig+2
......@@ -541,6 +541,7 @@ test "makePath, put some files in it, deleteTree" {
541541 try tmp.dir.writeFile("os_test_tmp" ++ fs.path.sep_str ++ "b" ++ fs.path.sep_str ++ "file2.txt", "blah");
542542 try tmp.dir.deleteTree("os_test_tmp");
543543 if (tmp.dir.openDir("os_test_tmp", .{})) |dir| {
544 _ = dir;
544545 @panic("expected error");
545546 } else |err| {
546547 try testing.expect(err == error.FileNotFound);
......@@ -638,6 +639,7 @@ test "access file" {
638639
639640 try tmp.dir.makePath("os_test_tmp");
640641 if (tmp.dir.access("os_test_tmp" ++ fs.path.sep_str ++ "file.txt", .{})) |ok| {
642 _ = ok;
641643 @panic("expected error");
642644 } else |err| {
643645 try testing.expect(err == error.FileNotFound);
lib/std/fs/wasi.zig+2
......@@ -36,6 +36,8 @@ pub const PreopenType = union(PreopenTypeTag) {
3636 }
3737
3838 pub fn format(self: Self, comptime fmt: []const u8, options: std.fmt.FormatOptions, out_stream: anytype) !void {
39 _ = fmt;
40 _ = options;
3941 try out_stream.print("PreopenType{{ ", .{});
4042 switch (self) {
4143 PreopenType.Dir => |path| try out_stream.print(".Dir = '{}'", .{std.zig.fmtId(path)}),
lib/std/hash/cityhash.zig+1
......@@ -375,6 +375,7 @@ fn SMHasherTest(comptime hash_fn: anytype) u32 {
375375}
376376
377377fn CityHash32hashIgnoreSeed(str: []const u8, seed: u32) u32 {
378 _ = seed;
378379 return CityHash32.hash(str);
379380}
380381
lib/std/hash_map.zig+6
......@@ -29,6 +29,7 @@ pub fn getAutoHashFn(comptime K: type, comptime Context: type) (fn (Context, K)
2929
3030 return struct {
3131 fn hash(ctx: Context, key: K) u64 {
32 _ = ctx;
3233 if (comptime trait.hasUniqueRepresentation(K)) {
3334 return Wyhash.hash(0, std.mem.asBytes(&key));
3435 } else {
......@@ -43,6 +44,7 @@ pub fn getAutoHashFn(comptime K: type, comptime Context: type) (fn (Context, K)
4344pub fn getAutoEqlFn(comptime K: type, comptime Context: type) (fn (Context, K, K) bool) {
4445 return struct {
4546 fn eql(ctx: Context, a: K, b: K) bool {
47 _ = ctx;
4648 return meta.eql(a, b);
4749 }
4850 }.eql;
......@@ -78,9 +80,11 @@ pub fn StringHashMapUnmanaged(comptime V: type) type {
7880
7981pub const StringContext = struct {
8082 pub fn hash(self: @This(), s: []const u8) u64 {
83 _ = self;
8184 return hashString(s);
8285 }
8386 pub fn eql(self: @This(), a: []const u8, b: []const u8) bool {
87 _ = self;
8488 return eqlString(a, b);
8589 }
8690};
......@@ -1887,9 +1891,11 @@ test "std.hash_map clone" {
18871891test "std.hash_map getOrPutAdapted" {
18881892 const AdaptedContext = struct {
18891893 fn eql(self: @This(), adapted_key: []const u8, test_key: u64) bool {
1894 _ = self;
18901895 return std.fmt.parseInt(u64, adapted_key, 10) catch unreachable == test_key;
18911896 }
18921897 fn hash(self: @This(), adapted_key: []const u8) u64 {
1898 _ = self;
18931899 const key = std.fmt.parseInt(u64, adapted_key, 10) catch unreachable;
18941900 return (AutoContext(u64){}).hash(key);
18951901 }
lib/std/heap.zig+30
......@@ -108,6 +108,8 @@ const CAllocator = struct {
108108 len_align: u29,
109109 return_address: usize,
110110 ) error{OutOfMemory}![]u8 {
111 _ = allocator;
112 _ = return_address;
111113 assert(len > 0);
112114 assert(std.math.isPowerOfTwo(alignment));
113115
......@@ -134,6 +136,9 @@ const CAllocator = struct {
134136 len_align: u29,
135137 return_address: usize,
136138 ) Allocator.Error!usize {
139 _ = allocator;
140 _ = buf_align;
141 _ = return_address;
137142 if (new_len == 0) {
138143 alignedFree(buf.ptr);
139144 return 0;
......@@ -178,6 +183,9 @@ fn rawCAlloc(
178183 len_align: u29,
179184 ret_addr: usize,
180185) Allocator.Error![]u8 {
186 _ = self;
187 _ = len_align;
188 _ = ret_addr;
181189 assert(ptr_align <= @alignOf(std.c.max_align_t));
182190 const ptr = @ptrCast([*]u8, c.malloc(len) orelse return error.OutOfMemory);
183191 return ptr[0..len];
......@@ -191,6 +199,9 @@ fn rawCResize(
191199 len_align: u29,
192200 ret_addr: usize,
193201) Allocator.Error!usize {
202 _ = self;
203 _ = old_align;
204 _ = ret_addr;
194205 if (new_len == 0) {
195206 c.free(buf.ptr);
196207 return 0;
......@@ -231,6 +242,8 @@ pub var next_mmap_addr_hint: ?[*]align(mem.page_size) u8 = null;
231242
232243const PageAllocator = struct {
233244 fn alloc(allocator: *Allocator, n: usize, alignment: u29, len_align: u29, ra: usize) error{OutOfMemory}![]u8 {
245 _ = allocator;
246 _ = ra;
234247 assert(n > 0);
235248 const aligned_len = mem.alignForward(n, mem.page_size);
236249
......@@ -334,6 +347,9 @@ const PageAllocator = struct {
334347 len_align: u29,
335348 return_address: usize,
336349 ) Allocator.Error!usize {
350 _ = allocator;
351 _ = buf_align;
352 _ = return_address;
337353 const new_size_aligned = mem.alignForward(new_size, mem.page_size);
338354
339355 if (builtin.os.tag == .windows) {
......@@ -482,6 +498,8 @@ const WasmPageAllocator = struct {
482498 }
483499
484500 fn alloc(allocator: *Allocator, len: usize, alignment: u29, len_align: u29, ra: usize) error{OutOfMemory}![]u8 {
501 _ = allocator;
502 _ = ra;
485503 const page_count = nPages(len);
486504 const page_idx = try allocPages(page_count, alignment);
487505 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 {
542560 len_align: u29,
543561 return_address: usize,
544562 ) error{OutOfMemory}!usize {
563 _ = allocator;
564 _ = buf_align;
565 _ = return_address;
545566 const aligned_len = mem.alignForward(buf.len, mem.page_size);
546567 if (new_len > aligned_len) return error.OutOfMemory;
547568 const current_n = nPages(aligned_len);
......@@ -588,6 +609,7 @@ pub const HeapAllocator = switch (builtin.os.tag) {
588609 len_align: u29,
589610 return_address: usize,
590611 ) error{OutOfMemory}![]u8 {
612 _ = return_address;
591613 const self = @fieldParentPtr(HeapAllocator, "allocator", allocator);
592614
593615 const amt = n + ptr_align - 1 + @sizeOf(usize);
......@@ -622,6 +644,8 @@ pub const HeapAllocator = switch (builtin.os.tag) {
622644 len_align: u29,
623645 return_address: usize,
624646 ) error{OutOfMemory}!usize {
647 _ = buf_align;
648 _ = return_address;
625649 const self = @fieldParentPtr(HeapAllocator, "allocator", allocator);
626650 if (new_size == 0) {
627651 os.windows.HeapFree(self.heap_handle.?, 0, @intToPtr(*c_void, getRecordPtr(buf).*));
......@@ -694,6 +718,8 @@ pub const FixedBufferAllocator = struct {
694718 }
695719
696720 fn alloc(allocator: *Allocator, n: usize, ptr_align: u29, len_align: u29, ra: usize) ![]u8 {
721 _ = len_align;
722 _ = ra;
697723 const self = @fieldParentPtr(FixedBufferAllocator, "allocator", allocator);
698724 const adjust_off = mem.alignPointerOffset(self.buffer.ptr + self.end_index, ptr_align) orelse
699725 return error.OutOfMemory;
......@@ -716,6 +742,8 @@ pub const FixedBufferAllocator = struct {
716742 len_align: u29,
717743 return_address: usize,
718744 ) Allocator.Error!usize {
745 _ = buf_align;
746 _ = return_address;
719747 const self = @fieldParentPtr(FixedBufferAllocator, "allocator", allocator);
720748 assert(self.ownsSlice(buf)); // sanity check
721749
......@@ -766,6 +794,8 @@ pub const ThreadSafeFixedBufferAllocator = blk: {
766794 }
767795
768796 fn alloc(allocator: *Allocator, n: usize, ptr_align: u29, len_align: u29, ra: usize) ![]u8 {
797 _ = len_align;
798 _ = ra;
769799 const self = @fieldParentPtr(ThreadSafeFixedBufferAllocator, "allocator", allocator);
770800 var end_index = @atomicLoad(usize, &self.end_index, builtin.AtomicOrder.SeqCst);
771801 while (true) {
lib/std/heap/arena_allocator.zig+5
......@@ -66,6 +66,8 @@ pub const ArenaAllocator = struct {
6666 }
6767
6868 fn alloc(allocator: *Allocator, n: usize, ptr_align: u29, len_align: u29, ra: usize) ![]u8 {
69 _ = len_align;
70 _ = ra;
6971 const self = @fieldParentPtr(ArenaAllocator, "allocator", allocator);
7072
7173 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 {
9597 }
9698
9799 fn resize(allocator: *Allocator, buf: []u8, buf_align: u29, new_len: usize, len_align: u29, ret_addr: usize) Allocator.Error!usize {
100 _ = buf_align;
101 _ = len_align;
102 _ = ret_addr;
98103 const self = @fieldParentPtr(ArenaAllocator, "allocator", allocator);
99104
100105 const cur_node = self.state.buffer_list.first orelse return error.OutOfMemory;
lib/std/heap/log_to_writer_allocator.zig+2-2
......@@ -37,9 +37,9 @@ pub fn LogToWriterAllocator(comptime Writer: type) type {
3737 const self = @fieldParentPtr(Self, "allocator", allocator);
3838 self.writer.print("alloc : {}", .{len}) catch {};
3939 const result = self.parent_allocator.allocFn(self.parent_allocator, len, ptr_align, len_align, ra);
40 if (result) |buff| {
40 if (result) |_| {
4141 self.writer.print(" success!\n", .{}) catch {};
42 } else |err| {
42 } else |_| {
4343 self.writer.print(" failure!\n", .{}) catch {};
4444 }
4545 return result;
lib/std/heap/logging_allocator.zig+1-1
......@@ -65,7 +65,7 @@ pub fn ScopedLoggingAllocator(
6565 ) error{OutOfMemory}![]u8 {
6666 const self = @fieldParentPtr(Self, "allocator", allocator);
6767 const result = self.parent_allocator.allocFn(self.parent_allocator, len, ptr_align, len_align, ra);
68 if (result) |buff| {
68 if (result) |_| {
6969 logHelper(
7070 success_log_level,
7171 "alloc - success - len: {}, ptr_align: {}, len_align: {}",
lib/std/io.zig+1
......@@ -161,6 +161,7 @@ pub const null_writer = @as(NullWriter, .{ .context = {} });
161161
162162const NullWriter = Writer(void, error{}, dummyWrite);
163163fn dummyWrite(context: void, data: []const u8) error{}!usize {
164 _ = context;
164165 return data.len;
165166}
166167
lib/std/io/bit_reader.zig+1-1
......@@ -149,7 +149,7 @@ pub fn BitReader(endian: builtin.Endian, comptime ReaderType: type) type {
149149 var out_bits_total = @as(usize, 0);
150150 //@NOTE: I'm not sure this is a good idea, maybe alignToByte should be forced
151151 if (self.bit_count > 0) {
152 for (buffer) |*b, i| {
152 for (buffer) |*b| {
153153 b.* = try self.readBits(u8, u8_bit_count, &out_bits);
154154 out_bits_total += out_bits;
155155 }
lib/std/io/bit_writer.zig+1-1
......@@ -128,7 +128,7 @@ pub fn BitWriter(endian: builtin.Endian, comptime WriterType: type) type {
128128 pub fn write(self: *Self, buffer: []const u8) Error!usize {
129129 // TODO: I'm not sure this is a good idea, maybe flushBits should be forced
130130 if (self.bit_count > 0) {
131 for (buffer) |b, i|
131 for (buffer) |b|
132132 try self.writeBits(b, u8_bit_count);
133133 return buffer.len;
134134 }
lib/std/json.zig+8-6
......@@ -1221,11 +1221,11 @@ test "json.token premature object close" {
12211221pub fn validate(s: []const u8) bool {
12221222 var p = StreamingParser.init();
12231223
1224 for (s) |c, i| {
1224 for (s) |c| {
12251225 var token1: ?Token = undefined;
12261226 var token2: ?Token = undefined;
12271227
1228 p.feed(c, &token1, &token2) catch |err| {
1228 p.feed(c, &token1, &token2) catch {
12291229 return false;
12301230 };
12311231 }
......@@ -1410,7 +1410,7 @@ fn parsedEqual(a: anytype, b: @TypeOf(a)) bool {
14101410 if (a == null or b == null) return false;
14111411 return parsedEqual(a.?, b.?);
14121412 },
1413 .Union => |unionInfo| {
1413 .Union => {
14141414 if (info.tag_type) |UnionTag| {
14151415 const tag_a = std.meta.activeTag(a);
14161416 const tag_b = std.meta.activeTag(b);
......@@ -1771,7 +1771,7 @@ fn parseInternal(comptime T: type, token: Token, tokens: *TokenStream, options:
17711771 const source_slice = stringToken.slice(tokens.slice, tokens.i - 1);
17721772 switch (stringToken.escapes) {
17731773 .None => return allocator.dupe(u8, source_slice),
1774 .Some => |some_escapes| {
1774 .Some => {
17751775 const output = try allocator.alloc(u8, stringToken.decodedLength());
17761776 errdefer allocator.free(output);
17771777 try unescapeValidString(output, source_slice);
......@@ -2391,7 +2391,7 @@ pub const Parser = struct {
23912391 const slice = s.slice(input, i);
23922392 switch (s.escapes) {
23932393 .None => return Value{ .String = if (p.copy_strings) try allocator.dupe(u8, slice) else slice },
2394 .Some => |some_escapes| {
2394 .Some => {
23952395 const output = try allocator.alloc(u8, s.decodedLength());
23962396 errdefer allocator.free(output);
23972397 try unescapeValidString(output, slice);
......@@ -2401,6 +2401,7 @@ pub const Parser = struct {
24012401 }
24022402
24032403 fn parseNumber(p: *Parser, n: std.meta.TagPayload(Token, Token.Number), input: []const u8, i: usize) !Value {
2404 _ = p;
24042405 return if (n.is_integer)
24052406 Value{
24062407 .Integer = std.fmt.parseInt(i64, n.slice(input, i), 10) catch |e| switch (e) {
......@@ -2815,7 +2816,7 @@ pub fn stringify(
28152816 if (child_options.whitespace) |*child_whitespace| {
28162817 child_whitespace.indent_level += 1;
28172818 }
2818 inline for (S.fields) |Field, field_i| {
2819 inline for (S.fields) |Field| {
28192820 // don't include void fields
28202821 if (Field.field_type == void) continue;
28212822
......@@ -3114,6 +3115,7 @@ test "stringify struct with custom stringifier" {
31143115 options: StringifyOptions,
31153116 out_stream: anytype,
31163117 ) !void {
3118 _ = value;
31173119 try out_stream.writeAll("[\"something special\",");
31183120 try stringify(42, options, out_stream);
31193121 try out_stream.writeByte(']');
lib/std/linked_list.zig+1-1
......@@ -63,7 +63,7 @@ pub fn SinglyLinkedList(comptime T: type) type {
6363 pub fn countChildren(node: *const Node) usize {
6464 var count: usize = 0;
6565 var it: ?*const Node = node.next;
66 while (it) |n| : (it = n.next) {
66 while (it) |_| : (it = n.next) {
6767 count += 1;
6868 }
6969 return count;
lib/std/math/big/int.zig+4
......@@ -458,6 +458,7 @@ pub const Mutable = struct {
458458 /// If `allocator` is provided, it will be used for temporary storage to improve
459459 /// multiplication performance. `error.OutOfMemory` is handled with a fallback algorithm.
460460 pub fn sqrNoAlias(rma: *Mutable, a: Const, opt_allocator: ?*Allocator) void {
461 _ = opt_allocator;
461462 assert(rma.limbs.ptr != a.limbs.ptr); // illegal aliasing
462463
463464 mem.set(Limb, rma.limbs, 0);
......@@ -676,6 +677,7 @@ pub const Mutable = struct {
676677 ///
677678 /// `limbs_buffer` is used for temporary storage during the operation.
678679 pub fn gcdNoAlias(rma: *Mutable, x: Const, y: Const, limbs_buffer: *std.ArrayList(Limb)) !void {
680 _ = limbs_buffer;
679681 assert(rma.limbs.ptr != x.limbs.ptr); // illegal aliasing
680682 assert(rma.limbs.ptr != y.limbs.ptr); // illegal aliasing
681683 return gcdLehmer(rma, x, y, allocator);
......@@ -1141,6 +1143,7 @@ pub const Const = struct {
11411143 options: std.fmt.FormatOptions,
11421144 out_stream: anytype,
11431145 ) !void {
1146 _ = options;
11441147 comptime var radix = 10;
11451148 comptime var case: std.fmt.Case = .lower;
11461149
......@@ -1618,6 +1621,7 @@ pub const Managed = struct {
16181621 /// Converts self to a string in the requested base. Memory is allocated from the provided
16191622 /// allocator and not the one present in self.
16201623 pub fn toString(self: Managed, allocator: *Allocator, base: u8, case: std.fmt.Case) ![]u8 {
1624 _ = allocator;
16211625 if (base < 2 or base > 16) return error.InvalidBase;
16221626 return self.toConst().toStringAlloc(self.allocator, base, case);
16231627 }
lib/std/mem.zig+5
......@@ -139,6 +139,11 @@ var failAllocator = Allocator{
139139 .resizeFn = Allocator.noResize,
140140};
141141fn failAllocatorAlloc(self: *Allocator, n: usize, alignment: u29, len_align: u29, ra: usize) Allocator.Error![]u8 {
142 _ = self;
143 _ = n;
144 _ = alignment;
145 _ = len_align;
146 _ = ra;
142147 return error.OutOfMemory;
143148}
144149
lib/std/mem/Allocator.zig+4
......@@ -55,6 +55,10 @@ pub fn noResize(
5555 len_align: u29,
5656 ret_addr: usize,
5757) Error!usize {
58 _ = self;
59 _ = buf_align;
60 _ = len_align;
61 _ = ret_addr;
5862 if (new_len > buf.len)
5963 return error.OutOfMemory;
6064 return new_len;
lib/std/meta.zig+1
......@@ -843,6 +843,7 @@ pub const refAllDecls = @compileError("refAllDecls has been moved from std.meta
843843pub fn declList(comptime Namespace: type, comptime Decl: type) []const *const Decl {
844844 const S = struct {
845845 fn declNameLessThan(context: void, lhs: *const Decl, rhs: *const Decl) bool {
846 _ = context;
846847 return mem.lessThan(u8, lhs.name, rhs.name);
847848 }
848849 };
lib/std/meta/trailer_flags.zig+1
......@@ -108,6 +108,7 @@ pub fn TrailerFlags(comptime Fields: type) type {
108108 }
109109
110110 pub fn offset(self: Self, p: [*]align(@alignOf(Fields)) const u8, comptime field: FieldEnum) usize {
111 _ = p;
111112 var off: usize = 0;
112113 inline for (@typeInfo(Fields).Struct.fields) |field_info, i| {
113114 const active = (self.bits & (1 << i)) != 0;
lib/std/multi_array_list.zig+3-2
......@@ -92,6 +92,7 @@ pub fn MultiArrayList(comptime S: type) type {
9292 }
9393 const Sort = struct {
9494 fn lessThan(trash: *i32, lhs: Data, rhs: Data) bool {
95 _ = trash;
9596 return lhs.alignment > rhs.alignment;
9697 }
9798 };
......@@ -221,7 +222,7 @@ pub fn MultiArrayList(comptime S: type) type {
221222 /// retain list ordering.
222223 pub fn swapRemove(self: *Self, index: usize) void {
223224 const slices = self.slice();
224 inline for (fields) |field_info, i| {
225 inline for (fields) |_, i| {
225226 const field_slice = slices.items(@intToEnum(Field, i));
226227 field_slice[index] = field_slice[self.len - 1];
227228 field_slice[self.len - 1] = undefined;
......@@ -233,7 +234,7 @@ pub fn MultiArrayList(comptime S: type) type {
233234 /// after it to preserve order.
234235 pub fn orderedRemove(self: *Self, index: usize) void {
235236 const slices = self.slice();
236 inline for (fields) |field_info, field_index| {
237 inline for (fields) |_, field_index| {
237238 const field_slice = slices.items(@intToEnum(Field, field_index));
238239 var i = index;
239240 while (i < self.len - 1) : (i += 1) {
lib/std/net.zig+7
......@@ -270,6 +270,8 @@ pub const Ip4Address = extern struct {
270270 options: std.fmt.FormatOptions,
271271 out_stream: anytype,
272272 ) !void {
273 _ = fmt;
274 _ = options;
273275 const bytes = @ptrCast(*const [4]u8, &self.sa.addr);
274276 try std.fmt.format(out_stream, "{}.{}.{}.{}:{}", .{
275277 bytes[0],
......@@ -281,6 +283,7 @@ pub const Ip4Address = extern struct {
281283 }
282284
283285 pub fn getOsSockLen(self: Ip4Address) os.socklen_t {
286 _ = self;
284287 return @sizeOf(os.sockaddr_in);
285288 }
286289};
......@@ -556,6 +559,8 @@ pub const Ip6Address = extern struct {
556559 options: std.fmt.FormatOptions,
557560 out_stream: anytype,
558561 ) !void {
562 _ = fmt;
563 _ = options;
559564 const port = mem.bigToNative(u16, self.sa.port);
560565 if (mem.eql(u8, self.sa.addr[0..12], &[_]u8{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xff, 0xff })) {
561566 try std.fmt.format(out_stream, "[::ffff:{}.{}.{}.{}]:{}", .{
......@@ -598,6 +603,7 @@ pub const Ip6Address = extern struct {
598603 }
599604
600605 pub fn getOsSockLen(self: Ip6Address) os.socklen_t {
606 _ = self;
601607 return @sizeOf(os.sockaddr_in6);
602608 }
603609};
......@@ -1062,6 +1068,7 @@ fn IN6_IS_ADDR_SITELOCAL(a: [16]u8) bool {
10621068
10631069// Parameters `b` and `a` swapped to make this descending.
10641070fn addrCmpLessThan(context: void, b: LookupAddr, a: LookupAddr) bool {
1071 _ = context;
10651072 return a.sortkey < b.sortkey;
10661073}
10671074
lib/std/once.zig+1
......@@ -61,6 +61,7 @@ test "Once executes its function just once" {
6161 for (threads) |*handle| {
6262 handle.* = try std.Thread.spawn(struct {
6363 fn thread_fn(x: u8) void {
64 _ = x;
6465 global_once.call();
6566 }
6667 }.thread_fn, 0);
lib/std/os.zig+10
......@@ -1164,6 +1164,7 @@ fn openOptionsFromFlags(flags: u32) windows.OpenFileOptions {
11641164/// TODO currently, this function does not handle all flag combinations
11651165/// or makes use of perm argument.
11661166pub fn openW(file_path_w: []const u16, flags: u32, perm: mode_t) OpenError!fd_t {
1167 _ = perm;
11671168 var options = openOptionsFromFlags(flags);
11681169 options.dir = std.fs.cwd().fd;
11691170 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)
12731274/// TODO currently, this function does not handle all flag combinations
12741275/// or makes use of perm argument.
12751276pub fn openatW(dir_fd: fd_t, file_path_w: []const u16, flags: u32, mode: mode_t) OpenError!fd_t {
1277 _ = mode;
12761278 var options = openOptionsFromFlags(flags);
12771279 options.dir = dir_fd;
12781280 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
21692171pub const mkdiratC = @compileError("deprecated: renamed to mkdiratZ");
21702172
21712173pub fn mkdiratWasi(dir_fd: fd_t, sub_dir_path: []const u8, mode: u32) MakeDirError!void {
2174 _ = mode;
21722175 switch (wasi.path_create_directory(dir_fd, sub_dir_path.ptr, sub_dir_path.len)) {
21732176 wasi.ESUCCESS => return,
21742177 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
22162219}
22172220
22182221pub fn mkdiratW(dir_fd: fd_t, sub_path_w: []const u16, mode: u32) MakeDirError!void {
2222 _ = mode;
22192223 const sub_dir_handle = windows.OpenFile(sub_path_w, .{
22202224 .dir = dir_fd,
22212225 .access_mask = windows.GENERIC_READ | windows.SYNCHRONIZE,
......@@ -2291,6 +2295,7 @@ pub fn mkdirZ(dir_path: [*:0]const u8, mode: u32) MakeDirError!void {
22912295
22922296/// Windows-only. Same as `mkdir` but the parameters is WTF16 encoded.
22932297pub fn mkdirW(dir_path_w: []const u16, mode: u32) MakeDirError!void {
2298 _ = mode;
22942299 const sub_dir_handle = windows.OpenFile(dir_path_w, .{
22952300 .dir = std.fs.cwd().fd,
22962301 .access_mask = windows.GENERIC_READ | windows.SYNCHRONIZE,
......@@ -3868,6 +3873,7 @@ pub fn accessZ(path: [*:0]const u8, mode: u32) AccessError!void {
38683873/// Otherwise use `access` or `accessC`.
38693874/// TODO currently this ignores `mode`.
38703875pub fn accessW(path: [*:0]const u16, mode: u32) windows.GetFileAttributesError!void {
3876 _ = mode;
38713877 const ret = try windows.GetFileAttributesW(path);
38723878 if (ret != windows.INVALID_FILE_ATTRIBUTES) {
38733879 return;
......@@ -3918,6 +3924,8 @@ pub fn faccessatZ(dirfd: fd_t, path: [*:0]const u8, mode: u32, flags: u32) Acces
39183924/// is NtDll-prefixed, null-terminated, WTF-16 encoded.
39193925/// TODO currently this ignores `mode` and `flags`
39203926pub fn faccessatW(dirfd: fd_t, sub_path_w: [*:0]const u16, mode: u32, flags: u32) AccessError!void {
3927 _ = mode;
3928 _ = flags;
39213929 if (sub_path_w[0] == '.' and sub_path_w[1] == 0) {
39223930 return;
39233931 }
......@@ -4895,6 +4903,8 @@ pub fn res_mkquery(
48954903 newrr: ?[*]const u8,
48964904 buf: []u8,
48974905) usize {
4906 _ = data;
4907 _ = newrr;
48984908 // This implementation is ported from musl libc.
48994909 // A more idiomatic "ziggy" implementation would be welcome.
49004910 var name = dname;
lib/std/os/bits/linux.zig+1-1
......@@ -1286,7 +1286,7 @@ pub const CAP_BLOCK_SUSPEND = 36;
12861286pub const CAP_AUDIT_READ = 37;
12871287pub const CAP_LAST_CAP = CAP_AUDIT_READ;
12881288
1289pub fn cap_valid(u8: x) bool {
1289pub fn cap_valid(x: u8) bool {
12901290 return x >= 0 and x <= CAP_LAST_CAP;
12911291}
12921292
lib/std/os/linux.zig+2-1
......@@ -70,6 +70,7 @@ fn splitValueLE64(val: i64) [2]u32 {
7070 };
7171}
7272fn splitValueBE64(val: i64) [2]u32 {
73 _ = val;
7374 return [2]u32{
7475 @truncate(u32, u >> 32),
7576 @truncate(u32, u),
......@@ -1022,7 +1023,7 @@ pub fn sendmmsg(fd: i32, msgvec: [*]mmsghdr_const, vlen: u32, flags: u32) usize
10221023 for (msgvec[0..kvlen]) |*msg, i| {
10231024 var size: i32 = 0;
10241025 const msg_iovlen = @intCast(usize, msg.msg_hdr.msg_iovlen); // kernel side this is treated as unsigned
1025 for (msg.msg_hdr.msg_iov[0..msg_iovlen]) |iov, j| {
1026 for (msg.msg_hdr.msg_iov[0..msg_iovlen]) |iov| {
10261027 if (iov.iov_len > std.math.maxInt(i32) or @addWithOverflow(i32, size, @intCast(i32, iov.iov_len), &size)) {
10271028 // batch-send all messages up to the current message
10281029 if (next_unsent < i) {
lib/std/os/linux/bpf.zig+2-2
......@@ -1513,7 +1513,7 @@ pub fn map_create(map_type: MapType, key_size: u32, value_size: u32, max_entries
15131513 EINVAL => error.MapTypeOrAttrInvalid,
15141514 ENOMEM => error.SystemResources,
15151515 EPERM => error.AccessDenied,
1516 else => |err| unexpectedErrno(rc),
1516 else => unexpectedErrno(rc),
15171517 };
15181518}
15191519
......@@ -1539,7 +1539,7 @@ pub fn map_lookup_elem(fd: fd_t, key: []const u8, value: []u8) !void {
15391539 EINVAL => return error.FieldInAttrNeedsZeroing,
15401540 ENOENT => return error.NotFound,
15411541 EPERM => return error.AccessDenied,
1542 else => |err| return unexpectedErrno(rc),
1542 else => return unexpectedErrno(rc),
15431543 }
15441544}
15451545
lib/std/os/linux/io_uring.zig+3
......@@ -284,6 +284,7 @@ pub const IO_Uring = struct {
284284 }
285285
286286 fn copy_cqes_ready(self: *IO_Uring, cqes: []io_uring_cqe, wait_nr: u32) u32 {
287 _ = wait_nr;
287288 const ready = self.cq_ready();
288289 const count = std.math.min(cqes.len, ready);
289290 var head = self.cq.head.*;
......@@ -320,6 +321,7 @@ pub const IO_Uring = struct {
320321 /// Not idempotent, calling more than once will result in other CQEs being lost.
321322 /// Matches the implementation of cqe_seen() in liburing.
322323 pub fn cqe_seen(self: *IO_Uring, cqe: *io_uring_cqe) void {
324 _ = cqe;
323325 self.cq_advance(1);
324326 }
325327
......@@ -728,6 +730,7 @@ pub const CompletionQueue = struct {
728730 }
729731
730732 pub fn deinit(self: *CompletionQueue) void {
733 _ = self;
731734 // A no-op since we now share the mmap with the submission queue.
732735 // Here for symmetry with the submission queue, and for any future feature support.
733736 }
lib/std/os/linux/mips.zig+1
......@@ -18,6 +18,7 @@ pub fn syscall0(number: SYS) usize {
1818}
1919
2020pub fn syscall_pipe(fd: *[2]i32) usize {
21 _ = fd;
2122 return asm volatile (
2223 \\ .set noat
2324 \\ .set noreorder
lib/std/os/test.zig+4
......@@ -353,6 +353,7 @@ test "spawn threads" {
353353}
354354
355355fn start1(ctx: void) u8 {
356 _ = ctx;
356357 return 0;
357358}
358359
......@@ -379,6 +380,7 @@ test "thread local storage" {
379380
380381threadlocal var x: i32 = 1234;
381382fn testTls(context: void) !void {
383 _ = context;
382384 if (x != 1234) return error.TlsBadStartValue;
383385 x += 1;
384386 if (x != 1235) return error.TlsBadEndValue;
......@@ -425,6 +427,7 @@ const IterFnError = error{
425427};
426428
427429fn iter_fn(info: *dl_phdr_info, size: usize, counter: *usize) IterFnError!void {
430 _ = size;
428431 // Count how many libraries are loaded
429432 counter.* += @as(usize, 1);
430433
......@@ -731,6 +734,7 @@ test "sigaction" {
731734
732735 const S = struct {
733736 fn handler(sig: i32, info: *const os.siginfo_t, ctx_ptr: ?*const c_void) callconv(.C) void {
737 _ = ctx_ptr;
734738 // Check that we received the correct signal.
735739 switch (native_os) {
736740 .netbsd => {
lib/std/os/uefi.zig+1
......@@ -37,6 +37,7 @@ pub const Guid = extern struct {
3737 options: std.fmt.FormatOptions,
3838 writer: anytype,
3939 ) !void {
40 _ = options;
4041 if (f.len == 0) {
4142 return std.fmt.format(writer, "{x:0>8}-{x:0>4}-{x:0>4}-{x:0>2}{x:0>2}-{x:0>12}", .{
4243 self.time_low,
lib/std/os/uefi/protocols/managed_network_protocol.zig+1
......@@ -35,6 +35,7 @@ pub const ManagedNetworkProtocol = extern struct {
3535 /// Translates an IP multicast address to a hardware (MAC) multicast address.
3636 /// This function may be unsupported in some MNP implementations.
3737 pub fn mcastIpToMac(self: *const ManagedNetworkProtocol, ipv6flag: bool, ipaddress: *const c_void, mac_address: *MacAddress) Status {
38 _ = mac_address;
3839 return self._mcast_ip_to_mac(self, ipv6flag, ipaddress);
3940 }
4041
lib/std/packed_int_array.zig+1
......@@ -194,6 +194,7 @@ pub fn PackedIntArrayEndian(comptime Int: type, comptime endian: Endian, comptim
194194
195195 ///Returns the number of elements in the packed array
196196 pub fn len(self: Self) usize {
197 _ = self;
197198 return int_count;
198199 }
199200
lib/std/pdb.zig+2-1
......@@ -675,6 +675,7 @@ pub const Pdb = struct {
675675 }
676676
677677 pub fn getSymbolName(self: *Pdb, module: *Module, address: u64) ?[]const u8 {
678 _ = self;
678679 std.debug.assert(module.populated);
679680
680681 var symbol_i: usize = 0;
......@@ -906,7 +907,7 @@ const Msf = struct {
906907 // These streams are not used, but still participate in the file
907908 // and must be taken into account when resolving stream indices.
908909 const Nil = 0xFFFFFFFF;
909 for (stream_sizes) |*s, i| {
910 for (stream_sizes) |*s| {
910911 const size = try directory.reader().readIntLittle(u32);
911912 s.* = if (size == Nil) 0 else blockCountFromSize(size, superblock.BlockSize);
912913 }
lib/std/priority_dequeue.zig+1-1
......@@ -428,7 +428,7 @@ pub fn PriorityDequeue(comptime T: type) type {
428428 warn("{}, ", .{e});
429429 }
430430 warn("array: ", .{});
431 for (self.items) |e, i| {
431 for (self.items) |e| {
432432 warn("{}, ", .{e});
433433 }
434434 warn("len: {} ", .{self.len});
lib/std/priority_queue.zig+1-1
......@@ -249,7 +249,7 @@ pub fn PriorityQueue(comptime T: type) type {
249249 warn("{}, ", .{e});
250250 }
251251 warn("array: ", .{});
252 for (self.items) |e, i| {
252 for (self.items) |e| {
253253 warn("{}, ", .{e});
254254 }
255255 warn("len: {} ", .{self.len});
lib/std/process.zig+2
......@@ -419,6 +419,7 @@ pub const ArgIteratorWindows = struct {
419419 };
420420 }
421421 fn emitBackslashes(self: *ArgIteratorWindows, buf: *std.ArrayList(u16), emit_count: usize) !void {
422 _ = self;
422423 var i: usize = 0;
423424 while (i < emit_count) : (i += 1) {
424425 try buf.append(std.mem.nativeToLittle(u16, '\\'));
......@@ -748,6 +749,7 @@ pub fn getSelfExeSharedLibPaths(allocator: *Allocator) error{OutOfMemory}![][:0]
748749 }
749750 try os.dl_iterate_phdr(&paths, error{OutOfMemory}, struct {
750751 fn callback(info: *os.dl_phdr_info, size: usize, list: *List) !void {
752 _ = size;
751753 const name = info.dlpi_name orelse return;
752754 if (name[0] == '/') {
753755 const item = try list.allocator.dupeZ(u8, mem.spanZ(name));
lib/std/sort.zig+4
......@@ -37,9 +37,11 @@ pub fn binarySearch(
3737test "binarySearch" {
3838 const S = struct {
3939 fn order_u32(context: void, lhs: u32, rhs: u32) math.Order {
40 _ = context;
4041 return math.order(lhs, rhs);
4142 }
4243 fn order_i32(context: void, lhs: i32, rhs: i32) math.Order {
44 _ = context;
4345 return math.order(lhs, rhs);
4446 }
4547 };
......@@ -1133,6 +1135,7 @@ fn swap(
11331135pub fn asc(comptime T: type) fn (void, T, T) bool {
11341136 const impl = struct {
11351137 fn inner(context: void, a: T, b: T) bool {
1138 _ = context;
11361139 return a < b;
11371140 }
11381141 };
......@@ -1144,6 +1147,7 @@ pub fn asc(comptime T: type) fn (void, T, T) bool {
11441147pub fn desc(comptime T: type) fn (void, T, T) bool {
11451148 const impl = struct {
11461149 fn inner(context: void, a: T, b: T) bool {
1150 _ = context;
11471151 return a > b;
11481152 }
11491153 };
lib/std/special/c.zig+2
......@@ -160,6 +160,7 @@ fn strncmp(_l: [*:0]const u8, _r: [*:0]const u8, _n: usize) callconv(.C) c_int {
160160}
161161
162162fn strerror(errnum: c_int) callconv(.C) [*:0]const u8 {
163 _ = errnum;
163164 return "TODO strerror implementation";
164165}
165166
......@@ -173,6 +174,7 @@ test "strncmp" {
173174// Avoid dragging in the runtime safety mechanisms into this .o file,
174175// unless we're trying to test this file.
175176pub fn panic(msg: []const u8, error_return_trace: ?*builtin.StackTrace) noreturn {
177 _ = error_return_trace;
176178 if (builtin.is_test) {
177179 @setCold(true);
178180 std.debug.panic("{s}", .{msg});
lib/std/special/compiler_rt.zig+1
......@@ -602,6 +602,7 @@ pub usingnamespace @import("compiler_rt/atomics.zig");
602602// Avoid dragging in the runtime safety mechanisms into this .o file,
603603// unless we're trying to test this file.
604604pub fn panic(msg: []const u8, error_return_trace: ?*builtin.StackTrace) noreturn {
605 _ = error_return_trace;
605606 @setCold(true);
606607 if (is_test) {
607608 std.debug.panic("{s}", .{msg});
lib/std/special/compiler_rt/atomics.zig+11
......@@ -80,18 +80,21 @@ var spinlocks: SpinlockTable = SpinlockTable{};
8080// Those work on any object no matter the pointer alignment nor its size.
8181
8282fn __atomic_load(size: u32, src: [*]u8, dest: [*]u8, model: i32) callconv(.C) void {
83 _ = model;
8384 var sl = spinlocks.get(@ptrToInt(src));
8485 defer sl.release();
8586 @memcpy(dest, src, size);
8687}
8788
8889fn __atomic_store(size: u32, dest: [*]u8, src: [*]u8, model: i32) callconv(.C) void {
90 _ = model;
8991 var sl = spinlocks.get(@ptrToInt(dest));
9092 defer sl.release();
9193 @memcpy(dest, src, size);
9294}
9395
9496fn __atomic_exchange(size: u32, ptr: [*]u8, val: [*]u8, old: [*]u8, model: i32) callconv(.C) void {
97 _ = model;
9598 var sl = spinlocks.get(@ptrToInt(ptr));
9699 defer sl.release();
97100 @memcpy(old, ptr, size);
......@@ -106,6 +109,8 @@ fn __atomic_compare_exchange(
106109 success: i32,
107110 failure: i32,
108111) callconv(.C) i32 {
112 _ = success;
113 _ = failure;
109114 var sl = spinlocks.get(@ptrToInt(ptr));
110115 defer sl.release();
111116 for (ptr[0..size]) |b, i| {
......@@ -135,6 +140,7 @@ comptime {
135140fn atomicLoadFn(comptime T: type) fn (*T, i32) callconv(.C) T {
136141 return struct {
137142 fn atomic_load_N(src: *T, model: i32) callconv(.C) T {
143 _ = model;
138144 if (@sizeOf(T) > largest_atomic_size) {
139145 var sl = spinlocks.get(@ptrToInt(src));
140146 defer sl.release();
......@@ -162,6 +168,7 @@ comptime {
162168fn atomicStoreFn(comptime T: type) fn (*T, T, i32) callconv(.C) void {
163169 return struct {
164170 fn atomic_store_N(dst: *T, value: T, model: i32) callconv(.C) void {
171 _ = model;
165172 if (@sizeOf(T) > largest_atomic_size) {
166173 var sl = spinlocks.get(@ptrToInt(dst));
167174 defer sl.release();
......@@ -189,6 +196,7 @@ comptime {
189196fn atomicExchangeFn(comptime T: type) fn (*T, T, i32) callconv(.C) T {
190197 return struct {
191198 fn atomic_exchange_N(ptr: *T, val: T, model: i32) callconv(.C) T {
199 _ = model;
192200 if (@sizeOf(T) > largest_atomic_size) {
193201 var sl = spinlocks.get(@ptrToInt(ptr));
194202 defer sl.release();
......@@ -218,6 +226,8 @@ comptime {
218226fn atomicCompareExchangeFn(comptime T: type) fn (*T, *T, T, i32, i32) callconv(.C) i32 {
219227 return struct {
220228 fn atomic_compare_exchange_N(ptr: *T, expected: *T, desired: T, success: i32, failure: i32) callconv(.C) i32 {
229 _ = success;
230 _ = failure;
221231 if (@sizeOf(T) > largest_atomic_size) {
222232 var sl = spinlocks.get(@ptrToInt(ptr));
223233 defer sl.release();
......@@ -255,6 +265,7 @@ comptime {
255265fn fetchFn(comptime T: type, comptime op: builtin.AtomicRmwOp) fn (*T, T, i32) callconv(.C) T {
256266 return struct {
257267 pub fn fetch_op_N(ptr: *T, val: T, model: i32) callconv(.C) T {
268 _ = model;
258269 if (@sizeOf(T) > largest_atomic_size) {
259270 var sl = spinlocks.get(@ptrToInt(ptr));
260271 defer sl.release();
lib/std/special/compiler_rt/comparedf2_test.zig+1
......@@ -101,6 +101,7 @@ const test_vectors = init: {
101101
102102test "compare f64" {
103103 for (test_vectors) |vector, i| {
104 _ = i;
104105 try std.testing.expect(test__cmpdf2(vector));
105106 }
106107}
lib/std/special/compiler_rt/comparesf2_test.zig+1
......@@ -101,6 +101,7 @@ const test_vectors = init: {
101101
102102test "compare f32" {
103103 for (test_vectors) |vector, i| {
104 _ = i;
104105 try std.testing.expect(test__cmpsf2(vector));
105106 }
106107}
lib/std/special/ssp.zig+2
......@@ -27,6 +27,8 @@ extern fn memmove(dest: ?[*]u8, src: ?[*]const u8, n: usize) callconv(.C) ?[*]u8
2727
2828// Avoid dragging in the runtime safety mechanisms into this .o file.
2929pub fn panic(msg: []const u8, error_return_trace: ?*builtin.StackTrace) noreturn {
30 _ = msg;
31 _ = error_return_trace;
3032 @setCold(true);
3133 if (@hasDecl(std.os, "abort"))
3234 std.os.abort();
lib/std/target.zig+1-1
......@@ -157,7 +157,7 @@ pub const Target = struct {
157157 pub fn format(
158158 self: WindowsVersion,
159159 comptime fmt: []const u8,
160 options: std.fmt.FormatOptions,
160 _: std.fmt.FormatOptions,
161161 out_stream: anytype,
162162 ) !void {
163163 if (fmt.len > 0 and fmt[0] == 's') {
lib/std/unicode.zig+1-1
......@@ -210,7 +210,7 @@ pub fn utf8ValidateSlice(s: []const u8) bool {
210210 return false;
211211 }
212212 i += cp_len;
213 } else |err| {
213 } else |_| {
214214 return false;
215215 }
216216 }
lib/std/x/net/ip.zig+2
......@@ -53,6 +53,8 @@ pub const Address = union(enum) {
5353 opts: fmt.FormatOptions,
5454 writer: anytype,
5555 ) !void {
56 _ = opts;
57 _ = layout;
5658 switch (self) {
5759 .ipv4 => |address| try fmt.format(writer, "{}:{}", .{ address.host, address.port }),
5860 .ipv6 => |address| try fmt.format(writer, "{}:{}", .{ address.host, address.port }),
lib/std/x/os/net.zig+2
......@@ -143,6 +143,7 @@ pub const IPv4 = extern struct {
143143 opts: fmt.FormatOptions,
144144 writer: anytype,
145145 ) !void {
146 _ = opts;
146147 if (comptime layout.len != 0 and layout[0] != 's') {
147148 @compileError("Unsupported format specifier for IPv4 type '" ++ layout ++ "'.");
148149 }
......@@ -352,6 +353,7 @@ pub const IPv6 = extern struct {
352353 opts: fmt.FormatOptions,
353354 writer: anytype,
354355 ) !void {
356 _ = opts;
355357 const specifier = comptime &[_]u8{if (layout.len == 0) 'x' else switch (layout[0]) {
356358 'x', 'X' => |specifier| specifier,
357359 's' => 'x',
lib/std/x/os/socket.zig+4-2
......@@ -117,7 +117,7 @@ pub const Socket = struct {
117117 };
118118 }
119119
120 /// Returns the number of bytes that make up the `sockaddr` equivalent to the address.
120 /// Returns the number of bytes that make up the `sockaddr` equivalent to the address.
121121 pub fn getNativeSize(self: Socket.Address) u32 {
122122 return switch (self) {
123123 .ipv4 => @sizeOf(os.sockaddr_in),
......@@ -132,6 +132,8 @@ pub const Socket = struct {
132132 opts: fmt.FormatOptions,
133133 writer: anytype,
134134 ) !void {
135 _ = opts;
136 _ = layout;
135137 switch (self) {
136138 .ipv4 => |address| try fmt.format(writer, "{}:{}", .{ address.host, address.port }),
137139 .ipv6 => |address| try fmt.format(writer, "{}:{}", .{ address.host, address.port }),
......@@ -280,7 +282,7 @@ pub const Socket = struct {
280282 ///
281283 /// Microsoft's documentation and glibc denote the fields to be unsigned
282284 /// short's on Windows, whereas glibc and musl denote the fields to be
283 /// int's on every other platform.
285 /// int's on every other platform.
284286 pub const Linger = extern struct {
285287 pub const Field = switch (native_os.tag) {
286288 .windows => c_ushort,
lib/std/x/os/socket_windows.zig+7-3
......@@ -292,6 +292,7 @@ pub fn Mixin(comptime Socket: type) type {
292292 /// with a set of flags specified. It returns the number of bytes that were
293293 /// read into the buffer provided.
294294 pub fn readMessage(self: Socket, msg: *Socket.Message, flags: u32) !usize {
295 _ = flags;
295296 const call = try windows.loadWinsockExtensionFunction(ws2_32.LPFN_WSARECVMSG, self.fd, ws2_32.WSAID_WSARECVMSG);
296297
297298 var num_bytes: u32 = undefined;
......@@ -367,16 +368,19 @@ pub fn Mixin(comptime Socket: type) type {
367368
368369 /// Query and return the latest cached error on the socket.
369370 pub fn getError(self: Socket) !void {
371 _ = self;
370372 return {};
371373 }
372374
373375 /// Query the read buffer size of the socket.
374376 pub fn getReadBufferSize(self: Socket) !u32 {
377 _ = self;
375378 return 0;
376379 }
377380
378381 /// Query the write buffer size of the socket.
379382 pub fn getWriteBufferSize(self: Socket) !u32 {
383 _ = self;
380384 return 0;
381385 }
382386
......@@ -406,7 +410,7 @@ pub fn Mixin(comptime Socket: type) type {
406410
407411 /// On connection-oriented sockets, have keep-alive messages be sent periodically. The timing in which keep-alive
408412 /// messages are sent are dependant on operating system settings. It returns `error.UnsupportedSocketOption` if
409 /// the host does not support periodically sending keep-alive messages on connection-oriented sockets.
413 /// the host does not support periodically sending keep-alive messages on connection-oriented sockets.
410414 pub fn setKeepAlive(self: Socket, enabled: bool) !void {
411415 return self.setOption(ws2_32.SOL_SOCKET, ws2_32.SO_KEEPALIVE, mem.asBytes(&@as(u32, @boolToInt(enabled))));
412416 }
......@@ -438,7 +442,7 @@ pub fn Mixin(comptime Socket: type) type {
438442
439443 /// WARNING: Timeouts only affect blocking sockets. It is undefined behavior if a timeout is
440444 /// set on a non-blocking socket.
441 ///
445 ///
442446 /// Set a timeout on the socket that is to occur if no messages are successfully written
443447 /// to its bound destination after a specified number of milliseconds. A subsequent write
444448 /// to the socket will thereafter return `error.WouldBlock` should the timeout be exceeded.
......@@ -448,7 +452,7 @@ pub fn Mixin(comptime Socket: type) type {
448452
449453 /// WARNING: Timeouts only affect blocking sockets. It is undefined behavior if a timeout is
450454 /// set on a non-blocking socket.
451 ///
455 ///
452456 /// Set a timeout on the socket that is to occur if no messages are successfully read
453457 /// from its bound destination after a specified number of milliseconds. A subsequent
454458 /// read from the socket will thereafter return `error.WouldBlock` should the timeout be
lib/std/zig/ast.zig+1
......@@ -1866,6 +1866,7 @@ pub const Tree = struct {
18661866 }
18671867
18681868 fn fullStructInit(tree: Tree, info: full.StructInit.Ast) full.StructInit {
1869 _ = tree;
18691870 var result: full.StructInit = .{
18701871 .ast = info,
18711872 };
lib/std/zig/c_builtins.zig+2
......@@ -136,6 +136,7 @@ pub inline fn __builtin_strcmp(s1: [*c]const u8, s2: [*c]const u8) c_int {
136136}
137137
138138pub inline fn __builtin_object_size(ptr: ?*const c_void, ty: c_int) usize {
139 _ = ptr;
139140 // clang semantics match gcc's: https://gcc.gnu.org/onlinedocs/gcc/Object-Size-Checking.html
140141 // If it is not possible to determine which objects ptr points to at compile time,
141142 // __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(
186187/// The return value of __builtin_expect is `expr`. `c` is the expected value
187188/// of `expr` and is used as a hint to the compiler in C. Here it is unused.
188189pub inline fn __builtin_expect(expr: c_long, c: c_long) c_long {
190 _ = c;
189191 return expr;
190192}
191193
lib/std/zig/fmt.zig+2
......@@ -8,6 +8,7 @@ pub fn formatId(
88 options: std.fmt.FormatOptions,
99 writer: anytype,
1010) !void {
11 _ = fmt;
1112 if (isValidId(bytes)) {
1213 return writer.writeAll(bytes);
1314 }
......@@ -41,6 +42,7 @@ pub fn formatEscapes(
4142 options: std.fmt.FormatOptions,
4243 writer: anytype,
4344) !void {
45 _ = options;
4446 for (bytes) |byte| switch (byte) {
4547 '\n' => try writer.writeAll("\\n"),
4648 '\r' => try writer.writeAll("\\r"),
lib/std/zig/parse.zig+1-1
......@@ -2104,7 +2104,7 @@ const Parser = struct {
21042104 /// FnCallArguments <- LPAREN ExprList RPAREN
21052105 /// ExprList <- (Expr COMMA)* Expr?
21062106 fn parseSuffixExpr(p: *Parser) !Node.Index {
2107 if (p.eatToken(.keyword_async)) |async_token| {
2107 if (p.eatToken(.keyword_async)) |_| {
21082108 var res = try p.expectPrimaryTypeExpr();
21092109 while (true) {
21102110 const node = try p.parseSuffixOp(res);
lib/std/zig/system.zig+2-1
......@@ -200,6 +200,7 @@ pub const NativePaths = struct {
200200 }
201201
202202 fn appendArray(self: *NativePaths, array: *ArrayList([:0]u8), s: []const u8) !void {
203 _ = self;
203204 const item = try array.allocator.dupeZ(u8, s);
204205 errdefer array.allocator.free(item);
205206 try array.append(item);
......@@ -332,7 +333,7 @@ pub const NativeTargetInfo = struct {
332333 if (std.builtin.Version.parse(buf[0 .. len - 1])) |ver| {
333334 os.version_range.semver.min = ver;
334335 os.version_range.semver.max = ver;
335 } else |err| {
336 } else |_| {
336337 return error.OSVersionDetectionFail;
337338 }
338339 },
lib/std/zig/system/macos.zig+2-2
......@@ -68,10 +68,10 @@ pub fn detect(target_os: *Target.Os) !void {
6868 return;
6969 }
7070 continue;
71 } else |err| {
71 } else |_| {
7272 return error.OSVersionDetectionFail;
7373 }
74 } else |err| {
74 } else |_| {
7575 return error.OSVersionDetectionFail;
7676 }
7777 }
lib/std/zig/system/x86.zig+1
......@@ -28,6 +28,7 @@ inline fn hasMask(input: u32, mask: u32) bool {
2828}
2929
3030pub fn detectNativeCpuAndFeatures(arch: Target.Cpu.Arch, os: Target.Os, cross_target: CrossTarget) Target.Cpu {
31 _ = cross_target;
3132 var cpu = Target.Cpu{
3233 .arch = arch,
3334 .model = Target.Cpu.Model.generic(arch),
src/AstGen.zig+22-4
......@@ -925,6 +925,7 @@ fn suspendExpr(
925925 rl: ResultLoc,
926926 node: ast.Node.Index,
927927) InnerError!Zir.Inst.Ref {
928 _ = rl;
928929 const astgen = gz.astgen;
929930 const gpa = astgen.gpa;
930931 const tree = astgen.tree;
......@@ -1208,6 +1209,7 @@ fn arrayInitExprRlNone(
12081209 elements: []const ast.Node.Index,
12091210 tag: Zir.Inst.Tag,
12101211) InnerError!Zir.Inst.Ref {
1212 _ = rl;
12111213 const astgen = gz.astgen;
12121214 const gpa = astgen.gpa;
12131215 const elem_list = try gpa.alloc(Zir.Inst.Ref, elements.len);
......@@ -1233,6 +1235,9 @@ fn arrayInitExprRlTy(
12331235 elem_ty_inst: Zir.Inst.Ref,
12341236 tag: Zir.Inst.Tag,
12351237) InnerError!Zir.Inst.Ref {
1238 _ = rl;
1239 _ = array_ty_inst;
1240 _ = elem_ty_inst;
12361241 const astgen = gz.astgen;
12371242 const gpa = astgen.gpa;
12381243
......@@ -1259,6 +1264,7 @@ fn arrayInitExprRlPtr(
12591264 elements: []const ast.Node.Index,
12601265 result_ptr: Zir.Inst.Ref,
12611266) InnerError!Zir.Inst.Ref {
1267 _ = rl;
12621268 const astgen = gz.astgen;
12631269 const gpa = astgen.gpa;
12641270
......@@ -1368,6 +1374,7 @@ fn structInitExprRlNone(
13681374 struct_init: ast.full.StructInit,
13691375 tag: Zir.Inst.Tag,
13701376) InnerError!Zir.Inst.Ref {
1377 _ = rl;
13711378 const astgen = gz.astgen;
13721379 const gpa = astgen.gpa;
13731380 const tree = astgen.tree;
......@@ -1403,6 +1410,7 @@ fn structInitExprRlPtr(
14031410 struct_init: ast.full.StructInit,
14041411 result_ptr: Zir.Inst.Ref,
14051412) InnerError!Zir.Inst.Ref {
1413 _ = rl;
14061414 const astgen = gz.astgen;
14071415 const gpa = astgen.gpa;
14081416 const tree = astgen.tree;
......@@ -1439,6 +1447,7 @@ fn structInitExprRlTy(
14391447 ty_inst: Zir.Inst.Ref,
14401448 tag: Zir.Inst.Tag,
14411449) InnerError!Zir.Inst.Ref {
1450 _ = rl;
14421451 const astgen = gz.astgen;
14431452 const gpa = astgen.gpa;
14441453 const tree = astgen.tree;
......@@ -1781,6 +1790,7 @@ fn blockExprStmts(
17811790 node: ast.Node.Index,
17821791 statements: []const ast.Node.Index,
17831792) !void {
1793 _ = node;
17841794 const astgen = gz.astgen;
17851795 const tree = astgen.tree;
17861796 const node_tags = tree.nodes.items(.tag);
......@@ -2117,6 +2127,7 @@ fn genDefers(
21172127 inner_scope: *Scope,
21182128 err_code: Zir.Inst.Ref,
21192129) InnerError!void {
2130 _ = err_code;
21202131 const astgen = gz.astgen;
21212132 const tree = astgen.tree;
21222133 const node_datas = tree.nodes.items(.data);
......@@ -2201,6 +2212,7 @@ fn deferStmt(
22012212 block_arena: *Allocator,
22022213 scope_tag: Scope.Tag,
22032214) InnerError!*Scope {
2215 _ = gz;
22042216 const defer_scope = try block_arena.create(Scope.Defer);
22052217 defer_scope.* = .{
22062218 .base = .{ .tag = scope_tag },
......@@ -4703,6 +4715,8 @@ fn finishThenElseBlock(
47034715 then_break_block: Zir.Inst.Index,
47044716 break_tag: Zir.Inst.Tag,
47054717) InnerError!Zir.Inst.Ref {
4718 _ = then_src;
4719 _ = else_src;
47064720 // We now have enough information to decide whether the result instruction should
47074721 // be communicated via result location pointer or break instructions.
47084722 const strat = rl.strategy(block_scope);
......@@ -4886,7 +4900,7 @@ fn ifExpr(
48864900 inst: Zir.Inst.Ref,
48874901 bool_bit: Zir.Inst.Ref,
48884902 } = c: {
4889 if (if_full.error_token) |error_token| {
4903 if (if_full.error_token) |_| {
48904904 const cond_rl: ResultLoc = if (payload_is_ref) .ref else .none;
48914905 const err_union = try expr(&block_scope, &block_scope.base, cond_rl, if_full.ast.cond_expr);
48924906 const tag: Zir.Inst.Tag = if (payload_is_ref) .is_err_ptr else .is_err;
......@@ -4894,7 +4908,7 @@ fn ifExpr(
48944908 .inst = err_union,
48954909 .bool_bit = try block_scope.addUnNode(tag, err_union, node),
48964910 };
4897 } else if (if_full.payload_token) |payload_token| {
4911 } else if (if_full.payload_token) |_| {
48984912 const cond_rl: ResultLoc = if (payload_is_ref) .ref else .none;
48994913 const optional = try expr(&block_scope, &block_scope.base, cond_rl, if_full.ast.cond_expr);
49004914 const tag: Zir.Inst.Tag = if (payload_is_ref) .is_non_null_ptr else .is_non_null;
......@@ -5146,7 +5160,7 @@ fn whileExpr(
51465160 inst: Zir.Inst.Ref,
51475161 bool_bit: Zir.Inst.Ref,
51485162 } = c: {
5149 if (while_full.error_token) |error_token| {
5163 if (while_full.error_token) |_| {
51505164 const cond_rl: ResultLoc = if (payload_is_ref) .ref else .none;
51515165 const err_union = try expr(&continue_scope, &continue_scope.base, cond_rl, while_full.ast.cond_expr);
51525166 const tag: Zir.Inst.Tag = if (payload_is_ref) .is_err_ptr else .is_err;
......@@ -5154,7 +5168,7 @@ fn whileExpr(
51545168 .inst = err_union,
51555169 .bool_bit = try continue_scope.addUnNode(tag, err_union, node),
51565170 };
5157 } else if (while_full.payload_token) |payload_token| {
5171 } else if (while_full.payload_token) |_| {
51585172 const cond_rl: ResultLoc = if (payload_is_ref) .ref else .none;
51595173 const optional = try expr(&continue_scope, &continue_scope.base, cond_rl, while_full.ast.cond_expr);
51605174 const tag: Zir.Inst.Tag = if (payload_is_ref) .is_non_null_ptr else .is_non_null;
......@@ -6665,6 +6679,7 @@ fn unionInitRlPtr(
66656679 union_type: Zir.Inst.Ref,
66666680 field_name: Zir.Inst.Ref,
66676681) InnerError!Zir.Inst.Ref {
6682 _ = rl;
66686683 const union_init_ptr = try parent_gz.addPlNode(.union_init_ptr, node, Zir.Inst.UnionInitPtr{
66696684 .result_ptr = result_ptr,
66706685 .union_type = union_type,
......@@ -6753,6 +6768,8 @@ fn bitCastRlPtr(
67536768 result_ptr: Zir.Inst.Ref,
67546769 rhs: ast.Node.Index,
67556770) InnerError!Zir.Inst.Ref {
6771 _ = rl;
6772 _ = scope;
67566773 const casted_result_ptr = try gz.addPlNode(.bitcast_result_ptr, node, Zir.Inst.Bin{
67576774 .lhs = dest_type,
67586775 .rhs = result_ptr,
......@@ -8013,6 +8030,7 @@ fn rvalue(
80138030 result: Zir.Inst.Ref,
80148031 src_node: ast.Node.Index,
80158032) InnerError!Zir.Inst.Ref {
8033 _ = scope;
80168034 switch (rl) {
80178035 .none, .none_or_ref => return result,
80188036 .discard => {
src/Compilation.zig+1
......@@ -523,6 +523,7 @@ pub const AllErrors = struct {
523523 errors: *std.ArrayList(Message),
524524 msg: []const u8,
525525 ) !void {
526 _ = arena;
526527 try errors.append(.{ .plain = .{ .msg = msg } });
527528 }
528529
src/Module.zig+17-2
......@@ -774,7 +774,10 @@ pub const Fn = struct {
774774 ir.dumpFn(mod, func);
775775 }
776776
777 pub fn deinit(func: *Fn, gpa: *Allocator) void {}
777 pub fn deinit(func: *Fn, gpa: *Allocator) void {
778 _ = func;
779 _ = gpa;
780 }
778781};
779782
780783pub const Var = struct {
......@@ -2209,6 +2212,7 @@ comptime {
22092212}
22102213
22112214pub fn astGenFile(mod: *Module, file: *Scope.File, prog_node: *std.Progress.Node) !void {
2215 _ = prog_node;
22122216 const tracy = trace(@src());
22132217 defer tracy.end();
22142218
......@@ -3128,6 +3132,7 @@ pub const ImportFileResult = struct {
31283132};
31293133
31303134pub fn importPkg(mod: *Module, cur_pkg: *Package, pkg: *Package) !ImportFileResult {
3135 _ = cur_pkg;
31313136 const gpa = mod.gpa;
31323137
31333138 // 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
33843389 decl.has_align = has_align;
33853390 decl.has_linksection = has_linksection;
33863391 decl.zir_decl_index = @intCast(u32, decl_sub_index);
3387 if (decl.getFunction()) |func| {
3392 if (decl.getFunction()) |_| {
33883393 switch (mod.comp.bin_file.tag) {
33893394 .coff => {
33903395 // TODO Implement for COFF
......@@ -3753,6 +3758,7 @@ pub fn analyzeExport(
37533758 errdefer de_gop.value_ptr.* = mod.gpa.shrink(de_gop.value_ptr.*, de_gop.value_ptr.len - 1);
37543759}
37553760pub fn constInst(mod: *Module, arena: *Allocator, src: LazySrcLoc, typed_value: TypedValue) !*ir.Inst {
3761 _ = mod;
37563762 const const_inst = try arena.create(ir.Inst.Constant);
37573763 const_inst.* = .{
37583764 .base = .{
......@@ -4121,6 +4127,7 @@ pub fn floatAdd(
41214127 lhs: Value,
41224128 rhs: Value,
41234129) !Value {
4130 _ = src;
41244131 switch (float_type.tag()) {
41254132 .f16 => {
41264133 @panic("TODO add __trunctfhf2 to compiler-rt");
......@@ -4154,6 +4161,7 @@ pub fn floatSub(
41544161 lhs: Value,
41554162 rhs: Value,
41564163) !Value {
4164 _ = src;
41574165 switch (float_type.tag()) {
41584166 .f16 => {
41594167 @panic("TODO add __trunctfhf2 to compiler-rt");
......@@ -4187,6 +4195,7 @@ pub fn floatDiv(
41874195 lhs: Value,
41884196 rhs: Value,
41894197) !Value {
4198 _ = src;
41904199 switch (float_type.tag()) {
41914200 .f16 => {
41924201 @panic("TODO add __trunctfhf2 to compiler-rt");
......@@ -4220,6 +4229,7 @@ pub fn floatMul(
42204229 lhs: Value,
42214230 rhs: Value,
42224231) !Value {
4232 _ = src;
42234233 switch (float_type.tag()) {
42244234 .f16 => {
42254235 @panic("TODO add __trunctfhf2 to compiler-rt");
......@@ -4253,6 +4263,7 @@ pub fn simplePtrType(
42534263 mutable: bool,
42544264 size: std.builtin.TypeInfo.Pointer.Size,
42554265) Allocator.Error!Type {
4266 _ = mod;
42564267 if (!mutable and size == .Slice and elem_ty.eql(Type.initTag(.u8))) {
42574268 return Type.initTag(.const_slice_u8);
42584269 }
......@@ -4287,6 +4298,7 @@ pub fn ptrType(
42874298 @"volatile": bool,
42884299 size: std.builtin.TypeInfo.Pointer.Size,
42894300) Allocator.Error!Type {
4301 _ = mod;
42904302 assert(host_size == 0 or bit_offset < host_size * 8);
42914303
42924304 // TODO check if type can be represented by simplePtrType
......@@ -4304,6 +4316,7 @@ pub fn ptrType(
43044316}
43054317
43064318pub fn optionalType(mod: *Module, arena: *Allocator, child_type: Type) Allocator.Error!Type {
4319 _ = mod;
43074320 switch (child_type.tag()) {
43084321 .single_const_pointer => return Type.Tag.optional_single_const_pointer.create(
43094322 arena,
......@@ -4324,6 +4337,7 @@ pub fn arrayType(
43244337 sentinel: ?Value,
43254338 elem_type: Type,
43264339) Allocator.Error!Type {
4340 _ = mod;
43274341 if (elem_type.eql(Type.initTag(.u8))) {
43284342 if (sentinel) |some| {
43294343 if (some.eql(Value.initTag(.zero))) {
......@@ -4354,6 +4368,7 @@ pub fn errorUnionType(
43544368 error_set: Type,
43554369 payload: Type,
43564370) Allocator.Error!Type {
4371 _ = mod;
43574372 assert(error_set.zigTypeTag() == .ErrorSet);
43584373 if (error_set.eql(Type.initTag(.anyerror)) and payload.eql(Type.initTag(.void))) {
43594374 return Type.initTag(.anyerror_void_error_union);
src/Sema.zig+34
......@@ -702,6 +702,7 @@ fn zirBitcastResultPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) I
702702}
703703
704704fn zirCoerceResultPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst {
705 _ = inst;
705706 const tracy = trace(@src());
706707 defer tracy.end();
707708 return sema.mod.fail(&block.base, sema.src, "TODO implement zirCoerceResultPtr", .{});
......@@ -776,6 +777,7 @@ fn zirStructDecl(
776777}
777778
778779fn createTypeName(sema: *Sema, block: *Scope.Block, name_strategy: Zir.Inst.NameStrategy) ![:0]u8 {
780 _ = block;
779781 switch (name_strategy) {
780782 .anon => {
781783 // It would be neat to have "struct:line:column" but this name has
......@@ -1067,6 +1069,7 @@ fn zirOpaqueDecl(
10671069 inst: Zir.Inst.Index,
10681070 name_strategy: Zir.Inst.NameStrategy,
10691071) InnerError!*Inst {
1072 _ = name_strategy;
10701073 const tracy = trace(@src());
10711074 defer tracy.end();
10721075
......@@ -1242,6 +1245,7 @@ fn zirArg(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*In
12421245 // TODO check if arg_name shadows a Decl
12431246
12441247 if (block.inlining) |inlining| {
1248 _ = inlining;
12451249 return sema.param_inst_list[arg_index];
12461250 }
12471251
......@@ -1640,6 +1644,7 @@ fn zirStr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*In
16401644}
16411645
16421646fn zirInt(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst {
1647 _ = block;
16431648 const tracy = trace(@src());
16441649 defer tracy.end();
16451650
......@@ -1648,6 +1653,7 @@ fn zirInt(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*In
16481653}
16491654
16501655fn zirIntBig(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst {
1656 _ = block;
16511657 const tracy = trace(@src());
16521658 defer tracy.end();
16531659
......@@ -1665,6 +1671,7 @@ fn zirIntBig(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!
16651671}
16661672
16671673fn zirFloat(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst {
1674 _ = block;
16681675 const arena = sema.arena;
16691676 const inst_data = sema.code.instructions.items(.data)[inst].float;
16701677 const src = inst_data.src();
......@@ -1677,6 +1684,7 @@ fn zirFloat(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*
16771684}
16781685
16791686fn zirFloat128(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst {
1687 _ = block;
16801688 const arena = sema.arena;
16811689 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
16821690 const extra = sema.code.extraData(Zir.Inst.Float128, inst_data.payload_index).data;
......@@ -2358,6 +2366,7 @@ fn analyzeCall(
23582366}
23592367
23602368fn zirIntType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst {
2369 _ = block;
23612370 const tracy = trace(@src());
23622371 defer tracy.end();
23632372
......@@ -2466,6 +2475,7 @@ fn zirErrorUnionType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Inn
24662475}
24672476
24682477fn zirErrorValue(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst {
2478 _ = block;
24692479 const tracy = trace(@src());
24702480 defer tracy.end();
24712481
......@@ -2626,6 +2636,7 @@ fn zirMergeErrorSets(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Inn
26262636}
26272637
26282638fn zirEnumLiteral(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst {
2639 _ = block;
26292640 const tracy = trace(@src());
26302641 defer tracy.end();
26312642
......@@ -3056,6 +3067,7 @@ fn funcCommon(
30563067 src_locs: Zir.Inst.Func.SrcLocs,
30573068 opt_lib_name: ?[]const u8,
30583069) InnerError!*Inst {
3070 _ = inferred_error_set;
30593071 const src: LazySrcLoc = .{ .node_offset = src_node_offset };
30603072 const ret_ty_src: LazySrcLoc = .{ .node_offset_fn_type_ret_ty = src_node_offset };
30613073 const return_type = try sema.resolveType(block, ret_ty_src, zir_return_type);
......@@ -3492,6 +3504,8 @@ fn zirSwitchCapture(
34923504 is_multi: bool,
34933505 is_ref: bool,
34943506) InnerError!*Inst {
3507 _ = is_ref;
3508 _ = is_multi;
34953509 const tracy = trace(@src());
34963510 defer tracy.end();
34973511
......@@ -3509,6 +3523,7 @@ fn zirSwitchCaptureElse(
35093523 inst: Zir.Inst.Index,
35103524 is_ref: bool,
35113525) InnerError!*Inst {
3526 _ = is_ref;
35123527 const tracy = trace(@src());
35133528 defer tracy.end();
35143529
......@@ -4511,12 +4526,15 @@ fn zirImport(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!
45114526}
45124527
45134528fn zirShl(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst {
4529 _ = block;
4530 _ = inst;
45144531 const tracy = trace(@src());
45154532 defer tracy.end();
45164533 return sema.mod.fail(&block.base, sema.src, "TODO implement zirShl", .{});
45174534}
45184535
45194536fn zirShr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst {
4537 _ = inst;
45204538 const tracy = trace(@src());
45214539 defer tracy.end();
45224540 return sema.mod.fail(&block.base, sema.src, "TODO implement zirShr", .{});
......@@ -4586,18 +4604,21 @@ fn zirBitwise(
45864604}
45874605
45884606fn zirBitNot(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst {
4607 _ = inst;
45894608 const tracy = trace(@src());
45904609 defer tracy.end();
45914610 return sema.mod.fail(&block.base, sema.src, "TODO implement zirBitNot", .{});
45924611}
45934612
45944613fn zirArrayCat(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst {
4614 _ = inst;
45954615 const tracy = trace(@src());
45964616 defer tracy.end();
45974617 return sema.mod.fail(&block.base, sema.src, "TODO implement zirArrayCat", .{});
45984618}
45994619
46004620fn zirArrayMul(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst {
4621 _ = inst;
46014622 const tracy = trace(@src());
46024623 defer tracy.end();
46034624 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
50595080}
50605081
50615082fn zirTypeof(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst {
5083 _ = block;
50625084 const zir_datas = sema.code.instructions.items(.data);
50635085 const inst_data = zir_datas[inst].un_node;
50645086 const src = inst_data.src();
......@@ -5067,6 +5089,7 @@ fn zirTypeof(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!
50675089}
50685090
50695091fn zirTypeofElem(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst {
5092 _ = block;
50705093 const inst_data = sema.code.instructions.items(.data)[inst].un_node;
50715094 const src = inst_data.src();
50725095 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
55045527}
55055528
55065529fn zirStructInit(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index, is_ref: bool) InnerError!*Inst {
5530 _ = is_ref;
55075531 const mod = sema.mod;
55085532 const gpa = sema.gpa;
55095533 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:
56135637}
56145638
56155639fn zirStructInitAnon(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index, is_ref: bool) InnerError!*Inst {
5640 _ = is_ref;
56165641 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
56175642 const src = inst_data.src();
56185643 return sema.mod.fail(&block.base, src, "TODO: Sema.zirStructInitAnon", .{});
56195644}
56205645
56215646fn zirArrayInit(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index, is_ref: bool) InnerError!*Inst {
5647 _ = is_ref;
56225648 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
56235649 const src = inst_data.src();
56245650 return sema.mod.fail(&block.base, src, "TODO: Sema.zirArrayInit", .{});
56255651}
56265652
56275653fn zirArrayInitAnon(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index, is_ref: bool) InnerError!*Inst {
5654 _ = is_ref;
56285655 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
56295656 const src = inst_data.src();
56305657 return sema.mod.fail(&block.base, src, "TODO: Sema.zirArrayInitAnon", .{});
......@@ -6021,6 +6048,7 @@ fn zirAwait(
60216048 inst: Zir.Inst.Index,
60226049 is_nosuspend: bool,
60236050) InnerError!*Inst {
6051 _ = is_nosuspend;
60246052 const inst_data = sema.code.instructions.items(.data)[inst].un_node;
60256053 const src = inst_data.src();
60266054 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:
63026330}
63036331
63046332fn safetyPanic(sema: *Sema, block: *Scope.Block, src: LazySrcLoc, panic_id: PanicId) !Zir.Inst.Index {
6333 _ = sema;
6334 _ = panic_id;
63056335 // TODO Once we have a panic function to call, call it here instead of breakpoint.
63066336 _ = try block.addNoOp(src, Type.initTag(.void), .breakpoint);
63076337 _ = try block.addNoOp(src, Type.initTag(.noreturn), .unreach);
......@@ -6600,6 +6630,8 @@ fn elemPtrArray(
66006630 elem_index: *Inst,
66016631 elem_index_src: LazySrcLoc,
66026632) InnerError!*Inst {
6633 _ = elem_index;
6634 _ = elem_index_src;
66036635 if (array_ptr.value()) |array_ptr_val| {
66046636 if (elem_index.value()) |index_val| {
66056637 // Both array pointer and index are compile-time known.
......@@ -7510,6 +7542,8 @@ fn resolveBuiltinTypeFields(
75107542 ty: Type,
75117543 name: []const u8,
75127544) InnerError!Type {
7545 _ = ty;
7546 _ = name;
75137547 const resolved_ty = try sema.getBuiltinType(block, src, name);
75147548 return sema.resolveTypeFields(block, src, resolved_ty);
75157549}
src/Zir.zig+2
......@@ -4433,6 +4433,7 @@ const Writer = struct {
44334433 }
44344434
44354435 fn writeInstIndex(self: *Writer, stream: anytype, inst: Inst.Index) !void {
4436 _ = self;
44364437 return stream.print("%{d}", .{inst});
44374438 }
44384439
......@@ -4453,6 +4454,7 @@ const Writer = struct {
44534454 name: []const u8,
44544455 flag: bool,
44554456 ) !void {
4457 _ = self;
44564458 if (!flag) return;
44574459 try stream.writeAll(name);
44584460 }
src/air.zig+36
......@@ -304,9 +304,12 @@ pub const Inst = struct {
304304 base: Inst,
305305
306306 pub fn operandCount(self: *const NoOp) usize {
307 _ = self;
307308 return 0;
308309 }
309310 pub fn getOperand(self: *const NoOp, index: usize) ?*Inst {
311 _ = self;
312 _ = index;
310313 return null;
311314 }
312315 };
......@@ -316,6 +319,7 @@ pub const Inst = struct {
316319 operand: *Inst,
317320
318321 pub fn operandCount(self: *const UnOp) usize {
322 _ = self;
319323 return 1;
320324 }
321325 pub fn getOperand(self: *const UnOp, index: usize) ?*Inst {
......@@ -331,6 +335,7 @@ pub const Inst = struct {
331335 rhs: *Inst,
332336
333337 pub fn operandCount(self: *const BinOp) usize {
338 _ = self;
334339 return 2;
335340 }
336341 pub fn getOperand(self: *const BinOp, index: usize) ?*Inst {
......@@ -356,9 +361,12 @@ pub const Inst = struct {
356361 name: [*:0]const u8,
357362
358363 pub fn operandCount(self: *const Arg) usize {
364 _ = self;
359365 return 0;
360366 }
361367 pub fn getOperand(self: *const Arg, index: usize) ?*Inst {
368 _ = self;
369 _ = index;
362370 return null;
363371 }
364372 };
......@@ -391,9 +399,12 @@ pub const Inst = struct {
391399 body: Body,
392400
393401 pub fn operandCount(self: *const Block) usize {
402 _ = self;
394403 return 0;
395404 }
396405 pub fn getOperand(self: *const Block, index: usize) ?*Inst {
406 _ = self;
407 _ = index;
397408 return null;
398409 }
399410 };
......@@ -412,9 +423,12 @@ pub const Inst = struct {
412423 body: Body,
413424
414425 pub fn operandCount(self: *const BrBlockFlat) usize {
426 _ = self;
415427 return 0;
416428 }
417429 pub fn getOperand(self: *const BrBlockFlat, index: usize) ?*Inst {
430 _ = self;
431 _ = index;
418432 return null;
419433 }
420434 };
......@@ -427,9 +441,11 @@ pub const Inst = struct {
427441 operand: *Inst,
428442
429443 pub fn operandCount(self: *const Br) usize {
444 _ = self;
430445 return 1;
431446 }
432447 pub fn getOperand(self: *const Br, index: usize) ?*Inst {
448 _ = self;
433449 if (index == 0)
434450 return self.operand;
435451 return null;
......@@ -443,9 +459,12 @@ pub const Inst = struct {
443459 block: *Block,
444460
445461 pub fn operandCount(self: *const BrVoid) usize {
462 _ = self;
446463 return 0;
447464 }
448465 pub fn getOperand(self: *const BrVoid, index: usize) ?*Inst {
466 _ = self;
467 _ = index;
449468 return null;
450469 }
451470 };
......@@ -490,6 +509,7 @@ pub const Inst = struct {
490509 else_death_count: u32 = 0,
491510
492511 pub fn operandCount(self: *const CondBr) usize {
512 _ = self;
493513 return 1;
494514 }
495515 pub fn getOperand(self: *const CondBr, index: usize) ?*Inst {
......@@ -516,9 +536,12 @@ pub const Inst = struct {
516536 val: Value,
517537
518538 pub fn operandCount(self: *const Constant) usize {
539 _ = self;
519540 return 0;
520541 }
521542 pub fn getOperand(self: *const Constant, index: usize) ?*Inst {
543 _ = self;
544 _ = index;
522545 return null;
523546 }
524547 };
......@@ -530,9 +553,12 @@ pub const Inst = struct {
530553 body: Body,
531554
532555 pub fn operandCount(self: *const Loop) usize {
556 _ = self;
533557 return 0;
534558 }
535559 pub fn getOperand(self: *const Loop, index: usize) ?*Inst {
560 _ = self;
561 _ = index;
536562 return null;
537563 }
538564 };
......@@ -544,9 +570,12 @@ pub const Inst = struct {
544570 variable: *Module.Var,
545571
546572 pub fn operandCount(self: *const VarPtr) usize {
573 _ = self;
547574 return 0;
548575 }
549576 pub fn getOperand(self: *const VarPtr, index: usize) ?*Inst {
577 _ = self;
578 _ = index;
550579 return null;
551580 }
552581 };
......@@ -559,9 +588,12 @@ pub const Inst = struct {
559588 field_index: usize,
560589
561590 pub fn operandCount(self: *const StructFieldPtr) usize {
591 _ = self;
562592 return 1;
563593 }
564594 pub fn getOperand(self: *const StructFieldPtr, index: usize) ?*Inst {
595 _ = self;
596 _ = index;
565597 var i = index;
566598
567599 if (i < 1)
......@@ -593,6 +625,7 @@ pub const Inst = struct {
593625 };
594626
595627 pub fn operandCount(self: *const SwitchBr) usize {
628 _ = self;
596629 return 1;
597630 }
598631 pub fn getOperand(self: *const SwitchBr, index: usize) ?*Inst {
......@@ -621,9 +654,12 @@ pub const Inst = struct {
621654 column: u32,
622655
623656 pub fn operandCount(self: *const DbgStmt) usize {
657 _ = self;
624658 return 0;
625659 }
626660 pub fn getOperand(self: *const DbgStmt, index: usize) ?*Inst {
661 _ = self;
662 _ = index;
627663 return null;
628664 }
629665 };
src/codegen.zig+22-15
......@@ -564,7 +564,7 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type {
564564 .r11 = true, // fp
565565 .r14 = true, // lr
566566 };
567 inline for (callee_preserved_regs) |reg, i| {
567 inline for (callee_preserved_regs) |reg| {
568568 if (self.register_manager.isRegAllocated(reg)) {
569569 @field(saved_regs, @tagName(reg)) = true;
570570 }
......@@ -602,7 +602,7 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type {
602602 } else {
603603 if (math.cast(i26, amt)) |offset| {
604604 writeInt(u32, self.code.items[jmp_reloc..][0..4], Instruction.b(.al, offset).toU32());
605 } else |err| {
605 } else |_| {
606606 return self.failSymbol("exitlude jump is too large", .{});
607607 }
608608 }
......@@ -675,7 +675,7 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type {
675675 } else {
676676 if (math.cast(i28, amt)) |offset| {
677677 writeInt(u32, self.code.items[jmp_reloc..][0..4], Instruction.b(offset).toU32());
678 } else |err| {
678 } else |_| {
679679 return self.failSymbol("exitlude jump is too large", .{});
680680 }
681681 }
......@@ -1497,6 +1497,7 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type {
14971497 swap_lhs_and_rhs: bool,
14981498 op: ir.Inst.Tag,
14991499 ) !void {
1500 _ = src;
15001501 assert(lhs_mcv == .register or rhs_mcv == .register);
15011502
15021503 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 {
19051906 try self.genX8664ModRMRegToStack(src, dst_ty, off, src_reg, mr + 0x1);
19061907 },
19071908 .immediate => |imm| {
1909 _ = imm;
19081910 return self.fail(src, "TODO implement x86 ADD/SUB/CMP source immediate", .{});
19091911 },
19101912 .embedded_in_code, .memory, .stack_offset => {
......@@ -2054,6 +2056,7 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type {
20542056 return self.genSetStack(src, dst_ty, off, MCValue{ .register = dst_reg });
20552057 },
20562058 .immediate => |imm| {
2059 _ = imm;
20572060 return self.fail(src, "TODO implement x86 multiply source immediate", .{});
20582061 },
20592062 .embedded_in_code, .memory, .stack_offset => {
......@@ -2982,14 +2985,14 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type {
29822985 .arm, .armeb => {
29832986 if (math.cast(i26, @intCast(i32, index) - @intCast(i32, self.code.items.len + 8))) |delta| {
29842987 writeInt(u32, try self.code.addManyAsArray(4), Instruction.b(.al, delta).toU32());
2985 } else |err| {
2988 } else |_| {
29862989 return self.fail(src, "TODO: enable larger branch offset", .{});
29872990 }
29882991 },
29892992 .aarch64, .aarch64_be, .aarch64_32 => {
29902993 if (math.cast(i28, @intCast(i32, index) - @intCast(i32, self.code.items.len + 8))) |delta| {
29912994 writeInt(u32, try self.code.addManyAsArray(4), Instruction.b(delta).toU32());
2992 } else |err| {
2995 } else |_| {
29932996 return self.fail(src, "TODO: enable larger branch offset", .{});
29942997 }
29952998 },
......@@ -3307,16 +3310,18 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type {
33073310 }
33083311 },
33093312 .compare_flags_unsigned => |op| {
3313 _ = op;
33103314 return self.fail(src, "TODO implement set stack variable with compare flags value (unsigned)", .{});
33113315 },
33123316 .compare_flags_signed => |op| {
3317 _ = op;
33133318 return self.fail(src, "TODO implement set stack variable with compare flags value (signed)", .{});
33143319 },
33153320 .immediate => {
33163321 const reg = try self.copyToTmpRegister(src, ty, mcv);
33173322 return self.genSetStack(src, ty, stack_offset, MCValue{ .register = reg });
33183323 },
3319 .embedded_in_code => |code_offset| {
3324 .embedded_in_code => {
33203325 return self.fail(src, "TODO implement set stack variable from embedded_in_code", .{});
33213326 },
33223327 .register => |reg| {
......@@ -3352,7 +3357,7 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type {
33523357 else => return self.fail(src, "TODO implement storing other types abi_size={}", .{abi_size}),
33533358 }
33543359 },
3355 .memory => |vaddr| {
3360 .memory => {
33563361 return self.fail(src, "TODO implement set stack variable from memory vaddr", .{});
33573362 },
33583363 .stack_offset => |off| {
......@@ -3380,10 +3385,10 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type {
33803385 else => return self.fail(src, "TODO implement memset", .{}),
33813386 }
33823387 },
3383 .compare_flags_unsigned => |op| {
3388 .compare_flags_unsigned => {
33843389 return self.fail(src, "TODO implement set stack variable with compare flags value (unsigned)", .{});
33853390 },
3386 .compare_flags_signed => |op| {
3391 .compare_flags_signed => {
33873392 return self.fail(src, "TODO implement set stack variable with compare flags value (signed)", .{});
33883393 },
33893394 .immediate => |x_big| {
......@@ -3435,13 +3440,13 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type {
34353440 },
34363441 }
34373442 },
3438 .embedded_in_code => |code_offset| {
3443 .embedded_in_code => {
34393444 return self.fail(src, "TODO implement set stack variable from embedded_in_code", .{});
34403445 },
34413446 .register => |reg| {
34423447 try self.genX8664ModRMRegToStack(src, ty, stack_offset, reg, 0x89);
34433448 },
3444 .memory => |vaddr| {
3449 .memory => {
34453450 return self.fail(src, "TODO implement set stack variable from memory vaddr", .{});
34463451 },
34473452 .stack_offset => |off| {
......@@ -3469,17 +3474,17 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type {
34693474 else => return self.fail(src, "TODO implement memset", .{}),
34703475 }
34713476 },
3472 .compare_flags_unsigned => |op| {
3477 .compare_flags_unsigned => {
34733478 return self.fail(src, "TODO implement set stack variable with compare flags value (unsigned)", .{});
34743479 },
3475 .compare_flags_signed => |op| {
3480 .compare_flags_signed => {
34763481 return self.fail(src, "TODO implement set stack variable with compare flags value (signed)", .{});
34773482 },
34783483 .immediate => {
34793484 const reg = try self.copyToTmpRegister(src, ty, mcv);
34803485 return self.genSetStack(src, ty, stack_offset, MCValue{ .register = reg });
34813486 },
3482 .embedded_in_code => |code_offset| {
3487 .embedded_in_code => {
34833488 return self.fail(src, "TODO implement set stack variable from embedded_in_code", .{});
34843489 },
34853490 .register => |reg| {
......@@ -3511,7 +3516,7 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type {
35113516 else => return self.fail(src, "TODO implement storing other types abi_size={}", .{abi_size}),
35123517 }
35133518 },
3514 .memory => |vaddr| {
3519 .memory => {
35153520 return self.fail(src, "TODO implement set stack variable from memory vaddr", .{});
35163521 },
35173522 .stack_offset => |off| {
......@@ -3842,6 +3847,7 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type {
38423847 );
38433848 },
38443849 .compare_flags_signed => |op| {
3850 _ = op;
38453851 return self.fail(src, "TODO set register with compare flags value (signed)", .{});
38463852 },
38473853 .immediate => |x| {
......@@ -4460,6 +4466,7 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type {
44604466 dummy,
44614467
44624468 pub fn allocIndex(self: Register) ?u4 {
4469 _ = self;
44634470 return null;
44644471 }
44654472 };
src/codegen/arm.zig+1-1
......@@ -674,7 +674,7 @@ pub const Instruction = union(enum) {
674674 };
675675 const imm4h: u4 = switch (offset) {
676676 .immediate => |imm| @truncate(u4, imm >> 4),
677 .register => |reg| 0b0000,
677 .register => 0b0000,
678678 };
679679
680680 return Instruction{
src/codegen/c.zig+9
......@@ -47,6 +47,8 @@ fn formatTypeAsCIdentifier(
4747 options: std.fmt.FormatOptions,
4848 writer: anytype,
4949) !void {
50 _ = fmt;
51 _ = options;
5052 var buffer = [1]u8{0} ** 128;
5153 // We don't care if it gets cut off, it's still more unique than a number
5254 var buf = std.fmt.bufPrint(&buffer, "{}", .{data}) catch &buffer;
......@@ -63,6 +65,8 @@ fn formatIdent(
6365 options: std.fmt.FormatOptions,
6466 writer: anytype,
6567) !void {
68 _ = fmt;
69 _ = options;
6670 for (ident) |c, i| {
6771 switch (c) {
6872 'a'...'z', 'A'...'Z', '_' => try writer.writeByte(c),
......@@ -747,6 +751,7 @@ pub fn genBody(o: *Object, body: ir.Body) error{ AnalysisFail, OutOfMemory }!voi
747751}
748752
749753fn genVarPtr(o: *Object, inst: *Inst.VarPtr) !CValue {
754 _ = o;
750755 return CValue{ .decl_ref = inst.variable.owner_decl };
751756}
752757
......@@ -937,6 +942,8 @@ fn genCall(o: *Object, inst: *Inst.Call) !CValue {
937942}
938943
939944fn genDbgStmt(o: *Object, inst: *Inst.DbgStmt) !CValue {
945 _ = o;
946 _ = inst;
940947 // TODO emit #line directive here with line number and filename
941948 return CValue.none;
942949}
......@@ -1016,11 +1023,13 @@ fn genBitcast(o: *Object, inst: *Inst.UnOp) !CValue {
10161023}
10171024
10181025fn genBreakpoint(o: *Object, inst: *Inst.NoOp) !CValue {
1026 _ = inst;
10191027 try o.writer().writeAll("zig_breakpoint();\n");
10201028 return CValue.none;
10211029}
10221030
10231031fn genUnreach(o: *Object, inst: *Inst.NoOp) !CValue {
1032 _ = inst;
10241033 try o.writer().writeAll("zig_unreachable();\n");
10251034 return CValue.none;
10261035}
src/codegen/llvm.zig+4
......@@ -154,6 +154,7 @@ pub const Object = struct {
154154 object_pathZ: [:0]const u8,
155155
156156 pub fn create(allocator: *Allocator, sub_path: []const u8, options: link.Options) !*Object {
157 _ = sub_path;
157158 const self = try allocator.create(Object);
158159 errdefer allocator.destroy(self);
159160
......@@ -742,6 +743,7 @@ pub const FuncGen = struct {
742743 }
743744
744745 fn genRetVoid(self: *FuncGen, inst: *Inst.NoOp) ?*const llvm.Value {
746 _ = inst;
745747 _ = self.builder.buildRetVoid();
746748 return null;
747749 }
......@@ -873,6 +875,7 @@ pub const FuncGen = struct {
873875 }
874876
875877 fn genUnreach(self: *FuncGen, inst: *Inst.NoOp) ?*const llvm.Value {
878 _ = inst;
876879 _ = self.builder.buildUnreachable();
877880 return null;
878881 }
......@@ -1013,6 +1016,7 @@ pub const FuncGen = struct {
10131016 }
10141017
10151018 fn genBreakpoint(self: *FuncGen, inst: *Inst.NoOp) !?*const llvm.Value {
1019 _ = inst;
10161020 const llvn_fn = self.getIntrinsic("llvm.debugtrap");
10171021 _ = self.builder.buildCall(llvn_fn, null, 0, "");
10181022 return null;
src/codegen/wasm.zig+7-3
......@@ -702,7 +702,7 @@ pub const Context = struct {
702702 try writer.writeByte(wasm.valtype(.i32)); // error code is always an i32 integer.
703703 try writer.writeByte(val_type);
704704 },
705 else => |ret_type| {
705 else => {
706706 try leb.writeULEB128(writer, @as(u32, 1));
707707 // Can we maybe get the source index of the return type?
708708 const val_type = try self.genValtype(.{ .node_offset = 0 }, return_type);
......@@ -721,7 +721,7 @@ pub const Context = struct {
721721 // TODO: check for and handle death of instructions
722722 const mod_fn = blk: {
723723 if (typed_value.val.castTag(.function)) |func| break :blk func.data;
724 if (typed_value.val.castTag(.extern_fn)) |ext_fn| return Result.appended; // don't need code body for extern functions
724 if (typed_value.val.castTag(.extern_fn)) |_| return Result.appended; // don't need code body for extern functions
725725 unreachable;
726726 };
727727
......@@ -910,7 +910,7 @@ pub const Context = struct {
910910 },
911911 else => unreachable,
912912 },
913 .local => |local| {
913 .local => {
914914 try self.emitWValue(rhs);
915915 try writer.writeByte(wasm.opcode(.local_set));
916916 try leb.writeULEB128(writer, lhs.local);
......@@ -925,6 +925,7 @@ pub const Context = struct {
925925 }
926926
927927 fn genArg(self: *Context, inst: *Inst.Arg) InnerError!WValue {
928 _ = inst;
928929 // arguments share the index with locals
929930 defer self.local_index += 1;
930931 return WValue{ .local = self.local_index };
......@@ -1213,12 +1214,15 @@ pub const Context = struct {
12131214 }
12141215
12151216 fn genBreakpoint(self: *Context, breakpoint: *Inst.NoOp) InnerError!WValue {
1217 _ = self;
1218 _ = breakpoint;
12161219 // unsupported by wasm itself. Can be implemented once we support DWARF
12171220 // for wasm
12181221 return .none;
12191222 }
12201223
12211224 fn genUnreachable(self: *Context, unreach: *Inst.NoOp) InnerError!WValue {
1225 _ = unreach;
12221226 try self.code.append(wasm.opcode(.@"unreachable"));
12231227 return .none;
12241228 }
src/link.zig+1-1
......@@ -517,7 +517,7 @@ pub const File = struct {
517517 .target = base.options.target,
518518 .output_mode = .Obj,
519519 });
520 const o_directory = base.options.module.?.zig_cache_artifact_directory;
520 const o_directory = module.zig_cache_artifact_directory;
521521 const full_obj_path = try o_directory.join(arena, &[_][]const u8{obj_basename});
522522 break :blk full_obj_path;
523523 }
src/link/C.zig+14-2
......@@ -76,7 +76,12 @@ pub fn deinit(self: *C) void {
7676 self.decl_table.deinit(self.base.allocator);
7777}
7878
79pub fn allocateDeclIndexes(self: *C, decl: *Module.Decl) !void {}
79pub fn allocateDeclIndexes(self: *C, decl: *Module.Decl) !void {
80 if (false) {
81 self;
82 decl;
83 }
84}
8085
8186pub fn freeDecl(self: *C, decl: *Module.Decl) void {
8287 _ = self.decl_table.swapRemove(decl);
......@@ -307,4 +312,11 @@ pub fn updateDeclExports(
307312 module: *Module,
308313 decl: *Module.Decl,
309314 exports: []const *Module.Export,
310) !void {}
315) !void {
316 if (false) {
317 exports;
318 decl;
319 module;
320 self;
321 }
322}
src/link/Coff.zig+4-1
......@@ -831,7 +831,7 @@ fn linkWithLLD(self: *Coff, comp: *Compilation) !void {
831831 .target = self.base.options.target,
832832 .output_mode = .Obj,
833833 });
834 const o_directory = self.base.options.module.?.zig_cache_artifact_directory;
834 const o_directory = module.zig_cache_artifact_directory;
835835 const full_obj_path = try o_directory.join(arena, &[_][]const u8{obj_basename});
836836 break :blk full_obj_path;
837837 }
......@@ -1340,6 +1340,9 @@ pub fn getDeclVAddr(self: *Coff, decl: *const Module.Decl) u64 {
13401340}
13411341
13421342pub fn updateDeclLineNumber(self: *Coff, module: *Module, decl: *Module.Decl) !void {
1343 _ = self;
1344 _ = module;
1345 _ = decl;
13431346 // TODO Implement this
13441347}
13451348
src/link/Elf.zig+10-3
......@@ -1262,7 +1262,7 @@ fn linkWithLLD(self: *Elf, comp: *Compilation) !void {
12621262 .target = self.base.options.target,
12631263 .output_mode = .Obj,
12641264 });
1265 const o_directory = self.base.options.module.?.zig_cache_artifact_directory;
1265 const o_directory = module.zig_cache_artifact_directory;
12661266 const full_obj_path = try o_directory.join(arena, &[_][]const u8{obj_basename});
12671267 break :blk full_obj_path;
12681268 }
......@@ -1938,6 +1938,11 @@ fn freeTextBlock(self: *Elf, text_block: *TextBlock) void {
19381938}
19391939
19401940fn shrinkTextBlock(self: *Elf, text_block: *TextBlock, new_block_size: u64) void {
1941 if (false) {
1942 self;
1943 text_block;
1944 new_block_size;
1945 }
19411946 // TODO check the new capacity, and if it crosses the size threshold into a big enough
19421947 // capacity, insert a free list node for it.
19431948}
......@@ -2706,6 +2711,7 @@ pub fn updateDeclExports(
27062711
27072712/// Must be called only after a successful call to `updateDecl`.
27082713pub fn updateDeclLineNumber(self: *Elf, module: *Module, decl: *const Module.Decl) !void {
2714 _ = module;
27092715 const tracy = trace(@src());
27102716 defer tracy.end();
27112717
......@@ -2979,6 +2985,7 @@ fn dbgLineNeededHeaderBytes(self: Elf) u32 {
29792985}
29802986
29812987fn dbgInfoNeededHeaderBytes(self: Elf) u32 {
2988 _ = self;
29822989 return 120;
29832990}
29842991
......@@ -3372,7 +3379,7 @@ const CsuObjects = struct {
33723379 if (result.crtend) |*obj| obj.* = try fs.path.join(arena, &[_][]const u8{ gcc_dir_path, obj.* });
33733380 },
33743381 else => {
3375 inline for (std.meta.fields(@TypeOf(result))) |f, i| {
3382 inline for (std.meta.fields(@TypeOf(result))) |f| {
33763383 if (@field(result, f.name)) |*obj| {
33773384 obj.* = try fs.path.join(arena, &[_][]const u8{ crt_dir_path, obj.* });
33783385 }
......@@ -3380,7 +3387,7 @@ const CsuObjects = struct {
33803387 },
33813388 }
33823389 } else {
3383 inline for (std.meta.fields(@TypeOf(result))) |f, i| {
3390 inline for (std.meta.fields(@TypeOf(result))) |f| {
33843391 if (@field(result, f.name)) |*obj| {
33853392 if (comp.crt_files.get(obj.*)) |crtf| {
33863393 obj.* = crtf.full_object_path;
src/link/MachO.zig+5-1
......@@ -441,6 +441,7 @@ pub fn flush(self: *MachO, comp: *Compilation) !void {
441441}
442442
443443pub fn flushModule(self: *MachO, comp: *Compilation) !void {
444 _ = comp;
444445 const tracy = trace(@src());
445446 defer tracy.end();
446447
......@@ -533,7 +534,7 @@ fn linkWithLLD(self: *MachO, comp: *Compilation) !void {
533534 .target = self.base.options.target,
534535 .output_mode = .Obj,
535536 });
536 const o_directory = self.base.options.module.?.zig_cache_artifact_directory;
537 const o_directory = module.zig_cache_artifact_directory;
537538 const full_obj_path = try o_directory.join(arena, &[_][]const u8{obj_basename});
538539 break :blk full_obj_path;
539540 }
......@@ -1254,6 +1255,9 @@ fn freeTextBlock(self: *MachO, text_block: *TextBlock) void {
12541255}
12551256
12561257fn shrinkTextBlock(self: *MachO, text_block: *TextBlock, new_block_size: u64) void {
1258 _ = self;
1259 _ = text_block;
1260 _ = new_block_size;
12571261 // TODO check the new capacity, and if it crosses the size threshold into a big enough
12581262 // capacity, insert a free list node for it.
12591263}
src/link/MachO/DebugSymbols.zig+6
......@@ -899,6 +899,7 @@ fn writeStringTable(self: *DebugSymbols) !void {
899899}
900900
901901pub fn updateDeclLineNumber(self: *DebugSymbols, module: *Module, decl: *const Module.Decl) !void {
902 _ = module;
902903 const tracy = trace(@src());
903904 defer tracy.end();
904905
......@@ -926,6 +927,8 @@ pub fn initDeclDebugBuffers(
926927 module: *Module,
927928 decl: *Module.Decl,
928929) !DeclDebugBuffers {
930 _ = self;
931 _ = module;
929932 const tracy = trace(@src());
930933 defer tracy.end();
931934
......@@ -1188,6 +1191,7 @@ fn addDbgInfoType(
11881191 dbg_info_buffer: *std.ArrayList(u8),
11891192 target: std.Target,
11901193) !void {
1194 _ = self;
11911195 switch (ty.zigTypeTag()) {
11921196 .Void => unreachable,
11931197 .NoReturn => unreachable,
......@@ -1364,6 +1368,7 @@ fn getRelocDbgInfoSubprogramHighPC() u32 {
13641368}
13651369
13661370fn dbgLineNeededHeaderBytes(self: DebugSymbols, module: *Module) u32 {
1371 _ = self;
13671372 const directory_entry_format_count = 1;
13681373 const file_name_entry_format_count = 1;
13691374 const directory_count = 1;
......@@ -1378,6 +1383,7 @@ fn dbgLineNeededHeaderBytes(self: DebugSymbols, module: *Module) u32 {
13781383}
13791384
13801385fn dbgInfoNeededHeaderBytes(self: DebugSymbols) u32 {
1386 _ = self;
13811387 return 120;
13821388}
13831389
src/link/MachO/Zld.zig+4-3
......@@ -108,6 +108,7 @@ const TlvOffset = struct {
108108 offset: u64,
109109
110110 fn cmp(context: void, a: TlvOffset, b: TlvOffset) bool {
111 _ = context;
111112 return a.source_addr < b.source_addr;
112113 }
113114};
......@@ -437,7 +438,7 @@ fn updateMetadata(self: *Zld) !void {
437438 const data_seg = &self.load_commands.items[self.data_segment_cmd_index.?].Segment;
438439
439440 // Create missing metadata
440 for (object.sections.items) |sect, sect_id| {
441 for (object.sections.items) |sect| {
441442 const segname = sect.segname();
442443 const sectname = sect.sectname();
443444
......@@ -1373,7 +1374,7 @@ fn allocateTentativeSymbols(self: *Zld) !void {
13731374 }
13741375
13751376 // Convert tentative definitions into regular symbols.
1376 for (self.tentatives.values()) |sym, i| {
1377 for (self.tentatives.values()) |sym| {
13771378 const tent = sym.cast(Symbol.Tentative) orelse unreachable;
13781379 const reg = try self.allocator.create(Symbol.Regular);
13791380 errdefer self.allocator.destroy(reg);
......@@ -1758,7 +1759,7 @@ fn resolveSymbolsInObject(self: *Zld, object: *Object) !void {
17581759
17591760 t_sym.alias = sym;
17601761 sym_ptr.* = sym;
1761 } else if (sym.cast(Symbol.Unresolved)) |und| {
1762 } else if (sym.cast(Symbol.Unresolved)) |_| {
17621763 if (self.globals.get(sym.name)) |g_sym| {
17631764 sym.alias = g_sym;
17641765 continue;
src/link/MachO/bind.zig+1
......@@ -10,6 +10,7 @@ pub const Pointer = struct {
1010};
1111
1212pub fn pointerCmp(context: void, a: Pointer, b: Pointer) bool {
13 _ = context;
1314 if (a.segment_id < b.segment_id) return true;
1415 if (a.segment_id == b.segment_id) {
1516 return a.offset < b.offset;
src/link/SpirV.zig+9-1
......@@ -102,6 +102,7 @@ pub fn deinit(self: *SpirV) void {
102102}
103103
104104pub fn updateDecl(self: *SpirV, module: *Module, decl: *Module.Decl) !void {
105 _ = module;
105106 // Keep track of all decls so we can iterate over them on flush().
106107 _ = try self.decl_table.getOrPut(self.base.allocator, decl);
107108}
......@@ -111,7 +112,14 @@ pub fn updateDeclExports(
111112 module: *Module,
112113 decl: *const Module.Decl,
113114 exports: []const *Module.Export,
114) !void {}
115) !void {
116 if (false) {
117 self;
118 module;
119 decl;
120 exports;
121 }
122}
115123
116124pub fn freeDecl(self: *SpirV, decl: *Module.Decl) void {
117125 assert(self.decl_table.swapRemove(decl));
src/link/Wasm.zig+11-3
......@@ -216,7 +216,7 @@ pub fn updateDecl(self: *Wasm, module: *Module, decl: *Module.Decl) !void {
216216 try module.failed_decls.put(module.gpa, decl, context.err_msg);
217217 return;
218218 },
219 else => |e| return err,
219 else => |e| return e,
220220 };
221221
222222 const code: []const u8 = switch (result) {
......@@ -258,7 +258,14 @@ pub fn updateDeclExports(
258258 module: *Module,
259259 decl: *const Module.Decl,
260260 exports: []const *Module.Export,
261) !void {}
261) !void {
262 if (false) {
263 self;
264 module;
265 decl;
266 exports;
267 }
268}
262269
263270pub fn freeDecl(self: *Wasm, decl: *Module.Decl) void {
264271 if (self.getFuncidx(decl)) |func_idx| {
......@@ -300,6 +307,7 @@ pub fn flush(self: *Wasm, comp: *Compilation) !void {
300307}
301308
302309pub fn flushModule(self: *Wasm, comp: *Compilation) !void {
310 _ = comp;
303311 const tracy = trace(@src());
304312 defer tracy.end();
305313
......@@ -557,7 +565,7 @@ fn linkWithLLD(self: *Wasm, comp: *Compilation) !void {
557565 .target = self.base.options.target,
558566 .output_mode = .Obj,
559567 });
560 const o_directory = self.base.options.module.?.zig_cache_artifact_directory;
568 const o_directory = module.zig_cache_artifact_directory;
561569 const full_obj_path = try o_directory.join(arena, &[_][]const u8{obj_basename});
562570 break :blk full_obj_path;
563571 }
src/main.zig+2-2
......@@ -500,7 +500,7 @@ const Emit = union(enum) {
500500};
501501
502502fn optionalBoolEnvVar(arena: *Allocator, name: []const u8) !bool {
503 if (std.process.getEnvVarOwned(arena, name)) |value| {
503 if (std.process.getEnvVarOwned(arena, name)) |_| {
504504 return true;
505505 } else |err| switch (err) {
506506 error.EnvironmentVariableNotFound => return false,
......@@ -2560,7 +2560,7 @@ pub const usage_init =
25602560;
25612561
25622562pub fn cmdInit(
2563 gpa: *Allocator,
2563 _: *Allocator,
25642564 arena: *Allocator,
25652565 args: []const []const u8,
25662566 output_mode: std.builtin.OutputMode,
src/print_env.zig+1
......@@ -5,6 +5,7 @@ const Allocator = std.mem.Allocator;
55const fatal = @import("main.zig").fatal;
66
77pub fn cmdEnv(gpa: *Allocator, args: []const []const u8, stdout: std.fs.File.Writer) !void {
8 _ = args;
89 const self_exe_path = try std.fs.selfExePathAlloc(gpa);
910 defer gpa.free(self_exe_path);
1011
src/print_targets.zig+1
......@@ -17,6 +17,7 @@ pub fn cmdTargets(
1717 stdout: anytype,
1818 native_target: Target,
1919) !void {
20 _ = args;
2021 var zig_lib_directory = introspect.findZigLibDir(allocator) catch |err| {
2122 fatal("unable to find zig installation directory: {s}\n", .{@errorName(err)});
2223 };
src/register_manager.zig+2
......@@ -265,6 +265,8 @@ fn MockFunction(comptime Register: type) type {
265265 }
266266
267267 pub fn spillInstruction(self: *Self, src: LazySrcLoc, reg: Register, inst: *ir.Inst) !void {
268 _ = src;
269 _ = inst;
268270 try self.spilled.append(self.allocator, reg);
269271 }
270272 };
src/stage1.zig+2
......@@ -407,6 +407,8 @@ export fn stage2_add_link_lib(
407407 symbol_name_ptr: [*c]const u8,
408408 symbol_name_len: usize,
409409) ?[*:0]const u8 {
410 _ = symbol_name_len;
411 _ = symbol_name_ptr;
410412 const comp = @intToPtr(*Compilation, stage1.userdata);
411413 const lib_name = std.ascii.allocLowerString(comp.gpa, lib_name_ptr[0..lib_name_len]) catch return "out of memory";
412414 const target = comp.getTarget();
src/test.zig+3
......@@ -70,6 +70,8 @@ const ErrorMsg = union(enum) {
7070 options: std.fmt.FormatOptions,
7171 writer: anytype,
7272 ) !void {
73 _ = fmt;
74 _ = options;
7375 switch (self) {
7476 .src => |src| {
7577 return writer.print("{s}:{d}:{d}: {s}: {s}", .{
......@@ -592,6 +594,7 @@ pub const TestContext = struct {
592594 thread_pool: *ThreadPool,
593595 global_cache_directory: Compilation.Directory,
594596 ) !void {
597 _ = self;
595598 const target_info = try std.zig.system.NativeTargetInfo.detect(allocator, case.target);
596599 const target = target_info.target;
597600
src/tracy.zig+3-1
......@@ -28,7 +28,9 @@ pub const ___tracy_c_zone_context = extern struct {
2828};
2929
3030pub const Ctx = if (enable) ___tracy_c_zone_context else struct {
31 pub fn end(self: Ctx) void {}
31 pub fn end(self: Ctx) void {
32 _ = self;
33 }
3234};
3335
3436pub inline fn trace(comptime src: std.builtin.SourceLocation) Ctx {
src/translate_c.zig+15-5
......@@ -206,6 +206,7 @@ const Scope = struct {
206206 }
207207
208208 fn findBlockReturnType(inner: *Scope, c: *Context) clang.QualType {
209 _ = c;
209210 var scope = inner;
210211 while (true) {
211212 switch (scope.id) {
......@@ -601,7 +602,7 @@ fn visitFnDecl(c: *Context, fn_decl: *const clang.FunctionDecl) Error!void {
601602 var scope = &block_scope.base;
602603
603604 var param_id: c_uint = 0;
604 for (proto_node.data.params) |*param, i| {
605 for (proto_node.data.params) |*param| {
605606 const param_name = param.name orelse {
606607 proto_node.data.is_extern = true;
607608 proto_node.data.is_export = false;
......@@ -785,7 +786,7 @@ const builtin_typedef_map = std.ComptimeStringMap([]const u8, .{
785786});
786787
787788fn transTypeDef(c: *Context, scope: *Scope, typedef_decl: *const clang.TypedefNameDecl) Error!void {
788 if (c.decl_table.get(@ptrToInt(typedef_decl.getCanonicalDecl()))) |name|
789 if (c.decl_table.get(@ptrToInt(typedef_decl.getCanonicalDecl()))) |_|
789790 return; // Avoid processing this decl twice
790791 const toplevel = scope.id == .root;
791792 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
935936}
936937
937938fn transRecordDecl(c: *Context, scope: *Scope, record_decl: *const clang.RecordDecl) Error!void {
938 if (c.decl_table.get(@ptrToInt(record_decl.getCanonicalDecl()))) |name|
939 if (c.decl_table.get(@ptrToInt(record_decl.getCanonicalDecl()))) |_|
939940 return; // Avoid processing this decl twice
940941 const record_loc = record_decl.getLocation();
941942 const toplevel = scope.id == .root;
......@@ -1080,7 +1081,7 @@ fn transRecordDecl(c: *Context, scope: *Scope, record_decl: *const clang.RecordD
10801081}
10811082
10821083fn transEnumDecl(c: *Context, scope: *Scope, enum_decl: *const clang.EnumDecl) Error!void {
1083 if (c.decl_table.get(@ptrToInt(enum_decl.getCanonicalDecl()))) |name|
1084 if (c.decl_table.get(@ptrToInt(enum_decl.getCanonicalDecl()))) |_|
10841085 return; // Avoid processing this decl twice
10851086 const enum_loc = enum_decl.getLocation();
10861087 const toplevel = scope.id == .root;
......@@ -1312,6 +1313,7 @@ fn transConvertVectorExpr(
13121313 source_loc: clang.SourceLocation,
13131314 expr: *const clang.ConvertVectorExpr,
13141315) TransError!Node {
1316 _ = source_loc;
13151317 const base_stmt = @ptrCast(*const clang.Stmt, expr);
13161318
13171319 var block_scope = try Scope.Block.init(c, scope, true);
......@@ -1433,6 +1435,7 @@ fn transSimpleOffsetOfExpr(
14331435 scope: *Scope,
14341436 expr: *const clang.OffsetOfExpr,
14351437) TransError!Node {
1438 _ = scope;
14361439 assert(expr.getNumComponents() == 1);
14371440 const component = expr.getComponent(0);
14381441 if (component.getKind() == .Field) {
......@@ -2269,6 +2272,7 @@ fn transStringLiteralInitializer(
22692272/// both operands resolve to addresses. The C standard requires that both operands
22702273/// point to elements of the same array object, but we do not verify that here.
22712274fn cIsPointerDiffExpr(c: *Context, stmt: *const clang.BinaryOperator) bool {
2275 _ = c;
22722276 const lhs = @ptrCast(*const clang.Stmt, stmt.getLHS());
22732277 const rhs = @ptrCast(*const clang.Stmt, stmt.getRHS());
22742278 return stmt.getOpcode() == .Sub and
......@@ -2572,6 +2576,7 @@ fn transInitListExprVector(
25722576 expr: *const clang.InitListExpr,
25732577 ty: *const clang.Type,
25742578) TransError!Node {
2579 _ = ty;
25752580 const qt = getExprQualType(c, @ptrCast(*const clang.Expr, expr));
25762581 const vector_type = try transQualType(c, scope, qt, loc);
25772582 const init_count = expr.getNumInits();
......@@ -2721,6 +2726,7 @@ fn transImplicitValueInitExpr(
27212726 expr: *const clang.Expr,
27222727 used: ResultUsed,
27232728) TransError!Node {
2729 _ = used;
27242730 const source_loc = expr.getBeginLoc();
27252731 const qt = getExprQualType(c, expr);
27262732 const ty = qt.getTypePtr();
......@@ -3407,6 +3413,7 @@ fn transUnaryExprOrTypeTraitExpr(
34073413 stmt: *const clang.UnaryExprOrTypeTraitExpr,
34083414 result_used: ResultUsed,
34093415) TransError!Node {
3416 _ = result_used;
34103417 const loc = stmt.getBeginLoc();
34113418 const type_node = try transQualType(c, scope, stmt.getTypeOfArgument(), loc);
34123419
......@@ -3893,6 +3900,7 @@ fn maybeSuppressResult(
38933900 used: ResultUsed,
38943901 result: Node,
38953902) TransError!Node {
3903 _ = scope;
38963904 if (used == .used) return result;
38973905 return Tag.discard.create(c.arena, result);
38983906}
......@@ -4337,7 +4345,7 @@ fn transCreateNodeMacroFn(c: *Context, name: []const u8, ref: Node, proto_alias:
43374345 var fn_params = std.ArrayList(ast.Payload.Param).init(c.gpa);
43384346 defer fn_params.deinit();
43394347
4340 for (proto_alias.data.params) |param, i| {
4348 for (proto_alias.data.params) |param| {
43414349 const param_name = param.name orelse
43424350 try std.fmt.allocPrint(c.arena, "arg_{d}", .{c.getMangle()});
43434351
......@@ -5653,6 +5661,7 @@ fn parseCSpecifierQualifierList(c: *Context, m: *MacroCtx, scope: *Scope, allow_
56535661}
56545662
56555663fn parseCNumericType(c: *Context, m: *MacroCtx, scope: *Scope) ParseError!Node {
5664 _ = scope;
56565665 const KwCounter = struct {
56575666 double: u8 = 0,
56585667 long: u8 = 0,
......@@ -5754,6 +5763,7 @@ fn parseCNumericType(c: *Context, m: *MacroCtx, scope: *Scope) ParseError!Node {
57545763}
57555764
57565765fn parseCAbstractDeclarator(c: *Context, m: *MacroCtx, scope: *Scope, node: Node) ParseError!Node {
5766 _ = scope;
57575767 switch (m.next().?) {
57585768 .Asterisk => {
57595769 // last token of `node`
src/type.zig+3
......@@ -600,9 +600,11 @@ pub const Type = extern union {
600600
601601 pub const HashContext = struct {
602602 pub fn hash(self: @This(), t: Type) u64 {
603 _ = self;
603604 return t.hash();
604605 }
605606 pub fn eql(self: @This(), a: Type, b: Type) bool {
607 _ = self;
606608 return a.eql(b);
607609 }
608610 };
......@@ -777,6 +779,7 @@ pub const Type = extern union {
777779 options: std.fmt.FormatOptions,
778780 writer: anytype,
779781 ) @TypeOf(writer).Error!void {
782 _ = options;
780783 comptime assert(fmt.len == 0);
781784 var ty = start_type;
782785 while (true) {
src/value.zig+8
......@@ -626,6 +626,7 @@ pub const Value = extern union {
626626 return std.mem.dupe(allocator, u8, payload.data);
627627 }
628628 if (self.castTag(.repeated)) |payload| {
629 _ = payload;
629630 @panic("TODO implement toAllocatedBytes for this Value tag");
630631 }
631632 if (self.castTag(.decl_ref)) |payload| {
......@@ -747,6 +748,7 @@ pub const Value = extern union {
747748
748749 /// Asserts the type is an enum type.
749750 pub fn toEnum(val: Value, enum_ty: Type, comptime E: type) E {
751 _ = enum_ty;
750752 // TODO this needs to resolve other kinds of Value tags rather than
751753 // assuming the tag will be .enum_field_index.
752754 const field_index = val.castTag(.enum_field_index).?.data;
......@@ -935,6 +937,7 @@ pub const Value = extern union {
935937 /// Converts an integer or a float to a float.
936938 /// Returns `error.Overflow` if the value does not fit in the new type.
937939 pub fn floatCast(self: Value, allocator: *Allocator, ty: Type, target: Target) !Value {
940 _ = target;
938941 switch (ty.tag()) {
939942 .f16 => {
940943 @panic("TODO add __trunctfhf2 to compiler-rt");
......@@ -1292,17 +1295,21 @@ pub const Value = extern union {
12921295
12931296 pub const ArrayHashContext = struct {
12941297 pub fn hash(self: @This(), v: Value) u32 {
1298 _ = self;
12951299 return v.hash_u32();
12961300 }
12971301 pub fn eql(self: @This(), a: Value, b: Value) bool {
1302 _ = self;
12981303 return a.eql(b);
12991304 }
13001305 };
13011306 pub const HashContext = struct {
13021307 pub fn hash(self: @This(), v: Value) u64 {
1308 _ = self;
13031309 return v.hash();
13041310 }
13051311 pub fn eql(self: @This(), a: Value, b: Value) bool {
1312 _ = self;
13061313 return a.eql(b);
13071314 }
13081315 };
......@@ -1345,6 +1352,7 @@ pub const Value = extern union {
13451352 }
13461353
13471354 pub fn fieldValue(val: Value, allocator: *Allocator, index: usize) error{OutOfMemory}!Value {
1355 _ = allocator;
13481356 switch (val.tag()) {
13491357 .@"struct" => {
13501358 const field_values = val.castTag(.@"struct").?.data;
test/behavior/align.zig+1
......@@ -167,6 +167,7 @@ test "generic function with align param" {
167167}
168168
169169fn whyWouldYouEverDoThis(comptime align_bytes: u8) align(align_bytes) u8 {
170 _ = align_bytes;
170171 return 0x1;
171172}
172173
test/behavior/async_fn.zig+10
......@@ -133,6 +133,7 @@ test "@frameSize" {
133133 other(1);
134134 }
135135 fn other(param: i32) void {
136 _ = param;
136137 var local: i32 = undefined;
137138 _ = local;
138139 suspend {}
......@@ -635,6 +636,8 @@ test "returning a const error from async function" {
635636 }
636637
637638 fn fetchUrl(unused: i32, url: []const u8) ![]u8 {
639 _ = unused;
640 _ = url;
638641 frame = @frame();
639642 suspend {}
640643 ok = true;
......@@ -711,6 +714,7 @@ fn testAsyncAwaitTypicalUsage(
711714
712715 var global_download_frame: anyframe = undefined;
713716 fn fetchUrl(allocator: *std.mem.Allocator, url: []const u8) anyerror![]u8 {
717 _ = url;
714718 const result = try std.mem.dupe(allocator, u8, "expected download text");
715719 errdefer allocator.free(result);
716720 if (suspend_download) {
......@@ -724,6 +728,7 @@ fn testAsyncAwaitTypicalUsage(
724728
725729 var global_file_frame: anyframe = undefined;
726730 fn readFile(allocator: *std.mem.Allocator, filename: []const u8) anyerror![]u8 {
731 _ = filename;
727732 const result = try std.mem.dupe(allocator, u8, "expected file text");
728733 errdefer allocator.free(result);
729734 if (suspend_file) {
......@@ -1226,6 +1231,7 @@ test "suspend in while loop" {
12261231 suspend {}
12271232 return val;
12281233 } else |err| {
1234 err catch {};
12291235 return 0;
12301236 }
12311237 }
......@@ -1355,6 +1361,7 @@ test "async function passed 0-bit arg after non-0-bit arg" {
13551361 }
13561362
13571363 fn bar(x: i32, args: anytype) anyerror!void {
1364 _ = args;
13581365 global_frame = @frame();
13591366 suspend {}
13601367 global_int = x;
......@@ -1650,6 +1657,8 @@ test "@asyncCall with pass-by-value arguments" {
16501657 pub const AT = [5]u8;
16511658
16521659 pub fn f(_fill0: u64, s: ST, _fill1: u64, a: AT, _fill2: u64) callconv(.Async) void {
1660 _ = s;
1661 _ = a;
16531662 // Check that the array and struct arguments passed by value don't
16541663 // end up overflowing the adjacent fields in the frame structure.
16551664 expectEqual(F0, _fill0) catch @panic("test failure");
......@@ -1677,6 +1686,7 @@ test "@asyncCall with arguments having non-standard alignment" {
16771686
16781687 const S = struct {
16791688 pub fn f(_fill0: u32, s: struct { x: u64 align(16) }, _fill1: u64) callconv(.Async) void {
1689 _ = s;
16801690 // The compiler inserts extra alignment for s, check that the
16811691 // generated code picks the right slot for fill1.
16821692 expectEqual(F0, _fill0) catch @panic("test failure");
test/behavior/bugs/1310.zig+2
......@@ -16,6 +16,8 @@ pub const InvocationTable_ = struct_InvocationTable_;
1616pub const VM_ = struct_VM_;
1717
1818fn agent_callback(_vm: [*]VM, options: [*]u8) callconv(.C) i32 {
19 _ = _vm;
20 _ = options;
1921 return 11;
2022}
2123
test/behavior/bugs/2578.zig+3-1
......@@ -5,7 +5,9 @@ const Foo = struct {
55var foo: Foo = undefined;
66const t = &foo;
77
8fn bar(pointer: ?*c_void) void {}
8fn bar(pointer: ?*c_void) void {
9 _ = pointer;
10}
911
1012test "fixed" {
1113 bar(t);
test/behavior/bugs/2692.zig+3-1
......@@ -1,4 +1,6 @@
1fn foo(a: []u8) void {}
1fn foo(a: []u8) void {
2 _ = a;
3}
24
35test "address of 0 length array" {
46 var pt: [0]u8 = undefined;
test/behavior/bugs/3367.zig+3-1
......@@ -3,7 +3,9 @@ const Foo = struct {
33};
44
55const Mixin = struct {
6 pub fn two(self: Foo) void {}
6 pub fn two(self: Foo) void {
7 _ = self;
8 }
79};
810
911test "container member access usingnamespace decls" {
test/behavior/bugs/4328.zig+2
......@@ -53,10 +53,12 @@ test "Peer resolution of extern function calls in @TypeOf" {
5353test "Extern function calls, dereferences and field access in @TypeOf" {
5454 const Test = struct {
5555 fn test_fn_1(a: c_long) @TypeOf(fopen("test", "r").*) {
56 _ = a;
5657 return .{ .dummy_field = 0 };
5758 }
5859
5960 fn test_fn_2(a: anytype) @TypeOf(fopen("test", "r").*.dummy_field) {
61 _ = a;
6062 return 255;
6163 }
6264
test/behavior/bugs/4560.zig+4
......@@ -25,6 +25,10 @@ pub fn StringHashMap(comptime V: type) type {
2525}
2626
2727pub fn HashMap(comptime K: type, comptime V: type) type {
28 if (false) {
29 K;
30 V;
31 }
2832 return struct {
2933 size: usize,
3034 max_distance_from_start_index: usize,
test/behavior/bugs/529_other_file_2.zig+3-1
......@@ -1,4 +1,6 @@
11pub const A = extern struct {
22 field: c_int,
33};
4export fn issue529(a: ?*A) void {}
4export fn issue529(a: ?*A) void {
5 _ = a;
6}
test/behavior/bugs/5487.zig+1
......@@ -1,6 +1,7 @@
11const io = @import("std").io;
22
33pub fn write(_: void, bytes: []const u8) !usize {
4 _ = bytes;
45 return 0;
56}
67pub fn writer() io.Writer(void, @typeInfo(@typeInfo(@TypeOf(write)).Fn.return_type.?).ErrorUnion.error_set, write) {
test/behavior/bugs/624.zig+1
......@@ -12,6 +12,7 @@ const ListenerContext = struct {
1212const ContextAllocator = MemoryPool(TestContext);
1313
1414fn MemoryPool(comptime T: type) type {
15 _ = T;
1516 return struct {
1617 n: usize,
1718 };
test/behavior/bugs/679.zig+1
......@@ -2,6 +2,7 @@ const std = @import("std");
22const expect = std.testing.expect;
33
44pub fn List(comptime T: type) type {
5 _ = T;
56 return u32;
67}
78
test/behavior/bugs/7027.zig+3-1
......@@ -9,7 +9,9 @@ const Foobar = struct {
99 }
1010};
1111
12fn foo(arg: anytype) void {}
12fn foo(arg: anytype) void {
13 _ = arg;
14}
1315
1416test "" {
1517 comptime var foobar = Foobar.foo();
test/behavior/bugs/704.zig+3-1
......@@ -1,5 +1,7 @@
11const xxx = struct {
2 pub fn bar(self: *xxx) void {}
2 pub fn bar(self: *xxx) void {
3 _ = self;
4 }
35};
46test "bug 704" {
57 var x: xxx = undefined;
test/behavior/bugs/7250.zig+3-1
......@@ -3,7 +3,9 @@ const nrfx_uart_t = extern struct {
33 drv_inst_idx: u8,
44};
55
6pub fn nrfx_uart_rx(p_instance: [*c]const nrfx_uart_t) void {}
6pub fn nrfx_uart_rx(p_instance: [*c]const nrfx_uart_t) void {
7 _ = p_instance;
8}
79
810threadlocal var g_uart0 = nrfx_uart_t{
911 .p_reg = 0,
test/behavior/bugs/828.zig+2
......@@ -4,6 +4,7 @@ const CountBy = struct {
44 const One = CountBy{ .a = 1 };
55
66 pub fn counter(self: *const CountBy) Counter {
7 _ = self;
78 return Counter{ .i = 0 };
89 }
910};
......@@ -18,6 +19,7 @@ const Counter = struct {
1819};
1920
2021fn constCount(comptime cb: *const CountBy, comptime unused: u32) void {
22 _ = unused;
2123 comptime {
2224 var cnt = cb.counter();
2325 if (cnt.i != 0) @compileError("Counter instance reused!");
test/behavior/bugs/920.zig+2
......@@ -46,6 +46,8 @@ fn norm_f_inv(y: f64) f64 {
4646 return math.sqrt(-2.0 * math.ln(y));
4747}
4848fn norm_zero_case(random: *Random, u: f64) f64 {
49 _ = random;
50 _ = u;
4951 return 0.0;
5052}
5153
test/behavior/cast.zig+6-2
......@@ -824,9 +824,13 @@ test "variable initialization uses result locations properly with regards to the
824824test "cast between [*c]T and ?[*:0]T on fn parameter" {
825825 const S = struct {
826826 const Handler = ?fn ([*c]const u8) callconv(.C) void;
827 fn addCallback(handler: Handler) void {}
827 fn addCallback(handler: Handler) void {
828 _ = handler;
829 }
828830
829 fn myCallback(cstr: ?[*:0]const u8) callconv(.C) void {}
831 fn myCallback(cstr: ?[*:0]const u8) callconv(.C) void {
832 _ = cstr;
833 }
830834
831835 fn doTheTest() void {
832836 addCallback(myCallback);
test/behavior/error.zig+8-2
......@@ -139,7 +139,10 @@ test "comptime test error for empty error set" {
139139const EmptyErrorSet = error{};
140140
141141fn testComptimeTestErrorEmptySet(x: EmptyErrorSet!i32) !void {
142 if (x) |v| try expect(v == 1234) else |err| @compileError("bad");
142 if (x) |v| try expect(v == 1234) else |err| {
143 _ = err;
144 @compileError("bad");
145 }
143146}
144147
145148test "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
394397 const Err = error{UnspecifiedErr};
395398
396399 fn bar(a: i32) anyerror!*Foo {
400 _ = a;
397401 return Err.UnspecifiedErr;
398402 }
399403
......@@ -448,7 +452,9 @@ test "error payload type is correctly resolved" {
448452
449453test "error union comptime caching" {
450454 const S = struct {
451 fn foo(comptime arg: anytype) void {}
455 fn foo(comptime arg: anytype) void {
456 arg catch {};
457 }
452458 };
453459
454460 S.foo(@as(anyerror!void, {}));
test/behavior/eval.zig+7-2
......@@ -422,6 +422,7 @@ test {
422422}
423423
424424pub fn TypeWithCompTimeSlice(comptime field_name: []const u8) type {
425 _ = field_name;
425426 return struct {
426427 pub const Node = struct {};
427428 };
......@@ -698,7 +699,9 @@ test "refer to the type of a generic function" {
698699 f(i32);
699700}
700701
701fn doNothingWithType(comptime T: type) void {}
702fn doNothingWithType(comptime T: type) void {
703 _ = T;
704}
702705
703706test "zero extend from u0 to u1" {
704707 var zero_u0: u0 = 0;
......@@ -819,7 +822,9 @@ test "two comptime calls with array default initialized to undefined" {
819822 result.getCpuArch();
820823 }
821824
822 pub fn getCpuArch(self: CrossTarget) void {}
825 pub fn getCpuArch(self: CrossTarget) void {
826 _ = self;
827 }
823828 };
824829
825830 const DynamicLinker = struct {
test/behavior/fn.zig+8-2
......@@ -23,6 +23,7 @@ test "void parameters" {
2323 try voidFun(1, void{}, 2, {});
2424}
2525fn voidFun(a: i32, b: void, c: i32, d: void) !void {
26 _ = d;
2627 const v = b;
2728 const vv: void = if (a == 1) v else {};
2829 try expect(a + c == 3);
......@@ -57,7 +58,9 @@ test "call function with empty string" {
5758 acceptsString("");
5859}
5960
60fn acceptsString(foo: []u8) void {}
61fn acceptsString(foo: []u8) void {
62 _ = foo;
63}
6164
6265fn @"weird function name"() i32 {
6366 return 1234;
......@@ -70,7 +73,9 @@ test "implicit cast function unreachable return" {
7073 wantsFnWithVoid(fnWithUnreachable);
7174}
7275
73fn wantsFnWithVoid(f: fn () void) void {}
76fn wantsFnWithVoid(f: fn () void) void {
77 _ = f;
78}
7479
7580fn fnWithUnreachable() noreturn {
7681 unreachable;
......@@ -162,6 +167,7 @@ const Point3 = struct {
162167 y: i32,
163168
164169 fn addPointCoords(self: Point3, comptime T: type) i32 {
170 _ = T;
165171 return self.x + self.y;
166172 }
167173};
test/behavior/for.zig+11-3
......@@ -29,10 +29,14 @@ test "for loop with pointer elem var" {
2929 mangleString(target[0..]);
3030 try expect(mem.eql(u8, &target, "bcdefgh"));
3131
32 for (source) |*c, i|
32 for (source) |*c, i| {
33 _ = i;
3334 try expect(@TypeOf(c) == *const u8);
34 for (target) |*c, i|
35 }
36 for (target) |*c, i| {
37 _ = i;
3538 try expect(@TypeOf(c) == *u8);
39 }
3640}
3741
3842fn mangleString(s: []u8) void {
......@@ -53,6 +57,7 @@ test "basic for loop" {
5357 buf_index += 1;
5458 }
5559 for (array) |item, index| {
60 _ = item;
5661 buffer[buf_index] = @intCast(u8, index);
5762 buf_index += 1;
5863 }
......@@ -62,6 +67,7 @@ test "basic for loop" {
6267 buf_index += 1;
6368 }
6469 for (array_ptr) |item, index| {
70 _ = item;
6571 buffer[buf_index] = @intCast(u8, index);
6672 buf_index += 1;
6773 }
......@@ -70,7 +76,7 @@ test "basic for loop" {
7076 buffer[buf_index] = item;
7177 buf_index += 1;
7278 }
73 for (unknown_size) |item, index| {
79 for (unknown_size) |_, index| {
7480 buffer[buf_index] = @intCast(u8, index);
7581 buf_index += 1;
7682 }
......@@ -118,6 +124,7 @@ test "2 break statements and an else" {
118124 var buf: [10]u8 = undefined;
119125 var ok = false;
120126 ok = for (buf) |item| {
127 _ = item;
121128 if (f) break false;
122129 if (t) break true;
123130 } else false;
......@@ -136,6 +143,7 @@ test "for with null and T peer types and inferred result location type" {
136143 break item;
137144 }
138145 } else null) |v| {
146 _ = v;
139147 @panic("fail");
140148 }
141149 }
test/behavior/if.zig+1-1
......@@ -45,7 +45,7 @@ var global_with_err: anyerror!u32 = error.SomeError;
4545test "unwrap mutable global var" {
4646 if (global_with_val) |v| {
4747 try expect(v == 0);
48 } else |e| {
48 } else |_| {
4949 unreachable;
5050 }
5151 if (global_with_err) |_| {
test/behavior/misc.zig+17-4
......@@ -245,14 +245,18 @@ var some_mem: [100]u8 = undefined;
245245fn memAlloc(comptime T: type, n: usize) anyerror![]T {
246246 return @ptrCast([*]T, &some_mem[0])[0..n];
247247}
248fn memFree(comptime T: type, memory: []T) void {}
248fn memFree(comptime T: type, memory: []T) void {
249 _ = memory;
250}
249251
250252test "cast undefined" {
251253 const array: [100]u8 = undefined;
252254 const slice = @as([]const u8, &array);
253255 testCastUndefined(slice);
254256}
255fn testCastUndefined(x: []const u8) void {}
257fn testCastUndefined(x: []const u8) void {
258 _ = x;
259}
256260
257261test "cast small unsigned to larger signed" {
258262 try expect(castSmallUnsignedToLargerSigned1(200) == @as(i16, 200));
......@@ -452,6 +456,7 @@ test "@typeName" {
452456}
453457
454458fn TypeFromFn(comptime T: type) type {
459 _ = T;
455460 return struct {};
456461}
457462
......@@ -555,7 +560,12 @@ test "packed struct, enum, union parameters in extern function" {
555560 }), &(PackedUnion{ .a = 1 }));
556561}
557562
558export fn testPackedStuff(a: *const PackedStruct, b: *const PackedUnion) void {}
563export fn testPackedStuff(a: *const PackedStruct, b: *const PackedUnion) void {
564 if (false) {
565 a;
566 b;
567 }
568}
559569
560570test "slicing zero length array" {
561571 const s1 = ""[0..];
......@@ -584,6 +594,7 @@ test "self reference through fn ptr field" {
584594 };
585595
586596 fn foo(a: A) u8 {
597 _ = a;
587598 return 12;
588599 }
589600 };
......@@ -753,7 +764,9 @@ test "extern variable with non-pointer opaque type" {
753764
754765test "lazy typeInfo value as generic parameter" {
755766 const S = struct {
756 fn foo(args: anytype) void {}
767 fn foo(args: anytype) void {
768 _ = args;
769 }
757770 };
758771 S.foo(@typeInfo(@TypeOf(.{})));
759772}
test/behavior/null.zig+1
......@@ -130,6 +130,7 @@ var struct_with_optional: StructWithOptional = undefined;
130130test "unwrap optional which is field of global var" {
131131 struct_with_optional.field = null;
132132 if (struct_with_optional.field) |payload| {
133 _ = payload;
133134 unreachable;
134135 }
135136 struct_with_optional.field = 1234;
test/behavior/optional.zig+1
......@@ -161,6 +161,7 @@ test "self-referential struct through a slice of optional" {
161161test "assigning to an unwrapped optional field in an inline loop" {
162162 comptime var maybe_pos_arg: ?comptime_int = null;
163163 inline for ("ab") |x| {
164 _ = x;
164165 maybe_pos_arg = 0;
165166 if (maybe_pos_arg.? != 0) {
166167 @compileError("bad");
test/behavior/pointers.zig+5-1
......@@ -179,6 +179,7 @@ test "assign null directly to C pointer and test null equality" {
179179 try expect(!(x != null));
180180 try expect(!(null != x));
181181 if (x) |same_x| {
182 _ = same_x;
182183 @panic("fail");
183184 }
184185 var otherx: i32 = undefined;
......@@ -189,7 +190,10 @@ test "assign null directly to C pointer and test null equality" {
189190 comptime try expect(null == y);
190191 comptime try expect(!(y != null));
191192 comptime try expect(!(null != y));
192 if (y) |same_y| @panic("fail");
193 if (y) |same_y| {
194 _ = same_y;
195 @panic("fail");
196 }
193197 const othery: i32 = undefined;
194198 comptime try expect((y orelse &othery) == &othery);
195199
test/behavior/reflection.zig+5
......@@ -15,6 +15,11 @@ test "reflection: function return type, var args, and param types" {
1515}
1616
1717fn dummy(a: bool, b: i32, c: f32) i32 {
18 if (false) {
19 a;
20 b;
21 c;
22 }
1823 return 1234;
1924}
2025
test/behavior/struct.zig+5
......@@ -182,6 +182,7 @@ test "empty struct method call" {
182182}
183183const EmptyStruct = struct {
184184 fn method(es: *const EmptyStruct) i32 {
185 _ = es;
185186 return 1234;
186187 }
187188};
......@@ -452,9 +453,11 @@ fn alloc(comptime T: type) []T {
452453test "call method with mutable reference to struct with no fields" {
453454 const S = struct {
454455 fn doC(s: *const @This()) bool {
456 _ = s;
455457 return true;
456458 }
457459 fn do(s: *@This()) bool {
460 _ = s;
458461 return true;
459462 }
460463 };
......@@ -625,11 +628,13 @@ test "for loop over pointers to struct, getting field from struct pointer" {
625628 var ok = true;
626629
627630 fn eql(a: []const u8) bool {
631 _ = a;
628632 return true;
629633 }
630634
631635 const ArrayList = struct {
632636 fn toSlice(self: *ArrayList) []*Foo {
637 _ = self;
633638 return @as([*]*Foo, undefined)[0..0];
634639 }
635640 };
test/behavior/switch.zig+13-3
......@@ -386,6 +386,7 @@ test "switch with null and T peer types and inferred result location type" {
386386 0 => true,
387387 else => null,
388388 }) |v| {
389 _ = v;
389390 @panic("fail");
390391 }
391392 }
......@@ -411,12 +412,18 @@ test "switch prongs with cases with identical payload types" {
411412 try expect(@TypeOf(e) == usize);
412413 try expect(e == 8);
413414 },
414 .B => |e| @panic("fail"),
415 .B => |e| {
416 _ = e;
417 @panic("fail");
418 },
415419 }
416420 }
417421 fn doTheSwitch2(u: Union) !void {
418422 switch (u) {
419 .A, .C => |e| @panic("fail"),
423 .A, .C => |e| {
424 _ = e;
425 @panic("fail");
426 },
420427 .B => |e| {
421428 try expect(@TypeOf(e) == isize);
422429 try expect(e == -8);
......@@ -508,7 +515,10 @@ test "switch on error set with single else" {
508515 fn doTheTest() !void {
509516 var some: error{Foo} = error.Foo;
510517 try expect(switch (some) {
511 else => |a| true,
518 else => |a| blk: {
519 a catch {};
520 break :blk true;
521 },
512522 });
513523 }
514524 };
test/behavior/type.zig+7-1
......@@ -431,6 +431,10 @@ test "Type.Fn" {
431431
432432 const foo = struct {
433433 fn func(a: usize, b: bool) align(4) callconv(.C) usize {
434 if (false) {
435 a;
436 b;
437 }
434438 return 0;
435439 }
436440 }.func;
......@@ -444,7 +448,9 @@ test "Type.BoundFn" {
444448 if (builtin.target.cpu.arch == .wasm32 or builtin.target.cpu.arch == .wasm64) return error.SkipZigTest;
445449
446450 const TestStruct = packed struct {
447 pub fn foo(self: *const @This()) align(4) callconv(.Unspecified) void {}
451 pub fn foo(self: *const @This()) align(4) callconv(.Unspecified) void {
452 _ = self;
453 }
448454 };
449455 const test_instance: TestStruct = undefined;
450456 try testing.expect(std.meta.eql(
test/behavior/type_info.zig+7-2
......@@ -277,7 +277,9 @@ const TestStruct = packed struct {
277277 fieldC: *Self,
278278 fieldD: u32 = 4,
279279
280 pub fn foo(self: *const Self) void {}
280 pub fn foo(self: *const Self) void {
281 _ = self;
282 }
281283 const Self = @This();
282284};
283285
......@@ -326,7 +328,9 @@ extern fn fooAligned(a: usize, b: bool, ...) align(4) callconv(.C) usize;
326328
327329test "typeInfo with comptime parameter in struct fn def" {
328330 const S = struct {
329 pub fn func(comptime x: f32) void {}
331 pub fn func(comptime x: f32) void {
332 _ = x;
333 }
330334 };
331335 comptime var info = @typeInfo(S);
332336 _ = info;
......@@ -369,6 +373,7 @@ test "type info: pass to function" {
369373}
370374
371375fn passTypeInfo(comptime info: TypeInfo) type {
376 _ = info;
372377 return void;
373378}
374379
test/behavior/underscore.zig+2
......@@ -7,7 +7,9 @@ test "ignore lval with underscore" {
77
88test "ignore lval with underscore (for loop)" {
99 for ([_]void{}) |_, i| {
10 _ = i;
1011 for ([_]void{}) |_, j| {
12 _ = j;
1113 break;
1214 }
1315 break;
test/behavior/union.zig+8-2
......@@ -374,7 +374,9 @@ const Attribute = union(enum) {
374374 B: u8,
375375};
376376
377fn setAttribute(attr: Attribute) void {}
377fn setAttribute(attr: Attribute) void {
378 _ = attr;
379}
378380
379381fn Setter(attr: Attribute) type {
380382 return struct {
......@@ -465,7 +467,9 @@ test "union no tag with struct member" {
465467 const Struct = struct {};
466468 const Union = union {
467469 s: Struct,
468 pub fn foo(self: *@This()) void {}
470 pub fn foo(self: *@This()) void {
471 _ = self;
472 }
469473 };
470474 var u = Union{ .s = Struct{} };
471475 u.foo();
......@@ -703,6 +707,7 @@ test "method call on an empty union" {
703707 X2: [0]u8,
704708
705709 pub fn useIt(self: *@This()) bool {
710 _ = self;
706711 return true;
707712 }
708713 };
......@@ -771,6 +776,7 @@ test "@unionInit on union w/ tag but no fields" {
771776 no_op: void,
772777
773778 pub fn decode(buf: []const u8) Data {
779 _ = buf;
774780 return @unionInit(Data, "no_op", {});
775781 }
776782 };
test/behavior/var_args.zig+3
......@@ -48,6 +48,7 @@ test "runtime parameter before var args" {
4848}
4949
5050fn extraFn(extra: u32, args: anytype) !usize {
51 _ = extra;
5152 if (args.len >= 1) {
5253 try expect(args[0] == false);
5354 }
......@@ -63,9 +64,11 @@ const foos = [_]fn (anytype) bool{
6364};
6465
6566fn foo1(args: anytype) bool {
67 _ = args;
6668 return true;
6769}
6870fn foo2(args: anytype) bool {
71 _ = args;
6972 return false;
7073}
7174
test/behavior/while.zig+2-2
......@@ -151,14 +151,14 @@ test "while on optional with else result follow break prong" {
151151test "while on error union with else result follow else prong" {
152152 const result = while (returnError()) |value| {
153153 break value;
154 } else |err| @as(i32, 2);
154 } else |_| @as(i32, 2);
155155 try expect(result == 2);
156156}
157157
158158test "while on error union with else result follow break prong" {
159159 const result = while (returnSuccess(10)) |value| {
160160 break value;
161 } else |err| @as(i32, 2);
161 } else |_| @as(i32, 2);
162162 try expect(result == 10);
163163}
164164
test/stage2/cbe.zig+10-6
......@@ -823,31 +823,35 @@ pub fn addCases(ctx: *TestContext) !void {
823823 \\
824824 );
825825 ctx.h("header with single param function", linux_x64,
826 \\export fn start(a: u8) void{}
826 \\export fn start(a: u8) void{
827 \\ _ = a;
828 \\}
827829 ,
828830 \\ZIG_EXTERN_C void start(uint8_t a0);
829831 \\
830832 );
831833 ctx.h("header with multiple param function", linux_x64,
832 \\export fn start(a: u8, b: u8, c: u8) void{}
834 \\export fn start(a: u8, b: u8, c: u8) void{
835 \\ _ = a; _ = b; _ = c;
836 \\}
833837 ,
834838 \\ZIG_EXTERN_C void start(uint8_t a0, uint8_t a1, uint8_t a2);
835839 \\
836840 );
837841 ctx.h("header with u32 param function", linux_x64,
838 \\export fn start(a: u32) void{}
842 \\export fn start(a: u32) void{ _ = a; }
839843 ,
840844 \\ZIG_EXTERN_C void start(uint32_t a0);
841845 \\
842846 );
843847 ctx.h("header with usize param function", linux_x64,
844 \\export fn start(a: usize) void{}
848 \\export fn start(a: usize) void{ _ = a; }
845849 ,
846850 \\ZIG_EXTERN_C void start(uintptr_t a0);
847851 \\
848852 );
849853 ctx.h("header with bool param function", linux_x64,
850 \\export fn start(a: bool) void{}
854 \\export fn start(a: bool) void{_ = a;}
851855 ,
852856 \\ZIG_EXTERN_C void start(bool a0);
853857 \\
......@@ -871,7 +875,7 @@ pub fn addCases(ctx: *TestContext) !void {
871875 \\
872876 );
873877 ctx.h("header with multiple includes", linux_x64,
874 \\export fn start(a: u32, b: usize) void{}
878 \\export fn start(a: u32, b: usize) void{ _ = a; _ = b; }
875879 ,
876880 \\ZIG_EXTERN_C void start(uint32_t a0, uintptr_t a1);
877881 \\
test/stage2/test.zig+3-1
......@@ -1392,7 +1392,9 @@ pub fn addCases(ctx: *TestContext) !void {
13921392 \\pub fn main() void {
13931393 \\ doNothing(0);
13941394 \\}
1395 \\fn doNothing(arg: u0) void {}
1395 \\fn doNothing(arg: u0) void {
1396 \\ _ = arg;
1397 \\}
13961398 ,
13971399 "",
13981400 );
test/stage2/wasm.zig+2-1
......@@ -64,7 +64,7 @@ pub fn addCases(ctx: *TestContext) !void {
6464 \\ foo(10, 20);
6565 \\ return 5;
6666 \\}
67 \\fn foo(x: u32, y: u32) void {}
67 \\fn foo(x: u32, y: u32) void { _ = x; _ = y; }
6868 , "5\n");
6969 }
7070
......@@ -95,6 +95,7 @@ pub fn addCases(ctx: *TestContext) !void {
9595 \\ return i;
9696 \\}
9797 \\fn foo(x: u32, y: u32) void {
98 \\ _ = y;
9899 \\ var i: u32 = 10;
99100 \\ i = x;
100101 \\}
test/standalone/hello_world/hello_libc.zig+2
......@@ -8,6 +8,8 @@ const c = @cImport({
88const msg = "Hello, world!\n";
99
1010pub export fn main(argc: c_int, argv: **u8) c_int {
11 _ = argv;
12 _ = argc;
1113 if (c.printf(msg) != @intCast(c_int, c.strlen(msg))) return -1;
1214 return 0;
1315}
test/standalone/issue_339/test.zig+2
......@@ -1,5 +1,7 @@
11const StackTrace = @import("std").builtin.StackTrace;
22pub fn panic(msg: []const u8, stack_trace: ?*StackTrace) noreturn {
3 _ = msg;
4 _ = stack_trace;
35 @breakpoint();
46 while (true) {}
57}
test/standalone/issue_8550/main.zig+3-1
......@@ -1,6 +1,8 @@
1export fn main(r0: u32, r1: u32, atags: u32) callconv(.C) noreturn {
1export fn main() callconv(.C) noreturn {
22 unreachable; // never gets run so it doesn't matter
33}
44pub fn panic(msg: []const u8, error_return_trace: ?*@import("std").builtin.StackTrace) noreturn {
5 _ = msg;
6 _ = error_return_trace;
57 while (true) {}
68}
test/tests.zig+2
......@@ -417,6 +417,8 @@ pub fn addStandaloneTests(b: *build.Builder, test_filter: ?[]const u8, modes: []
417417}
418418
419419pub fn addCliTests(b: *build.Builder, test_filter: ?[]const u8, modes: []const Mode) *build.Step {
420 _ = test_filter;
421 _ = modes;
420422 const step = b.step("test-cli", "Test the command line interface");
421423
422424 const exe = b.addExecutable("test-cli", "test/cli.zig");
tools/process_headers.zig+3
......@@ -236,12 +236,14 @@ const DestTarget = struct {
236236
237237 const HashContext = struct {
238238 pub fn hash(self: @This(), a: DestTarget) u32 {
239 _ = self;
239240 return @enumToInt(a.arch) +%
240241 (@enumToInt(a.os) *% @as(u32, 4202347608)) +%
241242 (@enumToInt(a.abi) *% @as(u32, 4082223418));
242243 }
243244
244245 pub fn eql(self: @This(), a: DestTarget, b: DestTarget) bool {
246 _ = self;
245247 return a.arch.eql(b.arch) and
246248 a.os == b.os and
247249 a.abi == b.abi;
......@@ -256,6 +258,7 @@ const Contents = struct {
256258 is_generic: bool,
257259
258260 fn hitCountLessThan(context: void, lhs: *const Contents, rhs: *const Contents) bool {
261 _ = context;
259262 return lhs.hit_count < rhs.hit_count;
260263 }
261264};
tools/update_clang_options.zig+3
......@@ -585,6 +585,8 @@ const Syntax = union(enum) {
585585 options: std.fmt.FormatOptions,
586586 out_stream: anytype,
587587 ) !void {
588 _ = fmt;
589 _ = options;
588590 switch (self) {
589591 .multi_arg => |n| return out_stream.print(".{{.{s}={}}}", .{ @tagName(self), n }),
590592 else => return out_stream.print(".{s}", .{@tagName(self)}),
......@@ -663,6 +665,7 @@ fn syntaxMatchesWithEql(syntax: Syntax) bool {
663665}
664666
665667fn objectLessThan(context: void, a: *json.ObjectMap, b: *json.ObjectMap) bool {
668 _ = context;
666669 // Priority is determined by exact matches first, followed by prefix matches in descending
667670 // length, with key as a final tiebreaker.
668671 const a_syntax = objSyntax(a);
tools/update_cpu_features.zig+3
......@@ -1227,14 +1227,17 @@ fn usageAndExit(file: fs.File, arg0: []const u8, code: u8) noreturn {
12271227}
12281228
12291229fn featureLessThan(context: void, a: Feature, b: Feature) bool {
1230 _ = context;
12301231 return std.ascii.lessThanIgnoreCase(a.zig_name, b.zig_name);
12311232}
12321233
12331234fn cpuLessThan(context: void, a: Cpu, b: Cpu) bool {
1235 _ = context;
12341236 return std.ascii.lessThanIgnoreCase(a.zig_name, b.zig_name);
12351237}
12361238
12371239fn asciiLessThan(context: void, a: []const u8, b: []const u8) bool {
1240 _ = context;
12381241 return std.ascii.lessThanIgnoreCase(a, b);
12391242}
12401243
tools/update_glibc.zig+5-3
......@@ -155,7 +155,7 @@ pub fn main() !void {
155155 }
156156 const fn_set = &target_funcs_gop.value_ptr.list;
157157
158 for (lib_names) |lib_name, lib_name_index| {
158 for (lib_names) |lib_name| {
159159 const lib_prefix = if (std.mem.eql(u8, lib_name, "ld")) "" else "lib";
160160 const basename = try fmt.allocPrint(allocator, "{s}{s}.abilist", .{ lib_prefix, lib_name });
161161 const abi_list_filename = blk: {
......@@ -263,7 +263,7 @@ pub fn main() !void {
263263
264264 // Now the mapping of version and function to integer index is complete.
265265 // Here we create a mapping of function name to list of versions.
266 for (abi_lists) |*abi_list, abi_index| {
266 for (abi_lists) |*abi_list| {
267267 const value = target_functions.getPtr(@ptrToInt(abi_list)).?;
268268 const fn_vers_list = &value.fn_vers_list;
269269 for (value.list.items) |*ver_fn| {
......@@ -286,7 +286,7 @@ pub fn main() !void {
286286 const abilist_txt = buffered.writer();
287287
288288 // first iterate over the abi lists
289 for (abi_lists) |*abi_list, abi_index| {
289 for (abi_lists) |*abi_list| {
290290 const fn_vers_list = &target_functions.getPtr(@ptrToInt(abi_list)).?.fn_vers_list;
291291 for (abi_list.targets) |target, it_i| {
292292 if (it_i != 0) try abilist_txt.writeByte(' ');
......@@ -312,10 +312,12 @@ pub fn main() !void {
312312}
313313
314314pub fn strCmpLessThan(context: void, a: []const u8, b: []const u8) bool {
315 _ = context;
315316 return std.mem.order(u8, a, b) == .lt;
316317}
317318
318319pub fn versionLessThan(context: void, a: []const u8, b: []const u8) bool {
320 _ = context;
319321 const sep_chars = "GLIBC_.";
320322 var a_tokens = std.mem.tokenize(a, sep_chars);
321323 var b_tokens = std.mem.tokenize(b, sep_chars);
tools/update_spirv_features.zig+1
......@@ -37,6 +37,7 @@ const Version = struct {
3737 }
3838
3939 fn lessThan(ctx: void, a: Version, b: Version) bool {
40 _ = ctx;
4041 return if (a.major == b.major)
4142 a.minor < b.minor
4243 else