authorgravatar for jacoblevgw@gmail.comJacob G-W <jacoblevgw@gmail.com> 2021-06-09 21:35:42-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-06-21 17:03:03-07:00
log641ecc260f43ffb2398acb80cbd141535dbbb03d
tree87455d3b460f517ad35bcda2b3a2e38599dd4aa1
parentd34a1ccb0ea75ba31f374b8b2d34e18326b147b1

std, src, doc, test: remove unused variables


112 files changed, 208 insertions(+), 294 deletions(-)

doc/docgen.zig-12
......@@ -1017,7 +1017,6 @@ fn tokenizeAndPrint(docgen_tokenizer: *Tokenizer, out: anytype, source_token: To
10171017}
10181018
10191019fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: anytype, zig_exe: []const u8, do_code_tests: bool) !void {
1020 var code_progress_index: usize = 0;
10211020 var progress = Progress{};
10221021 const root_node = try progress.start("Generating docgen examples", toc.nodes.len);
10231022 defer root_node.end();
......@@ -1090,7 +1089,6 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: any
10901089
10911090 switch (code.id) {
10921091 Code.Id.Exe => |expected_outcome| code_block: {
1093 const name_plus_bin_ext = try std.fmt.allocPrint(allocator, "{s}{s}", .{ code.name, exe_ext });
10941092 var build_args = std.ArrayList([]const u8).init(allocator);
10951093 defer build_args.deinit();
10961094 try build_args.appendSlice(&[_][]const u8{
......@@ -1361,19 +1359,9 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: any
13611359 },
13621360 Code.Id.Obj => |maybe_error_match| {
13631361 const name_plus_obj_ext = try std.fmt.allocPrint(allocator, "{s}{s}", .{ code.name, obj_ext });
1364 const tmp_obj_file_name = try fs.path.join(
1365 allocator,
1366 &[_][]const u8{ tmp_dir_name, name_plus_obj_ext },
1367 );
13681362 var build_args = std.ArrayList([]const u8).init(allocator);
13691363 defer build_args.deinit();
13701364
1371 const name_plus_h_ext = try std.fmt.allocPrint(allocator, "{s}.h", .{code.name});
1372 const output_h_file_name = try fs.path.join(
1373 allocator,
1374 &[_][]const u8{ tmp_dir_name, name_plus_h_ext },
1375 );
1376
13771365 try build_args.appendSlice(&[_][]const u8{
13781366 zig_exe,
13791367 "build-obj",
lib/std/Thread.zig+2-2
......@@ -518,8 +518,8 @@ pub fn cpuCount() CpuCountError!usize {
518518 },
519519 .haiku => {
520520 var count: u32 = undefined;
521 var system_info: os.system_info = undefined;
522 const rc = os.system.get_system_info(&system_info);
521 // var system_info: os.system_info = undefined;
522 // const rc = os.system.get_system_info(&system_info);
523523 count = system_info.cpu_count;
524524 return @intCast(usize, count);
525525 },
lib/std/base64.zig-5
......@@ -112,9 +112,6 @@ pub const Base64Encoder = struct {
112112 const out_len = encoder.calcSize(source.len);
113113 assert(dest.len >= out_len);
114114
115 const nibbles = source.len / 3;
116 const leftover = source.len - 3 * nibbles;
117
118115 var acc: u12 = 0;
119116 var acc_len: u4 = 0;
120117 var out_idx: usize = 0;
......@@ -223,7 +220,6 @@ pub const Base64Decoder = struct {
223220 if (decoder.pad_char) |pad_char| {
224221 const padding_len = acc_len / 2;
225222 var padding_chars: usize = 0;
226 var i: usize = 0;
227223 for (leftover) |c| {
228224 if (c != pad_char) {
229225 return if (c == Base64Decoder.invalid_char) error.InvalidCharacter else error.InvalidPadding;
......@@ -302,7 +298,6 @@ pub const Base64DecoderWithIgnore = struct {
302298 var leftover = source[leftover_idx.?..];
303299 if (decoder.pad_char) |pad_char| {
304300 var padding_chars: usize = 0;
305 var i: usize = 0;
306301 for (leftover) |c| {
307302 if (decoder_with_ignore.char_is_ignored[c]) continue;
308303 if (c != pad_char) {
lib/std/c/tokenizer.zig+6-7
......@@ -351,7 +351,6 @@ pub const Tokenizer = struct {
351351 pp_directive: bool = false,
352352
353353 pub fn next(self: *Tokenizer) Token {
354 const start_index = self.index;
355354 var result = Token{
356355 .id = .Eof,
357356 .start = self.index,
......@@ -1380,12 +1379,12 @@ test "operators" {
13801379
13811380test "keywords" {
13821381 try expectTokens(
1383 \\auto break case char const continue default do
1384 \\double else enum extern float for goto if int
1385 \\long register return short signed sizeof static
1386 \\struct switch typedef union unsigned void volatile
1387 \\while _Bool _Complex _Imaginary inline restrict _Alignas
1388 \\_Alignof _Atomic _Generic _Noreturn _Static_assert _Thread_local
1382 \\auto break case char const continue default do
1383 \\double else enum extern float for goto if int
1384 \\long register return short signed sizeof static
1385 \\struct switch typedef union unsigned void volatile
1386 \\while _Bool _Complex _Imaginary inline restrict _Alignas
1387 \\_Alignof _Atomic _Generic _Noreturn _Static_assert _Thread_local
13891388 \\
13901389 , &[_]Token.Id{
13911390 .Keyword_auto,
lib/std/compress/gzip.zig+2
......@@ -62,6 +62,8 @@ pub fn GzipStream(comptime ReaderType: type) type {
6262 const XFL = header[8];
6363 // Operating system where the compression took place
6464 const OS = header[9];
65 _ = XFL;
66 _ = OS;
6567
6668 if (FLG & FEXTRA != 0) {
6769 // Skip the extra data, we could read and expose it to the user
lib/std/compress/zlib.zig+1
......@@ -35,6 +35,7 @@ pub fn ZlibStream(comptime ReaderType: type) type {
3535 const CM = @truncate(u4, header[0]);
3636 const CINFO = @truncate(u4, header[0] >> 4);
3737 const FCHECK = @truncate(u5, header[1]);
38 _ = FCHECK;
3839 const FDICT = @truncate(u1, header[1] >> 5);
3940
4041 if ((@as(u16, header[0]) << 8 | header[1]) % 31 != 0)
lib/std/crypto/25519/scalar.zig-6
......@@ -330,13 +330,10 @@ pub const Scalar = struct {
330330 const carry9 = z02 >> 56;
331331 const c01 = carry9;
332332 const carry10 = (z12 + c01) >> 56;
333 const t21 = @truncate(u64, z12 + c01) & 0xffffffffffffff;
334333 const c11 = carry10;
335334 const carry11 = (z22 + c11) >> 56;
336 const t22 = @truncate(u64, z22 + c11) & 0xffffffffffffff;
337335 const c21 = carry11;
338336 const carry12 = (z32 + c21) >> 56;
339 const t23 = @truncate(u64, z32 + c21) & 0xffffffffffffff;
340337 const c31 = carry12;
341338 const carry13 = (z42 + c31) >> 56;
342339 const t24 = @truncate(u64, z42 + c31) & 0xffffffffffffff;
......@@ -605,13 +602,10 @@ const ScalarDouble = struct {
605602 const carry0 = z01 >> 56;
606603 const c00 = carry0;
607604 const carry1 = (z11 + c00) >> 56;
608 const t100 = @as(u64, @truncate(u64, z11 + c00)) & 0xffffffffffffff;
609605 const c10 = carry1;
610606 const carry2 = (z21 + c10) >> 56;
611 const t101 = @as(u64, @truncate(u64, z21 + c10)) & 0xffffffffffffff;
612607 const c20 = carry2;
613608 const carry3 = (z31 + c20) >> 56;
614 const t102 = @as(u64, @truncate(u64, z31 + c20)) & 0xffffffffffffff;
615609 const c30 = carry3;
616610 const carry4 = (z41 + c30) >> 56;
617611 const t103 = @as(u64, @truncate(u64, z41 + c30)) & 0xffffffffffffff;
lib/std/crypto/aes/soft.zig-8
......@@ -49,8 +49,6 @@ pub const Block = struct {
4949
5050 /// Encrypt a block with a round key.
5151 pub inline fn encrypt(block: Block, round_key: Block) Block {
52 const src = &block.repr;
53
5452 const s0 = block.repr[0];
5553 const s1 = block.repr[1];
5654 const s2 = block.repr[2];
......@@ -66,8 +64,6 @@ pub const Block = struct {
6664
6765 /// Encrypt a block with the last round key.
6866 pub inline fn encryptLast(block: Block, round_key: Block) Block {
69 const src = &block.repr;
70
7167 const t0 = block.repr[0];
7268 const t1 = block.repr[1];
7369 const t2 = block.repr[2];
......@@ -88,8 +84,6 @@ pub const Block = struct {
8884
8985 /// Decrypt a block with a round key.
9086 pub inline fn decrypt(block: Block, round_key: Block) Block {
91 const src = &block.repr;
92
9387 const s0 = block.repr[0];
9488 const s1 = block.repr[1];
9589 const s2 = block.repr[2];
......@@ -105,8 +99,6 @@ pub const Block = struct {
10599
106100 /// Decrypt a block with the last round key.
107101 pub inline fn decryptLast(block: Block, round_key: Block) Block {
108 const src = &block.repr;
109
110102 const t0 = block.repr[0];
111103 const t1 = block.repr[1];
112104 const t2 = block.repr[2];
lib/std/crypto/aes_gcm.zig-1
......@@ -114,7 +114,6 @@ test "Aes256Gcm - Empty message and no associated data" {
114114 const ad = "";
115115 const m = "";
116116 var c: [m.len]u8 = undefined;
117 var m2: [m.len]u8 = undefined;
118117 var tag: [Aes256Gcm.tag_length]u8 = undefined;
119118
120119 Aes256Gcm.encrypt(&c, &tag, m, ad, nonce, key);
lib/std/crypto/aes_ocb.zig-1
......@@ -271,7 +271,6 @@ test "AesOcb test vector 1" {
271271 var c: [0]u8 = undefined;
272272 Aes128Ocb.encrypt(&c, &tag, "", "", nonce, k);
273273
274 var expected_c: [c.len]u8 = undefined;
275274 var expected_tag: [tag.len]u8 = undefined;
276275 _ = try hexToBytes(&expected_tag, "785407BFFFC8AD9EDCC5520AC9111EE6");
277276
lib/std/crypto/bcrypt.zig-2
......@@ -48,7 +48,6 @@ const State = struct {
4848 fn expand0(state: *State, key: []const u8) void {
4949 var i: usize = 0;
5050 var j: usize = 0;
51 var t: u32 = undefined;
5251 while (i < state.subkeys.len) : (i += 1) {
5352 state.subkeys[i] ^= toWord(key, &j);
5453 }
......@@ -75,7 +74,6 @@ const State = struct {
7574 fn expand(state: *State, data: []const u8, key: []const u8) void {
7675 var i: usize = 0;
7776 var j: usize = 0;
78 var t: u32 = undefined;
7977 while (i < state.subkeys.len) : (i += 1) {
8078 state.subkeys[i] ^= toWord(key, &j);
8179 }
lib/std/crypto/chacha20.zig-1
......@@ -444,7 +444,6 @@ fn ChaChaWith64BitNonce(comptime rounds_nb: usize) type {
444444 if (comptime @sizeOf(usize) > 4) {
445445 // A big block is giant: 256 GiB, but we can avoid this limitation
446446 var remaining_blocks: u32 = @intCast(u32, (in.len / big_block));
447 var i: u32 = 0;
448447 while (remaining_blocks > 0) : (remaining_blocks -= 1) {
449448 ChaChaImpl(rounds_nb).chacha20Xor(out[cursor .. cursor + big_block], in[cursor .. cursor + big_block], k, c);
450449 c[1] += 1; // upper 32-bit of counter, generic chacha20Xor() doesn't know about this.
lib/std/dynamic_library.zig+1-1
......@@ -407,7 +407,7 @@ test "dynamic_library" {
407407 else => return error.SkipZigTest,
408408 };
409409
410 const dynlib = DynLib.open(libname) catch |err| {
410 _ = DynLib.open(libname) catch |err| {
411411 try testing.expect(err == error.FileNotFound);
412412 return;
413413 };
lib/std/event/channel.zig-1
......@@ -308,7 +308,6 @@ test "std.event.Channel wraparound" {
308308
309309 // add items to channel and pull them out until
310310 // the buffer wraps around, make sure it doesn't crash.
311 var result: i32 = undefined;
312311 channel.put(5);
313312 try testing.expectEqual(@as(i32, 5), channel.get());
314313 channel.put(6);
lib/std/event/group.zig+1-1
......@@ -130,7 +130,7 @@ test "std.event.Group" {
130130 // TODO this file has bit-rotted. repair it
131131 if (true) return error.SkipZigTest;
132132
133 const handle = async testGroup(std.heap.page_allocator);
133 _ = async testGroup(std.heap.page_allocator);
134134}
135135fn testGroup(allocator: *Allocator) callconv(.Async) void {
136136 var count: usize = 0;
lib/std/event/loop.zig+1-1
......@@ -680,7 +680,7 @@ pub const Loop = struct {
680680 fn run(func_args: Args, loop: *Loop, allocator: *mem.Allocator) void {
681681 loop.beginOneEvent();
682682 loop.yield();
683 const result = @call(.{}, func, func_args);
683 @call(.{}, func, func_args); // compile error when called with non-void ret type
684684 suspend {
685685 loop.finishOneEvent();
686686 allocator.destroy(@frame());
lib/std/event/rwlock.zig+1-1
......@@ -225,7 +225,7 @@ test "std.event.RwLock" {
225225 var lock = RwLock.init();
226226 defer lock.deinit();
227227
228 const handle = testLock(std.heap.page_allocator, &lock);
228 _ = testLock(std.heap.page_allocator, &lock);
229229
230230 const expected_result = [1]i32{shared_it_count * @intCast(i32, shared_test_data.len)} ** shared_test_data.len;
231231 try testing.expectEqualSlices(i32, expected_result, shared_test_data);
lib/std/fmt.zig+2-3
......@@ -1140,7 +1140,7 @@ pub fn formatFloatHexadecimal(
11401140
11411141 // +1 for the decimal part.
11421142 var buf: [1 + mantissa_digits]u8 = undefined;
1143 const N = formatIntBuf(&buf, mantissa, 16, .lower, .{ .fill = '0', .width = 1 + mantissa_digits });
1143 _ = formatIntBuf(&buf, mantissa, 16, .lower, .{ .fill = '0', .width = 1 + mantissa_digits });
11441144
11451145 try writer.writeAll("0x");
11461146 try writer.writeByte(buf[0]);
......@@ -2162,7 +2162,6 @@ test "custom" {
21622162 }
21632163 };
21642164
2165 var buf1: [32]u8 = undefined;
21662165 var value = Vec2{
21672166 .x = 10.2,
21682167 .y = 2.22,
......@@ -2220,7 +2219,7 @@ test "union" {
22202219 try std.testing.expect(mem.eql(u8, uu_result[0..3], "UU@"));
22212220
22222221 const eu_result = try bufPrint(buf[0..], "{}", .{eu_inst});
2223 try std.testing.expect(mem.eql(u8, uu_result[0..3], "EU@"));
2222 try std.testing.expect(mem.eql(u8, eu_result[0..3], "EU@"));
22242223}
22252224
22262225test "enum" {
lib/std/fmt/parse_float.zig-1
......@@ -200,7 +200,6 @@ const ParseResult = enum {
200200
201201fn parseRepr(s: []const u8, n: *FloatRepr) !ParseResult {
202202 var digit_index: usize = 0;
203 var negative = false;
204203 var negative_exp = false;
205204 var exponent: i32 = 0;
206205
lib/std/fs.zig+2-2
......@@ -477,7 +477,7 @@ pub const Dir = struct {
477477 }
478478
479479 var stat_info: os.libc_stat = undefined;
480 const rc2 = os.system._kern_read_stat(
480 _ = os.system._kern_read_stat(
481481 self.dir.fd,
482482 &haiku_entry.d_name,
483483 false,
......@@ -2438,7 +2438,7 @@ pub fn selfExePath(out_buffer: []u8) SelfExePathError![]u8 {
24382438 }) catch continue;
24392439
24402440 var real_path_buf: [MAX_PATH_BYTES]u8 = undefined;
2441 if (os.realpathZ(&resolved_path_buf, &real_path_buf)) |real_path| {
2441 if (os.realpathZ(resolved_path, &real_path_buf)) |real_path| {
24422442 // found a file, and hope it is the right file
24432443 if (real_path.len > out_buffer.len)
24442444 return error.NameTooLong;
lib/std/hash/cityhash.zig-1
......@@ -353,7 +353,6 @@ fn SMHasherTest(comptime hash_fn: anytype) u32 {
353353
354354 var key: [256]u8 = undefined;
355355 var hashes_bytes: [256 * @sizeOf(HashResult)]u8 = undefined;
356 var final: HashResult = 0;
357356
358357 std.mem.set(u8, &key, 0);
359358 std.mem.set(u8, &hashes_bytes, 0);
lib/std/hash/wyhash.zig-2
......@@ -166,8 +166,6 @@ pub const Wyhash = struct {
166166 }
167167
168168 pub fn final(self: *Wyhash) u64 {
169 const seed = self.state.seed;
170 const rem_len = @intCast(u5, self.buf_len);
171169 const rem_key = self.buf[0..self.buf_len];
172170
173171 return self.state.final(rem_key);
lib/std/hash_map.zig+1-1
......@@ -1809,7 +1809,7 @@ test "std.hash_map getOrPut" {
18091809
18101810 i = 0;
18111811 while (i < 20) : (i += 1) {
1812 var n = try map.getOrPutValue(i, 1);
1812 _ = try map.getOrPutValue(i, 1);
18131813 }
18141814
18151815 i = 0;
lib/std/leb128.zig+2-3
......@@ -198,7 +198,7 @@ fn test_read_ileb128_seq(comptime T: type, comptime N: usize, encoded: []const u
198198 var reader = std.io.fixedBufferStream(encoded);
199199 var i: usize = 0;
200200 while (i < N) : (i += 1) {
201 const v1 = try readILEB128(T, reader.reader());
201 _ = try readILEB128(T, reader.reader());
202202 }
203203}
204204
......@@ -206,7 +206,7 @@ fn test_read_uleb128_seq(comptime T: type, comptime N: usize, encoded: []const u
206206 var reader = std.io.fixedBufferStream(encoded);
207207 var i: usize = 0;
208208 while (i < N) : (i += 1) {
209 const v1 = try readULEB128(T, reader.reader());
209 _ = try readULEB128(T, reader.reader());
210210 }
211211}
212212
......@@ -309,7 +309,6 @@ fn test_write_leb128(value: anytype) !void {
309309 const B = std.meta.Int(signedness, larger_type_bits);
310310
311311 const bytes_needed = bn: {
312 const S = std.meta.Int(signedness, @sizeOf(T) * 8);
313312 if (@typeInfo(T).Int.bits <= 7) break :bn @as(u16, 1);
314313
315314 const unused_bits = if (value < 0) @clz(T, ~value) else @clz(T, value);
lib/std/linked_list.zig+2-2
......@@ -359,8 +359,8 @@ test "basic TailQueue test" {
359359 }
360360 }
361361
362 var first = list.popFirst(); // {2, 3, 4, 5}
363 var last = list.pop(); // {2, 3, 4}
362 _ = list.popFirst(); // {2, 3, 4, 5}
363 _ = list.pop(); // {2, 3, 4}
364364 list.remove(&three); // {2, 4}
365365
366366 try testing.expect(list.first.?.data == 2);
lib/std/math/big/int.zig-2
......@@ -2000,8 +2000,6 @@ fn llmulacc_karatsuba(allocator: *Allocator, r: []Limb, x: []const Limb, y: []co
20002000 } else {
20012001 llsub(j1, y0[0..y0_len], y1[0..y1_len]);
20022002 }
2003 const j0_len = llnormalize(j0);
2004 const j1_len = llnormalize(j1);
20052003 if (x_cmp == y_cmp) {
20062004 mem.set(Limb, tmp[0..length], 0);
20072005 llmulacc(allocator, tmp, j0, j1);
lib/std/math/big/rational.zig-1
......@@ -204,7 +204,6 @@ pub const Rational = struct {
204204 const esize = math.floatExponentBits(T);
205205 const ebias = (1 << (esize - 1)) - 1;
206206 const emin = 1 - ebias;
207 const emax = ebias;
208207
209208 if (self.p.eqZero()) {
210209 return 0;
lib/std/math/complex/ldexp.zig+1-1
......@@ -12,8 +12,8 @@
1212const std = @import("../../std.zig");
1313const debug = std.debug;
1414const math = std.math;
15const cmath = math.complex;
1615const testing = std.testing;
16const cmath = math.complex;
1717const Complex = cmath.Complex;
1818
1919/// Returns exp(z) scaled to avoid overflow.
lib/std/math/expm1.zig-4
......@@ -316,16 +316,12 @@ test "math.expm1_64" {
316316}
317317
318318test "math.expm1_32.special" {
319 const epsilon = 0.000001;
320
321319 try expect(math.isPositiveInf(expm1_32(math.inf(f32))));
322320 try expect(expm1_32(-math.inf(f32)) == -1.0);
323321 try expect(math.isNan(expm1_32(math.nan(f32))));
324322}
325323
326324test "math.expm1_64.special" {
327 const epsilon = 0.000001;
328
329325 try expect(math.isPositiveInf(expm1_64(math.inf(f64))));
330326 try expect(expm1_64(-math.inf(f64)) == -1.0);
331327 try expect(math.isNan(expm1_64(math.nan(f64))));
lib/std/math/modf.zig+2-5
......@@ -12,6 +12,7 @@
1212const std = @import("../std.zig");
1313const math = std.math;
1414const expect = std.testing.expect;
15const expectEqual = std.testing.expectEqual;
1516const maxInt = std.math.maxInt;
1617
1718fn modf_result(comptime T: type) type {
......@@ -131,11 +132,7 @@ test "math.modf" {
131132 const a = modf(@as(f32, 1.0));
132133 const b = modf32(1.0);
133134 // NOTE: No struct comparison on generic return type function? non-named, makes sense, but still.
134 try expect(a.ipart == b.ipart and a.fpart == b.fpart);
135
136 const c = modf(@as(f64, 1.0));
137 const d = modf64(1.0);
138 try expect(a.ipart == b.ipart and a.fpart == b.fpart);
135 try expectEqual(a, b);
139136}
140137
141138test "math.modf32" {
lib/std/meta.zig-7
......@@ -654,7 +654,6 @@ pub fn TagPayload(comptime U: type, tag: Tag(U)) type {
654654 try testing.expect(trait.is(.Union)(U));
655655
656656 const info = @typeInfo(U).Union;
657 const tag_info = @typeInfo(Tag(U)).Enum;
658657
659658 inline for (info.fields) |field_info| {
660659 if (comptime mem.eql(u8, field_info.name, @tagName(tag)))
......@@ -757,12 +756,6 @@ test "std.meta.eql" {
757756 .c = "12345".*,
758757 };
759758
760 const s_2 = S{
761 .a = 1,
762 .b = 123.3,
763 .c = "54321".*,
764 };
765
766759 var s_3 = S{
767760 .a = 134,
768761 .b = 123.3,
lib/std/os.zig+3-3
......@@ -5341,7 +5341,7 @@ pub fn sendfile(
53415341 ENXIO => return error.Unseekable,
53425342 ESPIPE => return error.Unseekable,
53435343 else => |err| {
5344 const discard = unexpectedErrno(err);
5344 unexpectedErrno(err) catch {};
53455345 break :sf;
53465346 },
53475347 }
......@@ -5422,7 +5422,7 @@ pub fn sendfile(
54225422 EPIPE => return error.BrokenPipe,
54235423
54245424 else => {
5425 const discard = unexpectedErrno(err);
5425 unexpectedErrno(err) catch {};
54265426 if (amt != 0) {
54275427 return amt;
54285428 } else {
......@@ -5484,7 +5484,7 @@ pub fn sendfile(
54845484 EPIPE => return error.BrokenPipe,
54855485
54865486 else => {
5487 const discard = unexpectedErrno(err);
5487 unexpectedErrno(err) catch {};
54885488 if (amt != 0) {
54895489 return amt;
54905490 } else {
lib/std/os/linux/io_uring.zig+3-3
......@@ -1272,12 +1272,12 @@ test "accept/connect/send/recv" {
12721272
12731273 var accept_addr: os.sockaddr = undefined;
12741274 var accept_addr_len: os.socklen_t = @sizeOf(@TypeOf(accept_addr));
1275 const accept = try ring.accept(0xaaaaaaaa, server, &accept_addr, &accept_addr_len, 0);
1275 _ = try ring.accept(0xaaaaaaaa, server, &accept_addr, &accept_addr_len, 0);
12761276 try testing.expectEqual(@as(u32, 1), try ring.submit());
12771277
12781278 const client = try os.socket(address.any.family, os.SOCK_STREAM | os.SOCK_CLOEXEC, 0);
12791279 defer os.close(client);
1280 const connect = try ring.connect(0xcccccccc, client, &address.any, address.getOsSockLen());
1280 _ = try ring.connect(0xcccccccc, client, &address.any, address.getOsSockLen());
12811281 try testing.expectEqual(@as(u32, 1), try ring.submit());
12821282
12831283 var cqe_accept = try ring.copy_cqe();
......@@ -1305,7 +1305,7 @@ test "accept/connect/send/recv" {
13051305
13061306 const send = try ring.send(0xeeeeeeee, client, buffer_send[0..], 0);
13071307 send.flags |= linux.IOSQE_IO_LINK;
1308 const recv = try ring.recv(0xffffffff, cqe_accept.res, buffer_recv[0..], 0);
1308 _ = try ring.recv(0xffffffff, cqe_accept.res, buffer_recv[0..], 0);
13091309 try testing.expectEqual(@as(u32, 2), try ring.submit());
13101310
13111311 const cqe_send = try ring.copy_cqe();
lib/std/os/linux/vdso.zig-1
......@@ -15,7 +15,6 @@ pub fn lookup(vername: []const u8, name: []const u8) usize {
1515
1616 const eh = @intToPtr(*elf.Ehdr, vdso_addr);
1717 var ph_addr: usize = vdso_addr + eh.e_phoff;
18 const ph = @intToPtr(*elf.Phdr, ph_addr);
1918
2019 var maybe_dynv: ?[*]usize = null;
2120 var base: usize = maxInt(usize);
lib/std/os/windows.zig-1
......@@ -1156,7 +1156,6 @@ pub fn GetFinalPathNameByHandle(
11561156 &mount_points_struct.MountPoints[0],
11571157 )[0..mount_points_struct.NumberOfMountPoints];
11581158
1159 var found: bool = false;
11601159 for (mount_points) |mount_point| {
11611160 const symlink = @ptrCast(
11621161 [*]const u16,
lib/std/pdb.zig+4-4
......@@ -590,11 +590,11 @@ pub const Pdb = struct {
590590
591591 var sect_cont_offset: usize = 0;
592592 if (section_contrib_size != 0) {
593 // the version
594 _ = reader.readEnum(SectionContrSubstreamVersion, .Little) catch |err| switch (err) {
593 const version = reader.readEnum(SectionContrSubstreamVersion, .Little) catch |err| switch (err) {
595594 error.InvalidValue => return error.InvalidDebugInfo,
596595 else => |e| return e,
597596 };
597 _ = version;
598598 sect_cont_offset += @sizeOf(u32);
599599 }
600600 while (sect_cont_offset != section_contrib_size) {
......@@ -617,8 +617,8 @@ pub const Pdb = struct {
617617
618618 // Parse the InfoStreamHeader.
619619 const version = try reader.readIntLittle(u32);
620 // The signature
621 _ = try reader.readIntLittle(u32);
620 const signature = try reader.readIntLittle(u32);
621 _ = signature;
622622 const age = try reader.readIntLittle(u32);
623623 const guid = try reader.readBytesNoEof(16);
624624
lib/std/rand/ziggurat.zig+1-1
......@@ -175,5 +175,5 @@ test "exp dist sanity" {
175175test "table gen" {
176176 if (please_windows_dont_oom) return error.SkipZigTest;
177177
178 const table = NormDist;
178 _ = NormDist;
179179}
lib/std/special/compiler_rt/addXf3.zig-5
......@@ -83,7 +83,6 @@ fn addXf3(comptime T: type, a: T, b: T) T {
8383
8484 const signBit = (@as(Z, 1) << (significandBits + exponentBits));
8585 const maxExponent = ((1 << exponentBits) - 1);
86 const exponentBias = (maxExponent >> 1);
8786
8887 const implicitBit = (@as(Z, 1) << significandBits);
8988 const quietBit = implicitBit >> 1;
......@@ -98,10 +97,6 @@ fn addXf3(comptime T: type, a: T, b: T) T {
9897 const aAbs = aRep & absMask;
9998 const bAbs = bRep & absMask;
10099
101 const negative = (aRep & signBit) != 0;
102 const exponent = @intCast(i32, aAbs >> significandBits) - exponentBias;
103 const significand = (aAbs & significandMask) | implicitBit;
104
105100 const infRep = @bitCast(Z, std.math.inf(T));
106101
107102 // Detect if a or b is zero, infinity, or NaN.
lib/std/special/compiler_rt/divtf3.zig-1
......@@ -12,7 +12,6 @@ const wideMultiply = @import("divdf3.zig").wideMultiply;
1212pub fn __divtf3(a: f128, b: f128) callconv(.C) f128 {
1313 @setRuntimeSafety(builtin.is_test);
1414 const Z = std.meta.Int(.unsigned, 128);
15 const SignedZ = std.meta.Int(.signed, 128);
1615
1716 const significandBits = std.math.floatMantissaBits(f128);
1817 const exponentBits = std.math.floatExponentBits(f128);
lib/std/special/compiler_rt/extendXfYf2.zig-1
......@@ -46,7 +46,6 @@ fn extendXfYf2(comptime dst_t: type, comptime src_t: type, a: std.meta.Int(.unsi
4646 const dst_rep_t = std.meta.Int(.unsigned, @typeInfo(dst_t).Float.bits);
4747 const srcSigBits = std.math.floatMantissaBits(src_t);
4848 const dstSigBits = std.math.floatMantissaBits(dst_t);
49 const SrcShift = std.math.Log2Int(src_rep_t);
5049 const DstShift = std.math.Log2Int(dst_rep_t);
5150
5251 // Various constants whose values follow from the type parameters.
lib/std/special/compiler_rt/fixuint.zig-1
......@@ -16,7 +16,6 @@ pub fn fixuint(comptime fp_t: type, comptime fixuint_t: type, a: fp_t) fixuint_t
1616 else => unreachable,
1717 };
1818 const typeWidth = @typeInfo(rep_t).Int.bits;
19 const srep_t = @import("std").meta.Int(.signed, typeWidth);
2019 const significandBits = switch (fp_t) {
2120 f32 => 23,
2221 f64 => 52,
lib/std/special/compiler_rt/truncXfYf2.zig-1
......@@ -50,7 +50,6 @@ fn truncXfYf2(comptime dst_t: type, comptime src_t: type, a: src_t) dst_t {
5050 const srcSigBits = std.math.floatMantissaBits(src_t);
5151 const dstSigBits = std.math.floatMantissaBits(dst_t);
5252 const SrcShift = std.math.Log2Int(src_rep_t);
53 const DstShift = std.math.Log2Int(dst_rep_t);
5453
5554 // Various constants whose values follow from the type parameters.
5655 // Any reasonable optimizer will fold and propagate all of these.
lib/std/testing.zig-1
......@@ -191,7 +191,6 @@ test "expectEqual.union(enum)" {
191191 };
192192
193193 const a10 = T{ .a = 10 };
194 const a20 = T{ .a = 20 };
195194
196195 try expectEqual(a10, a10);
197196}
lib/std/unicode/throughput_test.zig-2
......@@ -47,8 +47,6 @@ fn benchmarkCodepointCount(buf: []const u8) !ResultCount {
4747pub fn main() !void {
4848 const stdout = std.io.getStdOut().writer();
4949
50 const args = try std.process.argsAlloc(std.heap.page_allocator);
51
5250 try stdout.print("short ASCII strings\n", .{});
5351 {
5452 const result = try benchmarkCodepointCount("abc");
lib/std/x/os/io.zig-1
......@@ -122,7 +122,6 @@ test "reactor/linux: drive async tcp client/listener pair" {
122122
123123 const IPv4 = std.x.os.IPv4;
124124 const IPv6 = std.x.os.IPv6;
125 const Socket = std.x.os.Socket;
126125
127126 const reactor = try Reactor.init(.{ .close_on_exec = true });
128127 defer reactor.deinit();
lib/std/zig/ast.zig-1
......@@ -1866,7 +1866,6 @@ pub const Tree = struct {
18661866 }
18671867
18681868 fn fullStructInit(tree: Tree, info: full.StructInit.Ast) full.StructInit {
1869 const token_tags = tree.tokens.items(.tag);
18701869 var result: full.StructInit = .{
18711870 .ast = info,
18721871 };
lib/std/zig/parse.zig+23-23
......@@ -586,7 +586,7 @@ const Parser = struct {
586586 const thread_local_token = p.eatToken(.keyword_threadlocal);
587587 const var_decl = try p.parseVarDecl();
588588 if (var_decl != 0) {
589 const semicolon_token = try p.expectToken(.semicolon);
589 _ = try p.expectToken(.semicolon);
590590 return var_decl;
591591 }
592592 if (thread_local_token != null) {
......@@ -614,7 +614,7 @@ const Parser = struct {
614614 fn expectUsingNamespace(p: *Parser) !Node.Index {
615615 const usingnamespace_token = p.assertToken(.keyword_usingnamespace);
616616 const expr = try p.expectExpr();
617 const semicolon_token = try p.expectToken(.semicolon);
617 _ = try p.expectToken(.semicolon);
618618 return p.addNode(.{
619619 .tag = .@"usingnamespace",
620620 .main_token = usingnamespace_token,
......@@ -647,7 +647,7 @@ const Parser = struct {
647647 const align_expr = try p.parseByteAlign();
648648 const section_expr = try p.parseLinkSection();
649649 const callconv_expr = try p.parseCallconv();
650 const bang_token = p.eatToken(.bang);
650 _ = p.eatToken(.bang);
651651
652652 const return_type_expr = try p.parseTypeExpr();
653653 if (return_type_expr == 0) {
......@@ -775,7 +775,7 @@ const Parser = struct {
775775
776776 /// ContainerField <- KEYWORD_comptime? IDENTIFIER (COLON (KEYWORD_anytype / TypeExpr) ByteAlign?)? (EQUAL Expr)?
777777 fn expectContainerField(p: *Parser) !Node.Index {
778 const comptime_token = p.eatToken(.keyword_comptime);
778 _ = p.eatToken(.keyword_comptime);
779779 const name_token = p.assertToken(.identifier);
780780
781781 var align_expr: Node.Index = 0;
......@@ -967,7 +967,7 @@ const Parser = struct {
967967 _ = try p.expectToken(.l_paren);
968968 const condition = try p.expectExpr();
969969 _ = try p.expectToken(.r_paren);
970 const then_payload = try p.parsePtrPayload();
970 _ = try p.parsePtrPayload();
971971
972972 // TODO propose to change the syntax so that semicolons are always required
973973 // inside if statements, even if there is an `else`.
......@@ -992,7 +992,7 @@ const Parser = struct {
992992 else_required = true;
993993 break :blk assign_expr;
994994 };
995 const else_token = p.eatToken(.keyword_else) orelse {
995 _ = p.eatToken(.keyword_else) orelse {
996996 if (else_required) {
997997 try p.warn(.expected_semi_or_else);
998998 }
......@@ -1087,7 +1087,7 @@ const Parser = struct {
10871087 else_required = true;
10881088 break :blk assign_expr;
10891089 };
1090 const else_token = p.eatToken(.keyword_else) orelse {
1090 _ = p.eatToken(.keyword_else) orelse {
10911091 if (else_required) {
10921092 try p.warn(.expected_semi_or_else);
10931093 }
......@@ -1122,7 +1122,7 @@ const Parser = struct {
11221122 _ = try p.expectToken(.l_paren);
11231123 const condition = try p.expectExpr();
11241124 _ = try p.expectToken(.r_paren);
1125 const then_payload = try p.parsePtrPayload();
1125 _ = try p.parsePtrPayload();
11261126 const cont_expr = try p.parseWhileContinueExpr();
11271127
11281128 // TODO propose to change the syntax so that semicolons are always required
......@@ -1162,7 +1162,7 @@ const Parser = struct {
11621162 else_required = true;
11631163 break :blk assign_expr;
11641164 };
1165 const else_token = p.eatToken(.keyword_else) orelse {
1165 _ = p.eatToken(.keyword_else) orelse {
11661166 if (else_required) {
11671167 try p.warn(.expected_semi_or_else);
11681168 }
......@@ -1550,7 +1550,7 @@ const Parser = struct {
15501550 },
15511551 .l_bracket => switch (p.token_tags[p.tok_i + 1]) {
15521552 .asterisk => {
1553 const lbracket = p.nextToken();
1553 _ = p.nextToken();
15541554 const asterisk = p.nextToken();
15551555 var sentinel: Node.Index = 0;
15561556 prefix: {
......@@ -1907,7 +1907,7 @@ const Parser = struct {
19071907 if (found_payload == 0) try p.warn(.expected_loop_payload);
19081908
19091909 const then_expr = try p.expectExpr();
1910 const else_token = p.eatToken(.keyword_else) orelse {
1910 _ = p.eatToken(.keyword_else) orelse {
19111911 return p.addNode(.{
19121912 .tag = .for_simple,
19131913 .main_token = for_token,
......@@ -1938,11 +1938,11 @@ const Parser = struct {
19381938 _ = try p.expectToken(.l_paren);
19391939 const condition = try p.expectExpr();
19401940 _ = try p.expectToken(.r_paren);
1941 const then_payload = try p.parsePtrPayload();
1941 _ = try p.parsePtrPayload();
19421942 const cont_expr = try p.parseWhileContinueExpr();
19431943
19441944 const then_expr = try p.expectExpr();
1945 const else_token = p.eatToken(.keyword_else) orelse {
1945 _ = p.eatToken(.keyword_else) orelse {
19461946 if (cont_expr == 0) {
19471947 return p.addNode(.{
19481948 .tag = .while_simple,
......@@ -1966,7 +1966,7 @@ const Parser = struct {
19661966 });
19671967 }
19681968 };
1969 const else_payload = try p.parsePayload();
1969 _ = try p.parsePayload();
19701970 const else_expr = try p.expectExpr();
19711971 return p.addNode(.{
19721972 .tag = .@"while",
......@@ -2565,8 +2565,8 @@ const Parser = struct {
25652565 p.tok_i += 2;
25662566 while (true) {
25672567 if (p.eatToken(.r_brace)) |_| break;
2568 const doc_comment = try p.eatDocComments();
2569 const identifier = try p.expectToken(.identifier);
2568 _ = try p.eatDocComments();
2569 _ = try p.expectToken(.identifier);
25702570 switch (p.token_tags[p.tok_i]) {
25712571 .comma => p.tok_i += 1,
25722572 .r_brace => {
......@@ -2634,7 +2634,7 @@ const Parser = struct {
26342634 if (found_payload == 0) try p.warn(.expected_loop_payload);
26352635
26362636 const then_expr = try p.expectTypeExpr();
2637 const else_token = p.eatToken(.keyword_else) orelse {
2637 _ = p.eatToken(.keyword_else) orelse {
26382638 return p.addNode(.{
26392639 .tag = .for_simple,
26402640 .main_token = for_token,
......@@ -2665,11 +2665,11 @@ const Parser = struct {
26652665 _ = try p.expectToken(.l_paren);
26662666 const condition = try p.expectExpr();
26672667 _ = try p.expectToken(.r_paren);
2668 const then_payload = try p.parsePtrPayload();
2668 _ = try p.parsePtrPayload();
26692669 const cont_expr = try p.parseWhileContinueExpr();
26702670
26712671 const then_expr = try p.expectTypeExpr();
2672 const else_token = p.eatToken(.keyword_else) orelse {
2672 _ = p.eatToken(.keyword_else) orelse {
26732673 if (cont_expr == 0) {
26742674 return p.addNode(.{
26752675 .tag = .while_simple,
......@@ -2693,7 +2693,7 @@ const Parser = struct {
26932693 });
26942694 }
26952695 };
2696 const else_payload = try p.parsePayload();
2696 _ = try p.parsePayload();
26972697 const else_expr = try p.expectTypeExpr();
26982698 return p.addNode(.{
26992699 .tag = .@"while",
......@@ -3570,12 +3570,12 @@ const Parser = struct {
35703570 _ = try p.expectToken(.l_paren);
35713571 const condition = try p.expectExpr();
35723572 _ = try p.expectToken(.r_paren);
3573 const then_payload = try p.parsePtrPayload();
3573 _ = try p.parsePtrPayload();
35743574
35753575 const then_expr = try bodyParseFn(p);
35763576 if (then_expr == 0) return p.fail(.invalid_token);
35773577
3578 const else_token = p.eatToken(.keyword_else) orelse return p.addNode(.{
3578 _ = p.eatToken(.keyword_else) orelse return p.addNode(.{
35793579 .tag = .if_simple,
35803580 .main_token = if_token,
35813581 .data = .{
......@@ -3583,7 +3583,7 @@ const Parser = struct {
35833583 .rhs = then_expr,
35843584 },
35853585 });
3586 const else_payload = try p.parsePayload();
3586 _ = try p.parsePayload();
35873587 const else_expr = try bodyParseFn(p);
35883588 if (else_expr == 0) return p.fail(.invalid_token);
35893589
lib/std/zig/parser_test.zig-1
......@@ -5201,7 +5201,6 @@ fn testParse(source: []const u8, allocator: *mem.Allocator, anything_changed: *b
52015201 defer tree.deinit(allocator);
52025202
52035203 for (tree.errors) |parse_error| {
5204 const token_start = tree.tokens.items(.start)[parse_error.token];
52055204 const loc = tree.tokenLocation(0, parse_error.token);
52065205 try stderr.print("(memory buffer):{d}:{d}: error: ", .{ loc.line + 1, loc.column + 1 });
52075206 try tree.renderError(parse_error, stderr);
lib/std/zig/render.zig-6
......@@ -1086,8 +1086,6 @@ fn renderWhile(gpa: *Allocator, ais: *Ais, tree: ast.Tree, while_node: ast.full.
10861086 }
10871087
10881088 if (while_node.ast.else_expr != 0) {
1089 const first_else_expr_tok = tree.firstToken(while_node.ast.else_expr);
1090
10911089 if (indent_then_expr) {
10921090 ais.pushIndent();
10931091 try renderExpression(gpa, ais, tree, while_node.ast.then_expr, .newline);
......@@ -1133,7 +1131,6 @@ fn renderContainerField(
11331131 field: ast.full.ContainerField,
11341132 space: Space,
11351133) Error!void {
1136 const main_tokens = tree.nodes.items(.main_token);
11371134 if (field.comptime_token) |t| {
11381135 try renderToken(ais, tree, t, .space); // comptime
11391136 }
......@@ -1519,7 +1516,6 @@ fn renderBlock(
15191516) Error!void {
15201517 const token_tags = tree.tokens.items(.tag);
15211518 const node_tags = tree.nodes.items(.tag);
1522 const nodes_data = tree.nodes.items(.data);
15231519 const lbrace = tree.nodes.items(.main_token)[block_node];
15241520
15251521 if (token_tags[lbrace - 1] == .colon and
......@@ -1617,7 +1613,6 @@ fn renderArrayInit(
16171613 space: Space,
16181614) Error!void {
16191615 const token_tags = tree.tokens.items(.tag);
1620 const token_starts = tree.tokens.items(.start);
16211616
16221617 if (array_init.ast.type_expr == 0) {
16231618 try renderToken(ais, tree, array_init.ast.lbrace - 1, .none); // .
......@@ -2046,7 +2041,6 @@ fn renderCall(
20462041 space: Space,
20472042) Error!void {
20482043 const token_tags = tree.tokens.items(.tag);
2049 const main_tokens = tree.nodes.items(.main_token);
20502044
20512045 if (call.async_token) |async_token| {
20522046 try renderToken(ais, tree, async_token, .space);
lib/std/zig/system.zig+1-8
......@@ -478,13 +478,6 @@ pub const NativeTargetInfo = struct {
478478 }
479479 const ld_info_list = ld_info_list_buffer[0..ld_info_list_len];
480480
481 if (cross_target.dynamic_linker.get()) |explicit_ld| {
482 const explicit_ld_basename = fs.path.basename(explicit_ld);
483 for (ld_info_list) |ld_info| {
484 const standard_ld_basename = fs.path.basename(ld_info.ld.get().?);
485 }
486 }
487
488481 // Best case scenario: the executable is dynamically linked, and we can iterate
489482 // over our own shared objects and find a dynamic linker.
490483 self_exe: {
......@@ -838,7 +831,7 @@ pub const NativeTargetInfo = struct {
838831
839832 if (dynstr) |ds| {
840833 const strtab_len = std.math.min(ds.size, strtab_buf.len);
841 const strtab_read_len = try preadMin(file, &strtab_buf, ds.offset, shstrtab_len);
834 const strtab_read_len = try preadMin(file, &strtab_buf, ds.offset, strtab_len);
842835 const strtab = strtab_buf[0..strtab_read_len];
843836 // TODO this pointer cast should not be necessary
844837 const rpoff_usize = std.math.cast(usize, rpoff) catch |err| switch (err) {
lib/std/zig/tokenizer.zig-1
......@@ -416,7 +416,6 @@ pub const Tokenizer = struct {
416416 self.pending_invalid_token = null;
417417 return token;
418418 }
419 const start_index = self.index;
420419 var state: State = .start;
421420 var result = Token{
422421 .tag = .eof,
src/AstGen.zig+9-38
......@@ -206,7 +206,6 @@ pub const ResultLoc = union(enum) {
206206 };
207207
208208 fn strategy(rl: ResultLoc, block_scope: *GenZir) Strategy {
209 var elide_store_to_block_ptr_instructions = false;
210209 switch (rl) {
211210 // In this branch there will not be any store_to_block_ptr instructions.
212211 .discard, .none, .none_or_ref, .ty, .ref => return .{
......@@ -905,7 +904,6 @@ fn nosuspendExpr(
905904 node: ast.Node.Index,
906905) InnerError!Zir.Inst.Ref {
907906 const astgen = gz.astgen;
908 const gpa = astgen.gpa;
909907 const tree = astgen.tree;
910908 const node_datas = tree.nodes.items(.data);
911909 const body_node = node_datas[node].lhs;
......@@ -1113,7 +1111,6 @@ fn arrayInitExpr(
11131111) InnerError!Zir.Inst.Ref {
11141112 const astgen = gz.astgen;
11151113 const tree = astgen.tree;
1116 const gpa = astgen.gpa;
11171114 const node_tags = tree.nodes.items(.tag);
11181115 const main_tokens = tree.nodes.items(.main_token);
11191116
......@@ -1293,7 +1290,6 @@ fn structInitExpr(
12931290) InnerError!Zir.Inst.Ref {
12941291 const astgen = gz.astgen;
12951292 const tree = astgen.tree;
1296 const gpa = astgen.gpa;
12971293
12981294 if (struct_init.ast.fields.len == 0) {
12991295 if (struct_init.ast.type_expr == 0) {
......@@ -1675,9 +1671,6 @@ fn checkLabelRedefinition(astgen: *AstGen, parent_scope: *Scope, label: ast.Toke
16751671 const gen_zir = scope.cast(GenZir).?;
16761672 if (gen_zir.label) |prev_label| {
16771673 if (try astgen.tokenIdentEql(label, prev_label.token)) {
1678 const tree = astgen.tree;
1679 const main_tokens = tree.nodes.items(.main_token);
1680
16811674 const label_name = try astgen.identifierTokenString(label);
16821675 return astgen.failTokNotes(label, "redefinition of label '{s}'", .{
16831676 label_name,
......@@ -1790,7 +1783,6 @@ fn blockExprStmts(
17901783) !void {
17911784 const astgen = gz.astgen;
17921785 const tree = astgen.tree;
1793 const main_tokens = tree.nodes.items(.main_token);
17941786 const node_tags = tree.nodes.items(.tag);
17951787
17961788 var block_arena = std.heap.ArenaAllocator.init(gz.astgen.gpa);
......@@ -2147,7 +2139,10 @@ fn genDefers(
21472139 .defer_error => {
21482140 const defer_scope = scope.cast(Scope.Defer).?;
21492141 scope = defer_scope.parent;
2150 if (err_code == .none) continue;
2142 // TODO add this back when we have more errdefer support
2143 // right now it is making stuff not get evaluated which causes
2144 // unused vars.
2145 // if (err_code == .none) continue;
21512146 const expr_node = node_datas[defer_scope.defer_node].rhs;
21522147 const prev_in_defer = gz.in_defer;
21532148 gz.in_defer = true;
......@@ -2166,8 +2161,6 @@ fn checkUsed(
21662161 inner_scope: *Scope,
21672162) InnerError!void {
21682163 const astgen = gz.astgen;
2169 const tree = astgen.tree;
2170 const node_datas = tree.nodes.items(.data);
21712164
21722165 var scope = inner_scope;
21732166 while (scope != outer_scope) {
......@@ -2450,7 +2443,7 @@ fn varDecl(
24502443 resolve_inferred_alloc = alloc;
24512444 break :a .{ .alloc = alloc, .result_loc = .{ .inferred_ptr = alloc } };
24522445 };
2453 const init_inst = try expr(gz, scope, var_data.result_loc, var_decl.ast.init_node);
2446 _ = try expr(gz, scope, var_data.result_loc, var_decl.ast.init_node);
24542447 if (resolve_inferred_alloc != .none) {
24552448 _ = try gz.addUnNode(.resolve_inferred_alloc, resolve_inferred_alloc, node);
24562449 }
......@@ -2477,7 +2470,6 @@ fn emitDbgNode(gz: *GenZir, node: ast.Node.Index) !void {
24772470
24782471 const astgen = gz.astgen;
24792472 const tree = astgen.tree;
2480 const node_tags = tree.nodes.items(.tag);
24812473 const token_starts = tree.tokens.items(.start);
24822474 const decl_start = token_starts[tree.firstToken(gz.decl_node_index)];
24832475 const node_start = token_starts[tree.firstToken(node)];
......@@ -2602,9 +2594,6 @@ fn ptrType(
26022594 node: ast.Node.Index,
26032595 ptr_info: ast.full.PtrType,
26042596) InnerError!Zir.Inst.Ref {
2605 const astgen = gz.astgen;
2606 const tree = astgen.tree;
2607
26082597 const elem_type = try typeExpr(gz, scope, ptr_info.ast.child_type);
26092598
26102599 const simple = ptr_info.ast.align_node == 0 and
......@@ -4305,10 +4294,8 @@ fn containerDecl(
43054294 defer wip_decls.deinit(gpa);
43064295
43074296 for (container_decl.ast.members) |member_node| {
4308 const member = switch (node_tags[member_node]) {
4309 .container_field_init => tree.containerFieldInit(member_node),
4310 .container_field_align => tree.containerFieldAlign(member_node),
4311 .container_field => tree.containerField(member_node),
4297 switch (node_tags[member_node]) {
4298 .container_field_init, .container_field_align, .container_field => {},
43124299
43134300 .fn_decl => {
43144301 const fn_proto = node_datas[member_node].lhs;
......@@ -4429,7 +4416,7 @@ fn containerDecl(
44294416 continue;
44304417 },
44314418 else => unreachable,
4432 };
4419 }
44334420 }
44344421 {
44354422 const empty_slot_count = WipDecls.fields_per_u32 - (wip_decls.decl_index % WipDecls.fields_per_u32);
......@@ -4497,11 +4484,6 @@ fn errorSetDecl(
44974484 }
44984485 }
44994486
4500 const tag: Zir.Inst.Tag = switch (gz.anon_name_strategy) {
4501 .parent => .error_set_decl,
4502 .anon => .error_set_decl_anon,
4503 .func => .error_set_decl_func,
4504 };
45054487 const result = try gz.addPlNode(.error_set_decl, node, Zir.Inst.ErrorSetDecl{
45064488 .fields_len = @intCast(u32, field_names.items.len),
45074489 });
......@@ -4517,7 +4499,6 @@ fn tryExpr(
45174499 operand_node: ast.Node.Index,
45184500) InnerError!Zir.Inst.Ref {
45194501 const astgen = parent_gz.astgen;
4520 const tree = astgen.tree;
45214502
45224503 const fn_block = astgen.fn_block orelse {
45234504 return astgen.failNode(node, "invalid 'try' outside function scope", .{});
......@@ -4702,7 +4683,6 @@ fn finishThenElseBlock(
47024683 // We now have enough information to decide whether the result instruction should
47034684 // be communicated via result location pointer or break instructions.
47044685 const strat = rl.strategy(block_scope);
4705 const astgen = block_scope.astgen;
47064686 switch (strat.tag) {
47074687 .break_void => {
47084688 if (!parent_gz.refIsNoReturn(then_result)) {
......@@ -4786,7 +4766,6 @@ fn arrayAccess(
47864766) InnerError!Zir.Inst.Ref {
47874767 const astgen = gz.astgen;
47884768 const tree = astgen.tree;
4789 const main_tokens = tree.nodes.items(.main_token);
47904769 const node_datas = tree.nodes.items(.data);
47914770 switch (rl) {
47924771 .ref => return gz.addBin(
......@@ -6054,7 +6033,6 @@ fn ret(gz: *GenZir, scope: *Scope, node: ast.Node.Index) InnerError!Zir.Inst.Ref
60546033 const astgen = gz.astgen;
60556034 const tree = astgen.tree;
60566035 const node_datas = tree.nodes.items(.data);
6057 const main_tokens = tree.nodes.items(.main_token);
60586036
60596037 if (gz.in_defer) return astgen.failNode(node, "cannot return from defer expression", .{});
60606038
......@@ -6271,7 +6249,6 @@ fn multilineStringLiteral(
62716249 const astgen = gz.astgen;
62726250 const tree = astgen.tree;
62736251 const node_datas = tree.nodes.items(.data);
6274 const main_tokens = tree.nodes.items(.main_token);
62756252
62766253 const start = node_datas[node].lhs;
62776254 const end = node_datas[node].rhs;
......@@ -6387,7 +6364,6 @@ fn floatLiteral(
63876364 node: ast.Node.Index,
63886365) InnerError!Zir.Inst.Ref {
63896366 const astgen = gz.astgen;
6390 const arena = astgen.arena;
63916367 const tree = astgen.tree;
63926368 const main_tokens = tree.nodes.items(.main_token);
63936369
......@@ -6430,7 +6406,6 @@ fn asmExpr(
64306406 full: ast.full.Asm,
64316407) InnerError!Zir.Inst.Ref {
64326408 const astgen = gz.astgen;
6433 const arena = astgen.arena;
64346409 const tree = astgen.tree;
64356410 const main_tokens = tree.nodes.items(.main_token);
64366411 const node_datas = tree.nodes.items(.data);
......@@ -6519,7 +6494,6 @@ fn asmExpr(
65196494 const name = try astgen.identAsString(symbolic_name);
65206495 const constraint_token = symbolic_name + 2;
65216496 const constraint = (try astgen.strLitAsString(constraint_token)).index;
6522 const has_arrow = token_tags[symbolic_name + 4] == .arrow;
65236497 const operand = try expr(gz, scope, .{ .ty = .usize_type }, node_datas[input_node].lhs);
65246498 inputs[i] = .{
65256499 .name = name,
......@@ -6601,7 +6575,7 @@ fn unionInit(
66016575 const field_name = try comptimeExpr(gz, scope, .{ .ty = .const_slice_u8_type }, params[1]);
66026576 switch (rl) {
66036577 .none, .none_or_ref, .discard, .ref, .ty, .inferred_ptr => {
6604 const field_type = try gz.addPlNode(.field_type_ref, params[1], Zir.Inst.FieldTypeRef{
6578 _ = try gz.addPlNode(.field_type_ref, params[1], Zir.Inst.FieldTypeRef{
66056579 .container_type = union_type,
66066580 .field_name = field_name,
66076581 });
......@@ -6783,7 +6757,6 @@ fn builtinCall(
67836757 switch (info.tag) {
67846758 .import => {
67856759 const node_tags = tree.nodes.items(.tag);
6786 const node_datas = tree.nodes.items(.data);
67876760 const operand_node = params[0];
67886761
67896762 if (node_tags[operand_node] != .string_literal) {
......@@ -8119,7 +8092,6 @@ fn parseStrLit(
81198092 bytes: []const u8,
81208093 offset: u32,
81218094) InnerError!void {
8122 const tree = astgen.tree;
81238095 const raw_string = bytes[offset..];
81248096 var buf_managed = buf.toManaged(astgen.gpa);
81258097 const result = std.zig.string_literal.parseAppend(&buf_managed, raw_string);
......@@ -8567,7 +8539,6 @@ const GenZir = struct {
85678539 fn calcLine(gz: GenZir, node: ast.Node.Index) u32 {
85688540 const astgen = gz.astgen;
85698541 const tree = astgen.tree;
8570 const node_tags = tree.nodes.items(.tag);
85718542 const token_starts = tree.tokens.items(.start);
85728543 const decl_start = token_starts[tree.firstToken(gz.decl_node_index)];
85738544 const node_start = token_starts[tree.firstToken(node)];
src/Compilation.zig+1-2
......@@ -325,7 +325,6 @@ pub const AllErrors = struct {
325325 },
326326
327327 pub fn renderToStdErr(msg: Message, ttyconf: std.debug.TTY.Config) void {
328 const stderr_mutex = std.debug.getStderrMutex();
329328 const held = std.debug.getStderrMutex().acquire();
330329 defer held.release();
331330 const stderr = std.io.getStdErr();
......@@ -2373,7 +2372,7 @@ pub fn cImport(comp: *Compilation, c_src: []const u8) !CImportResult {
23732372 // We need to "unhit" in this case, to keep the digests matching.
23742373 const prev_hash_state = man.hash.peekBin();
23752374 const actual_hit = hit: {
2376 const is_hit = try man.hit();
2375 _ = try man.hit();
23772376 if (man.files.items.len == 0) {
23782377 man.unhit(prev_hash_state, 0);
23792378 break :hit false;
src/DepTokenizer.zig+2-3
......@@ -944,7 +944,7 @@ fn printLabel(out: anytype, label: []const u8, bytes: []const u8) !void {
944944 try out.writeAll(text);
945945 var i: usize = text.len;
946946 const end = 79;
947 while (i < 79) : (i += 1) {
947 while (i < end) : (i += 1) {
948948 try out.writeAll(&[_]u8{label[0]});
949949 }
950950 try out.writeAll("\n");
......@@ -953,7 +953,7 @@ fn printLabel(out: anytype, label: []const u8, bytes: []const u8) !void {
953953fn printRuler(out: anytype) !void {
954954 var i: usize = 0;
955955 const end = 79;
956 while (i < 79) : (i += 1) {
956 while (i < end) : (i += 1) {
957957 try out.writeAll("-");
958958 }
959959 try out.writeAll("\n");
......@@ -1057,4 +1057,3 @@ const printable_char_tab: [256]u8 = (
10571057 "................................................................" ++
10581058 "................................................................"
10591059).*;
1060
src/Module.zig+5-19
......@@ -1561,7 +1561,6 @@ pub const SrcLoc = struct {
15611561 .node_offset_array_access_index => |node_off| {
15621562 const tree = try src_loc.file_scope.getTree(gpa);
15631563 const node_datas = tree.nodes.items(.data);
1564 const node_tags = tree.nodes.items(.tag);
15651564 const node = src_loc.declRelativeToNodeIndex(node_off);
15661565 const main_tokens = tree.nodes.items(.main_token);
15671566 const tok_index = main_tokens[node_datas[node].rhs];
......@@ -1570,7 +1569,6 @@ pub const SrcLoc = struct {
15701569 },
15711570 .node_offset_slice_sentinel => |node_off| {
15721571 const tree = try src_loc.file_scope.getTree(gpa);
1573 const node_datas = tree.nodes.items(.data);
15741572 const node_tags = tree.nodes.items(.tag);
15751573 const node = src_loc.declRelativeToNodeIndex(node_off);
15761574 const full = switch (node_tags[node]) {
......@@ -1586,7 +1584,6 @@ pub const SrcLoc = struct {
15861584 },
15871585 .node_offset_call_func => |node_off| {
15881586 const tree = try src_loc.file_scope.getTree(gpa);
1589 const node_datas = tree.nodes.items(.data);
15901587 const node_tags = tree.nodes.items(.tag);
15911588 const node = src_loc.declRelativeToNodeIndex(node_off);
15921589 var params: [1]ast.Node.Index = undefined;
......@@ -1625,7 +1622,6 @@ pub const SrcLoc = struct {
16251622 .node_offset_deref_ptr => |node_off| {
16261623 const tree = try src_loc.file_scope.getTree(gpa);
16271624 const node_datas = tree.nodes.items(.data);
1628 const node_tags = tree.nodes.items(.tag);
16291625 const node = src_loc.declRelativeToNodeIndex(node_off);
16301626 const tok_index = node_datas[node].lhs;
16311627 const token_starts = tree.tokens.items(.start);
......@@ -1633,7 +1629,6 @@ pub const SrcLoc = struct {
16331629 },
16341630 .node_offset_asm_source => |node_off| {
16351631 const tree = try src_loc.file_scope.getTree(gpa);
1636 const node_datas = tree.nodes.items(.data);
16371632 const node_tags = tree.nodes.items(.tag);
16381633 const node = src_loc.declRelativeToNodeIndex(node_off);
16391634 const full = switch (node_tags[node]) {
......@@ -1648,7 +1643,6 @@ pub const SrcLoc = struct {
16481643 },
16491644 .node_offset_asm_ret_ty => |node_off| {
16501645 const tree = try src_loc.file_scope.getTree(gpa);
1651 const node_datas = tree.nodes.items(.data);
16521646 const node_tags = tree.nodes.items(.tag);
16531647 const node = src_loc.declRelativeToNodeIndex(node_off);
16541648 const full = switch (node_tags[node]) {
......@@ -1771,7 +1765,6 @@ pub const SrcLoc = struct {
17711765
17721766 .node_offset_fn_type_cc => |node_off| {
17731767 const tree = try src_loc.file_scope.getTree(gpa);
1774 const node_datas = tree.nodes.items(.data);
17751768 const node_tags = tree.nodes.items(.tag);
17761769 const node = src_loc.declRelativeToNodeIndex(node_off);
17771770 var params: [1]ast.Node.Index = undefined;
......@@ -1790,7 +1783,6 @@ pub const SrcLoc = struct {
17901783
17911784 .node_offset_fn_type_ret_ty => |node_off| {
17921785 const tree = try src_loc.file_scope.getTree(gpa);
1793 const node_datas = tree.nodes.items(.data);
17941786 const node_tags = tree.nodes.items(.tag);
17951787 const node = src_loc.declRelativeToNodeIndex(node_off);
17961788 var params: [1]ast.Node.Index = undefined;
......@@ -1810,7 +1802,6 @@ pub const SrcLoc = struct {
18101802 .node_offset_anyframe_type => |node_off| {
18111803 const tree = try src_loc.file_scope.getTree(gpa);
18121804 const node_datas = tree.nodes.items(.data);
1813 const node_tags = tree.nodes.items(.tag);
18141805 const parent_node = src_loc.declRelativeToNodeIndex(node_off);
18151806 const node = node_datas[parent_node].rhs;
18161807 const main_tokens = tree.nodes.items(.main_token);
......@@ -2502,7 +2493,6 @@ pub fn astGenFile(mod: *Module, file: *Scope.File, prog_node: *std.Progress.Node
25022493 @ptrCast([*]const u8, file.zir.instructions.items(.data).ptr);
25032494 if (data_has_safety_tag) {
25042495 // The `Data` union has a safety tag but in the file format we store it without.
2505 const tags = file.zir.instructions.items(.tag);
25062496 for (file.zir.instructions.items(.data)) |*data, i| {
25072497 const as_struct = @ptrCast(*const Stage1DataLayout, data);
25082498 safety_buffer[i] = as_struct.data;
......@@ -3386,7 +3376,6 @@ fn scanDecl(iter: *ScanDeclIter, decl_sub_index: usize, flags: u4) InnerError!vo
33863376 log.debug("scan existing {*} ({s}) of {*}", .{ decl, decl.name, namespace });
33873377 // Update the AST node of the decl; even if its contents are unchanged, it may
33883378 // have been re-ordered.
3389 const prev_src_node = decl.src_node;
33903379 decl.src_node = decl_node;
33913380 decl.src_line = line;
33923381
......@@ -4692,11 +4681,9 @@ pub fn analyzeUnionFields(mod: *Module, union_obj: *Union) InnerError!void {
46924681 const src: LazySrcLoc = .{ .node_offset = union_obj.node_offset };
46934682 extra_index += @boolToInt(small.has_src_node);
46944683
4695 const tag_type_ref = if (small.has_tag_type) blk: {
4696 const tag_type_ref = @intToEnum(Zir.Inst.Ref, zir.extra[extra_index]);
4684 if (small.has_tag_type) {
46974685 extra_index += 1;
4698 break :blk tag_type_ref;
4699 } else .none;
4686 }
47004687
47014688 const body_len = if (small.has_body_len) blk: {
47024689 const body_len = zir.extra[extra_index];
......@@ -4784,6 +4771,7 @@ pub fn analyzeUnionFields(mod: *Module, union_obj: *Union) InnerError!void {
47844771 cur_bit_bag >>= 1;
47854772 const unused = @truncate(u1, cur_bit_bag) != 0;
47864773 cur_bit_bag >>= 1;
4774 _ = unused;
47874775
47884776 const field_name_zir = zir.nullTerminatedString(zir.extra[extra_index]);
47894777 extra_index += 1;
......@@ -4800,11 +4788,9 @@ pub fn analyzeUnionFields(mod: *Module, union_obj: *Union) InnerError!void {
48004788 break :blk align_ref;
48014789 } else .none;
48024790
4803 const tag_ref: Zir.Inst.Ref = if (has_tag) blk: {
4804 const tag_ref = @intToEnum(Zir.Inst.Ref, zir.extra[extra_index]);
4791 if (has_tag) {
48054792 extra_index += 1;
4806 break :blk tag_ref;
4807 } else .none;
4793 }
48084794
48094795 // This string needs to outlive the ZIR code.
48104796 const field_name = try decl_arena.allocator.dupe(u8, field_name_zir);
src/Sema.zig+7-9
......@@ -1073,6 +1073,11 @@ fn zirOpaqueDecl(
10731073 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
10741074 const src = inst_data.src();
10751075 const extra = sema.code.extraData(Zir.Inst.Block, inst_data.payload_index);
1076 if (false) {
1077 inst_data;
1078 src;
1079 extra;
1080 }
10761081
10771082 return sema.mod.fail(&block.base, sema.src, "TODO implement zirOpaqueDecl", .{});
10781083}
......@@ -1230,7 +1235,6 @@ fn zirIndexablePtrLen(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) In
12301235
12311236fn zirArg(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst {
12321237 const inst_data = sema.code.instructions.items(.data)[inst].str_tok;
1233 const src = inst_data.src();
12341238 const arg_name = inst_data.get(sema.code);
12351239 const arg_index = sema.next_arg_index;
12361240 sema.next_arg_index += 1;
......@@ -3005,7 +3009,6 @@ fn zirFunc(
30053009 defer tracy.end();
30063010
30073011 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
3008 const src = inst_data.src();
30093012 const extra = sema.code.extraData(Zir.Inst.Func, inst_data.payload_index);
30103013 const param_types = sema.code.refSlice(extra.end, extra.data.param_types_len);
30113014
......@@ -3332,9 +3335,7 @@ fn zirBitcast(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError
33323335 defer tracy.end();
33333336
33343337 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
3335 const src = inst_data.src();
33363338 const dest_ty_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };
3337 const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node };
33383339 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;
33393340
33403341 const dest_type = try sema.resolveType(block, dest_ty_src, extra.lhs);
......@@ -3653,7 +3654,6 @@ fn analyzeSwitch(
36533654 extra_index += 1;
36543655 const body_len = sema.code.extra[extra_index];
36553656 extra_index += 1;
3656 const body = sema.code.extra[extra_index..][0..body_len];
36573657 extra_index += body_len;
36583658
36593659 try sema.validateSwitchItemEnum(
......@@ -3763,7 +3763,6 @@ fn analyzeSwitch(
37633763 extra_index += 1;
37643764 const body_len = sema.code.extra[extra_index];
37653765 extra_index += 1;
3766 const body = sema.code.extra[extra_index..][0..body_len];
37673766 extra_index += body_len;
37683767
37693768 try sema.validateSwitchItem(
......@@ -3859,7 +3858,6 @@ fn analyzeSwitch(
38593858 extra_index += 1;
38603859 const body_len = sema.code.extra[extra_index];
38613860 extra_index += 1;
3862 const body = sema.code.extra[extra_index..][0..body_len];
38633861 extra_index += body_len;
38643862
38653863 try sema.validateSwitchItemBool(
......@@ -3942,7 +3940,6 @@ fn analyzeSwitch(
39423940 extra_index += 1;
39433941 const body_len = sema.code.extra[extra_index];
39443942 extra_index += 1;
3945 const body = sema.code.extra[extra_index..][0..body_len];
39463943 extra_index += body_len;
39473944
39483945 try sema.validateSwitchItemSparse(
......@@ -4457,6 +4454,7 @@ fn validateSwitchNoRange(
44574454fn zirHasField(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst {
44584455 const inst_data = sema.code.instructions.items(.data)[inst].pl_node;
44594456 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;
4457 _ = extra;
44604458 const src = inst_data.src();
44614459
44624460 return sema.mod.fail(&block.base, src, "TODO implement zirHasField", .{});
......@@ -6035,7 +6033,6 @@ fn zirVarExtended(
60356033) InnerError!*Inst {
60366034 const extra = sema.code.extraData(Zir.Inst.ExtendedVar, extended.operand);
60376035 const src = sema.src;
6038 const align_src: LazySrcLoc = src; // TODO add a LazySrcLoc that points at align
60396036 const ty_src: LazySrcLoc = src; // TODO add a LazySrcLoc that points at type
60406037 const mut_src: LazySrcLoc = src; // TODO add a LazySrcLoc that points at mut token
60416038 const init_src: LazySrcLoc = src; // TODO add a LazySrcLoc that points at init expr
......@@ -7131,6 +7128,7 @@ fn analyzeSlice(
71317128 ptr_child.isVolatilePtr(),
71327129 return_ptr_size,
71337130 );
7131 _ = return_type;
71347132
71357133 return sema.mod.fail(&block.base, src, "TODO implement analysis of slice", .{});
71367134}
src/ThreadPool.zig+2-2
......@@ -101,7 +101,7 @@ pub fn deinit(self: *ThreadPool) void {
101101
102102pub fn spawn(self: *ThreadPool, comptime func: anytype, args: anytype) !void {
103103 if (std.builtin.single_threaded) {
104 const result = @call(.{}, func, args);
104 @call(.{}, func, args);
105105 return;
106106 }
107107
......@@ -114,7 +114,7 @@ pub fn spawn(self: *ThreadPool, comptime func: anytype, args: anytype) !void {
114114 fn runFn(runnable: *Runnable) void {
115115 const run_node = @fieldParentPtr(RunQueue.Node, "data", runnable);
116116 const closure = @fieldParentPtr(@This(), "run_node", run_node);
117 const result = @call(.{}, func, closure.arguments);
117 @call(.{}, func, closure.arguments);
118118
119119 const held = closure.pool.lock.acquire();
120120 defer held.release();
src/Zir.zig+3-4
......@@ -3176,6 +3176,7 @@ const Writer = struct {
31763176 inst: Inst.Index,
31773177 ) (@TypeOf(stream).Error || error{OutOfMemory})!void {
31783178 const inst_data = self.code.instructions.items(.data)[inst].array_type_sentinel;
3179 _ = inst_data;
31793180 try stream.writeAll("TODO)");
31803181 }
31813182
......@@ -3213,6 +3214,7 @@ const Writer = struct {
32133214 inst: Inst.Index,
32143215 ) (@TypeOf(stream).Error || error{OutOfMemory})!void {
32153216 const inst_data = self.code.instructions.items(.data)[inst].ptr_type;
3217 _ = inst_data;
32163218 try stream.writeAll("TODO)");
32173219 }
32183220
......@@ -4739,7 +4741,6 @@ fn findDeclsSwitch(
47394741 var extra_index: usize = special.end;
47404742 var scalar_i: usize = 0;
47414743 while (scalar_i < extra.data.cases_len) : (scalar_i += 1) {
4742 const item_ref = @intToEnum(Inst.Ref, zir.extra[extra_index]);
47434744 extra_index += 1;
47444745 const body_len = zir.extra[extra_index];
47454746 extra_index += 1;
......@@ -4779,7 +4780,6 @@ fn findDeclsSwitchMulti(
47794780 {
47804781 var scalar_i: usize = 0;
47814782 while (scalar_i < extra.data.scalar_cases_len) : (scalar_i += 1) {
4782 const item_ref = @intToEnum(Inst.Ref, zir.extra[extra_index]);
47834783 extra_index += 1;
47844784 const body_len = zir.extra[extra_index];
47854785 extra_index += 1;
......@@ -4800,12 +4800,11 @@ fn findDeclsSwitchMulti(
48004800 extra_index += 1;
48014801 const items = zir.refSlice(extra_index, items_len);
48024802 extra_index += items_len;
4803 _ = items;
48034804
48044805 var range_i: usize = 0;
48054806 while (range_i < ranges_len) : (range_i += 1) {
4806 const item_first = @intToEnum(Inst.Ref, zir.extra[extra_index]);
48074807 extra_index += 1;
4808 const item_last = @intToEnum(Inst.Ref, zir.extra[extra_index]);
48094808 extra_index += 1;
48104809 }
48114810
src/codegen.zig-1
......@@ -118,7 +118,6 @@ pub fn generateSymbol(
118118 if (typed_value.ty.sentinel()) |sentinel| {
119119 try code.ensureCapacity(code.items.len + payload.data.len + 1);
120120 code.appendSliceAssumeCapacity(payload.data);
121 const prev_len = code.items.len;
122121 switch (try generateSymbol(bin_file, src_loc, .{
123122 .ty = typed_value.ty.elemType(),
124123 .val = sentinel,
src/codegen/c.zig-1
......@@ -1107,7 +1107,6 @@ fn genAsm(o: *Object, as: *Inst.Assembly) !CValue {
11071107 for (as.inputs) |i, index| {
11081108 if (i[0] == '{' and i[i.len - 1] == '}') {
11091109 const reg = i[1 .. i.len - 1];
1110 const arg = as.args[index];
11111110 if (index > 0) {
11121111 try writer.writeAll(", ");
11131112 }
src/codegen/spirv.zig+1-3
......@@ -714,7 +714,6 @@ pub const DeclGen = struct {
714714 return self.fail(inst.base.src, "TODO: SPIR-V backend: binary operations for strange integers", .{});
715715 }
716716
717 const is_bool = info.class == .bool;
718717 const is_float = info.class == .float;
719718 const is_signed = info.signedness == .signed;
720719 // **Note**: All these operations must be valid for vectors as well!
......@@ -802,8 +801,6 @@ pub const DeclGen = struct {
802801 const result_id = self.spv.allocResultId();
803802 const result_type_id = try self.genType(inst.base.src, inst.base.ty);
804803
805 const info = try self.arithmeticTypeInfo(inst.operand.ty);
806
807804 const opcode = switch (inst.base.tag) {
808805 // Bool -> bool
809806 .not => Opcode.OpLogicalNot,
......@@ -867,6 +864,7 @@ pub const DeclGen = struct {
867864 // are not allowed to be created from a phi node, and throw an error for those. For now, genType already throws
868865 // an error for pointers.
869866 const result_type_id = try self.genType(inst.base.src, inst.base.ty);
867 _ = result_type_id;
870868
871869 try writeOpcode(&self.code, .OpPhi, 2 + @intCast(u16, incoming_blocks.items.len * 2)); // result type + result + variable/parent...
872870
src/codegen/wasm.zig-3
......@@ -849,7 +849,6 @@ pub const Context = struct {
849849 }
850850
851851 fn genCall(self: *Context, inst: *Inst.Call) InnerError!WValue {
852 const func_inst = inst.func.castTag(.constant).?;
853852 const func_val = inst.func.value().?;
854853
855854 const target: *Decl = blk: {
......@@ -1146,8 +1145,6 @@ pub const Context = struct {
11461145 }
11471146
11481147 fn genCmp(self: *Context, inst: *Inst.BinOp, op: std.math.CompareOperator) InnerError!WValue {
1149 const ty = inst.lhs.ty.tag();
1150
11511148 // save offset, so potential conditions can insert blocks in front of
11521149 // the comparison that we can later jump back to
11531150 const offset = self.code.items.len;
src/glibc.zig-1
......@@ -497,7 +497,6 @@ fn add_include_dirs(comp: *Compilation, arena: *Allocator, args: *std.ArrayList(
497497 const target = comp.getTarget();
498498 const arch = target.cpu.arch;
499499 const opt_nptl: ?[]const u8 = if (target.os.tag == .linux) "nptl" else "htl";
500 const glibc = try lib_path(comp, arena, lib_libc ++ "glibc");
501500
502501 const s = path.sep_str;
503502
src/link/MachO.zig-3
......@@ -2918,7 +2918,6 @@ fn relocateSymbolTable(self: *MachO) !void {
29182918 const nsyms = nlocals + nglobals + nundefs;
29192919
29202920 if (symtab.nsyms < nsyms) {
2921 const linkedit_segment = self.load_commands.items[self.linkedit_segment_cmd_index.?].Segment;
29222921 const needed_size = nsyms * @sizeOf(macho.nlist_64);
29232922 if (needed_size > self.allocatedSizeLinkedit(symtab.symoff)) {
29242923 // Move the entire symbol table to a new location
......@@ -3150,7 +3149,6 @@ fn writeExportTrie(self: *MachO) !void {
31503149 const nwritten = try trie.write(stream.writer());
31513150 assert(nwritten == trie.size);
31523151
3153 const linkedit_segment = self.load_commands.items[self.linkedit_segment_cmd_index.?].Segment;
31543152 const dyld_info = &self.load_commands.items[self.dyld_info_cmd_index.?].DyldInfoOnly;
31553153 const allocated_size = self.allocatedSizeLinkedit(dyld_info.export_off);
31563154 const needed_size = mem.alignForwardGeneric(u64, buffer.len, @alignOf(u64));
......@@ -3357,7 +3355,6 @@ fn populateLazyBindOffsetsInStubHelper(self: *MachO, buffer: []const u8) !void {
33573355 error.EndOfStream => break,
33583356 else => return err,
33593357 };
3360 const imm: u8 = inst & macho.BIND_IMMEDIATE_MASK;
33613358 const opcode: u8 = inst & macho.BIND_OPCODE_MASK;
33623359
33633360 switch (opcode) {
src/link/MachO/DebugSymbols.zig-7
......@@ -500,7 +500,6 @@ pub fn flushModule(self: *DebugSymbols, allocator: *Allocator, options: link.Opt
500500 if (self.debug_aranges_section_dirty) {
501501 const dwarf_segment = &self.load_commands.items[self.dwarf_segment_cmd_index.?].Segment;
502502 const debug_aranges_sect = &dwarf_segment.sections.items[self.debug_aranges_section_index.?];
503 const debug_info_sect = dwarf_segment.sections.items[self.debug_info_section_index.?];
504503
505504 var di_buf = std.ArrayList(u8).init(allocator);
506505 defer di_buf.deinit();
......@@ -844,7 +843,6 @@ fn relocateSymbolTable(self: *DebugSymbols) !void {
844843 const nsyms = nlocals + nglobals;
845844
846845 if (symtab.nsyms < nsyms) {
847 const linkedit_segment = self.load_commands.items[self.linkedit_segment_cmd_index.?].Segment;
848846 const needed_size = nsyms * @sizeOf(macho.nlist_64);
849847 if (needed_size > self.allocatedSizeLinkedit(symtab.symoff)) {
850848 // Move the entire symbol table to a new location
......@@ -904,11 +902,6 @@ pub fn updateDeclLineNumber(self: *DebugSymbols, module: *Module, decl: *const M
904902 const tracy = trace(@src());
905903 defer tracy.end();
906904
907 const tree = decl.namespace.file_scope.tree;
908 const node_tags = tree.nodes.items(.tag);
909 const node_datas = tree.nodes.items(.data);
910 const token_starts = tree.tokens.items(.start);
911
912905 const func = decl.val.castTag(.function).?.data;
913906 const line_off = @intCast(u28, decl.src_line + func.lbrace_line);
914907
src/link/MachO/Object.zig-1
......@@ -478,7 +478,6 @@ pub fn parseDebugInfo(self: *Object) !void {
478478
479479 self.tu_path = try std.fs.path.join(self.allocator, &[_][]const u8{ comp_dir, name });
480480 self.tu_mtime = mtime: {
481 var buffer: [std.fs.MAX_PATH_BYTES]u8 = undefined;
482481 const stat = try self.file.?.stat();
483482 break :mtime @intCast(u64, @divFloor(stat.mtime, 1_000_000_000));
484483 };
src/link/MachO/Zld.zig+1-5
......@@ -432,7 +432,6 @@ fn mapAndUpdateSections(
432432
433433fn updateMetadata(self: *Zld) !void {
434434 for (self.objects.items) |object| {
435 const object_seg = object.load_commands.items[object.segment_cmd_index.?].Segment;
436435 const text_seg = &self.load_commands.items[self.text_segment_cmd_index.?].Segment;
437436 const data_const_seg = &self.load_commands.items[self.data_const_segment_cmd_index.?].Segment;
438437 const data_seg = &self.load_commands.items[self.data_segment_cmd_index.?].Segment;
......@@ -1294,7 +1293,6 @@ fn allocateLinkeditSegment(self: *Zld) void {
12941293}
12951294
12961295fn allocateSegment(self: *Zld, index: u16, offset: u64) !void {
1297 const base_vmaddr = self.load_commands.items[self.pagezero_segment_cmd_index.?].Segment.inner.vmsize;
12981296 const seg = &self.load_commands.items[index].Segment;
12991297
13001298 // Allocate the sections according to their alignment at the beginning of the segment.
......@@ -1427,7 +1425,6 @@ fn writeStubHelperCommon(self: *Zld) !void {
14271425 const got = &data_const_segment.sections.items[self.got_section_index.?];
14281426 const data_segment = &self.load_commands.items[self.data_segment_cmd_index.?].Segment;
14291427 const data = &data_segment.sections.items[self.data_section_index.?];
1430 const la_symbol_ptr = data_segment.sections.items[self.la_symbol_ptr_section_index.?];
14311428
14321429 self.stub_helper_stubs_start_off = blk: {
14331430 switch (self.arch.?) {
......@@ -2654,7 +2651,6 @@ fn setEntryPoint(self: *Zld) !void {
26542651 // TODO we should respect the -entry flag passed in by the user to set a custom
26552652 // entrypoint. For now, assume default of `_main`.
26562653 const seg = self.load_commands.items[self.text_segment_cmd_index.?].Segment;
2657 const text = seg.sections.items[self.text_section_index.?];
26582654 const sym = self.globals.get("_main") orelse return error.MissingMainEntrypoint;
26592655 const entry_sym = sym.cast(Symbol.Regular) orelse unreachable;
26602656 const ec = &self.load_commands.items[self.main_cmd_index.?].Main;
......@@ -2862,7 +2858,6 @@ fn populateLazyBindOffsetsInStubHelper(self: *Zld, buffer: []const u8) !void {
28622858 error.EndOfStream => break,
28632859 else => return err,
28642860 };
2865 const imm: u8 = inst & macho.BIND_IMMEDIATE_MASK;
28662861 const opcode: u8 = inst & macho.BIND_OPCODE_MASK;
28672862
28682863 switch (opcode) {
......@@ -2959,6 +2954,7 @@ fn writeDebugInfo(self: *Zld) !void {
29592954 for (self.objects.items) |object| {
29602955 const tu_path = object.tu_path orelse continue;
29612956 const tu_mtime = object.tu_mtime orelse continue;
2957 _ = tu_mtime;
29622958 const dirname = std.fs.path.dirname(tu_path) orelse "./";
29632959 // Current dir
29642960 try stabs.append(.{
src/link/MachO/reloc/x86_64.zig-1
......@@ -175,7 +175,6 @@ pub const Parser = struct {
175175
176176 const rel_type = @intToEnum(macho.reloc_type_x86_64, rel.r_type);
177177 const target = Relocation.Target.from_reloc(rel, parser.symbols);
178 const is_extern = rel.r_extern == 1;
179178
180179 const offset = @intCast(u32, rel.r_address);
181180 const inst = parser.code[offset..][0..4];
src/link/Wasm.zig-1
......@@ -496,7 +496,6 @@ pub fn flushModule(self: *Wasm, comp: *Compilation) !void {
496496 if (data_size != 0) {
497497 const header_offset = try reserveVecSectionHeader(file);
498498 const writer = file.writer();
499 var len: u32 = 0;
500499 // index to memory section (currently, there can only be 1 memory section in wasm)
501500 try leb.writeULEB128(writer, @as(u32, 0));
502501
src/main.zig-1
......@@ -3749,7 +3749,6 @@ pub fn cmdAstCheck(
37493749
37503750 var color: Color = .auto;
37513751 var want_output_text = false;
3752 var have_zig_source_file = false;
37533752 var zig_source_file: ?[]const u8 = null;
37543753
37553754 var i: usize = 0;
src/mingw.zig-2
......@@ -372,11 +372,9 @@ pub fn buildImportLib(comp: *Compilation, lib_name: []const u8) !void {
372372
373373 try child.spawn();
374374
375 const stdout_reader = child.stdout.?.reader();
376375 const stderr_reader = child.stderr.?.reader();
377376
378377 // TODO https://github.com/ziglang/zig/issues/6343
379 const stdout = try stdout_reader.readAllAlloc(arena, std.math.maxInt(u32));
380378 const stderr = try stderr_reader.readAllAlloc(arena, 10 * 1024 * 1024);
381379
382380 const term = child.wait() catch |err| {
src/musl.zig-1
......@@ -143,7 +143,6 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile) !void {
143143 const dirname = path.dirname(src_file).?;
144144 const basename = path.basename(src_file);
145145 const noextbasename = basename[0 .. basename.len - std.fs.path.extension(basename).len];
146 const before_arch_dir = path.dirname(dirname).?;
147146 const dirbasename = path.basename(dirname);
148147
149148 var is_arch_specific = false;
src/register_manager.zig-12
......@@ -281,12 +281,6 @@ test "default state" {
281281 };
282282 defer function.deinit();
283283
284 var mock_instruction = ir.Inst{
285 .tag = .breakpoint,
286 .ty = Type.initTag(.void),
287 .src = .unneeded,
288 };
289
290284 try expect(!function.register_manager.isRegAllocated(.r2));
291285 try expect(!function.register_manager.isRegAllocated(.r3));
292286 try expect(function.register_manager.isRegFree(.r2));
......@@ -365,12 +359,6 @@ test "tryAllocRegs" {
365359 };
366360 defer function.deinit();
367361
368 var mock_instruction = ir.Inst{
369 .tag = .breakpoint,
370 .ty = Type.initTag(.void),
371 .src = .unneeded,
372 };
373
374362 try expectEqual([_]MockRegister2{ .r0, .r1, .r2 }, function.register_manager.tryAllocRegs(3, .{ null, null, null }, &.{}).?);
375363
376364 // Exceptions
src/translate_c.zig-4
......@@ -1321,7 +1321,6 @@ fn transConvertVectorExpr(
13211321 const src_type = qualTypeCanon(src_expr.getType());
13221322 const src_vector_ty = @ptrCast(*const clang.VectorType, src_type);
13231323 const src_element_qt = src_vector_ty.getElementType();
1324 const src_element_type_node = try transQualType(c, &block_scope.base, src_element_qt, base_stmt.getBeginLoc());
13251324
13261325 const src_expr_node = try transExpr(c, &block_scope.base, src_expr, .used);
13271326
......@@ -3802,7 +3801,6 @@ fn transBinaryConditionalOperator(c: *Context, scope: *Scope, stmt: *const clang
38023801 const res_is_bool = qualTypeIsBoolean(qt);
38033802 const casted_stmt = @ptrCast(*const clang.AbstractConditionalOperator, stmt);
38043803 const cond_expr = casted_stmt.getCond();
3805 const true_expr = casted_stmt.getTrueExpr();
38063804 const false_expr = casted_stmt.getFalseExpr();
38073805
38083806 // c: (cond_expr)?:(false_expr)
......@@ -4336,8 +4334,6 @@ fn transCreateNodeNumber(c: *Context, num: anytype, num_kind: enum { int, float
43364334}
43374335
43384336fn transCreateNodeMacroFn(c: *Context, name: []const u8, ref: Node, proto_alias: *ast.Payload.Func) !Node {
4339 const scope = &c.global_scope.base;
4340
43414337 var fn_params = std.ArrayList(ast.Payload.Param).init(c.gpa);
43424338 defer fn_params.deinit();
43434339
src/type.zig+1-2
......@@ -3013,7 +3013,7 @@ pub const Type = extern union {
30133013 .base = .{ .tag = t },
30143014 .data = data,
30153015 };
3016 return Type{ .ptr_otherwise = &ptr.base };
3016 return file_struct.Type{ .ptr_otherwise = &ptr.base };
30173017 }
30183018
30193019 pub fn Data(comptime t: Tag) type {
......@@ -3163,7 +3163,6 @@ pub const CType = enum {
31633163 longdouble,
31643164
31653165 pub fn sizeInBits(self: CType, target: Target) u16 {
3166 const arch = target.cpu.arch;
31673166 switch (target.os.tag) {
31683167 .freestanding, .other => switch (target.cpu.arch) {
31693168 .msp430 => switch (self) {
test/behavior/async_fn.zig+16
......@@ -13,6 +13,7 @@ test "simple coroutine suspend and resume" {
1313 resume frame;
1414 try expect(global_x == 3);
1515 const af: anyframe->void = &frame;
16 _ = af;
1617 resume frame;
1718 try expect(global_x == 4);
1819}
......@@ -45,6 +46,7 @@ test "suspend at end of function" {
4546 fn doTheTest() !void {
4647 try expect(x == 1);
4748 const p = async suspendAtEnd();
49 _ = p;
4850 try expect(x == 2);
4951 }
5052
......@@ -132,6 +134,7 @@ test "@frameSize" {
132134 }
133135 fn other(param: i32) void {
134136 var local: i32 = undefined;
137 _ = local;
135138 suspend {}
136139 }
137140 };
......@@ -181,6 +184,7 @@ test "coroutine suspend, resume" {
181184
182185test "coroutine suspend with block" {
183186 const p = async testSuspendBlock();
187 _ = p;
184188 try expect(!global_result);
185189 resume a_promise;
186190 try expect(global_result);
......@@ -207,6 +211,7 @@ var await_final_result: i32 = 0;
207211test "coroutine await" {
208212 await_seq('a');
209213 var p = async await_amain();
214 _ = p;
210215 await_seq('f');
211216 resume await_a_promise;
212217 await_seq('i');
......@@ -243,6 +248,7 @@ var early_final_result: i32 = 0;
243248test "coroutine await early return" {
244249 early_seq('a');
245250 var p = async early_amain();
251 _ = p;
246252 early_seq('f');
247253 try expect(early_final_result == 1234);
248254 try expect(std.mem.eql(u8, &early_points, "abcdef"));
......@@ -276,6 +282,7 @@ test "async function with dot syntax" {
276282 }
277283 };
278284 const p = async S.foo();
285 _ = p;
279286 try expect(S.y == 2);
280287}
281288
......@@ -362,11 +369,13 @@ test "error return trace across suspend points - early return" {
362369 const p = nonFailing();
363370 resume p;
364371 const p2 = async printTrace(p);
372 _ = p2;
365373}
366374
367375test "error return trace across suspend points - async return" {
368376 const p = nonFailing();
369377 const p2 = async printTrace(p);
378 _ = p2;
370379 resume p;
371380}
372381
......@@ -396,6 +405,7 @@ fn printTrace(p: anyframe->(anyerror!void)) callconv(.Async) void {
396405test "break from suspend" {
397406 var my_result: i32 = 1;
398407 const p = async testBreakFromSuspend(&my_result);
408 _ = p;
399409 try std.testing.expect(my_result == 2);
400410}
401411fn testBreakFromSuspend(my_result: *i32) callconv(.Async) void {
......@@ -619,6 +629,7 @@ test "returning a const error from async function" {
619629 fn amain() !void {
620630 var download_frame = async fetchUrl(10, "a string");
621631 const download_text = try await download_frame;
632 _ = download_text;
622633
623634 @panic("should not get here");
624635 }
......@@ -730,6 +741,7 @@ test "alignment of local variables in async functions" {
730741 const S = struct {
731742 fn doTheTest() !void {
732743 var y: u8 = 123;
744 _ = y;
733745 var x: u8 align(128) = 1;
734746 try expect(@ptrToInt(&x) % 128 == 0);
735747 }
......@@ -742,6 +754,7 @@ test "no reason to resolve frame still works" {
742754}
743755fn simpleNothing() void {
744756 var x: i32 = 1234;
757 _ = x;
745758}
746759
747760test "async call a generic function" {
......@@ -802,6 +815,7 @@ test "struct parameter to async function is copied to the frame" {
802815 if (x == 0) return;
803816 clobberStack(x - 1);
804817 var y: i32 = x;
818 _ = y;
805819 }
806820
807821 fn bar(f: *@Frame(foo)) void {
......@@ -1654,6 +1668,7 @@ test "@asyncCall with pass-by-value arguments" {
16541668 [_]u8{ 1, 2, 3, 4, 5 },
16551669 F2,
16561670 });
1671 _ = frame_ptr;
16571672}
16581673
16591674test "@asyncCall with arguments having non-standard alignment" {
......@@ -1673,4 +1688,5 @@ test "@asyncCall with arguments having non-standard alignment" {
16731688 // The function pointer must not be comptime-known.
16741689 var t = S.f;
16751690 var frame_ptr = @asyncCall(&buffer, {}, t, .{ F0, undefined, F1 });
1691 _ = frame_ptr;
16761692}
test/behavior/atomics.zig-2
......@@ -97,7 +97,6 @@ test "cmpxchg with ptr" {
9797
9898test "cmpxchg with ignored result" {
9999 var x: i32 = 1234;
100 var ptr = &x;
101100
102101 _ = @cmpxchgStrong(i32, &x, 1234, 5678, .Monotonic, .Monotonic);
103102
......@@ -195,7 +194,6 @@ fn testAtomicRmwInt() !void {
195194test "atomics with different types" {
196195 try testAtomicsWithType(bool, true, false);
197196 inline for (.{ u1, i4, u5, i15, u24 }) |T| {
198 var x: T = 0;
199197 try testAtomicsWithType(T, 0, 1);
200198 }
201199 try testAtomicsWithType(u0, 0, 0);
test/behavior/await_struct.zig+1
......@@ -12,6 +12,7 @@ var await_final_result = Foo{ .x = 0 };
1212test "coroutine await struct" {
1313 await_seq('a');
1414 var p = async await_amain();
15 _ = p;
1516 await_seq('f');
1617 resume await_a_promise;
1718 await_seq('i');
test/behavior/bit_shifting.zig+1-1
......@@ -100,5 +100,5 @@ test "comptime shr of BigInt" {
100100}
101101
102102test "comptime shift safety check" {
103 const x = @as(usize, 42) << @sizeOf(usize);
103 _ = @as(usize, 42) << @sizeOf(usize);
104104}
test/behavior/bugs/1467.zig+1
......@@ -4,4 +4,5 @@ pub const S = extern struct {
44};
55test "bug 1467" {
66 const s: S = undefined;
7 _ = s;
78}
test/behavior/bugs/1500.zig+4
......@@ -7,4 +7,8 @@ const B = fn (A) void;
77test "allow these dependencies" {
88 var a: A = undefined;
99 var b: B = undefined;
10 if (false) {
11 a;
12 b;
13 }
1014}
test/behavior/bugs/2346.zig+2
......@@ -1,6 +1,8 @@
11test "fixed" {
22 const a: *void = undefined;
33 const b: *[1]void = a;
4 _ = b;
45 const c: *[0]u8 = undefined;
56 const d: []u8 = c;
7 _ = d;
68}
test/behavior/bugs/3586.zig+1
......@@ -8,4 +8,5 @@ test "fixed" {
88 var ctr = Container{
99 .params = NoteParams{},
1010 };
11 _ = ctr;
1112}
test/behavior/bugs/4954.zig+1-1
......@@ -1,5 +1,5 @@
11fn f(buf: []u8) void {
2 var ptr = &buf[@sizeOf(u32)];
2 _ = &buf[@sizeOf(u32)];
33}
44
55test "crash" {
test/behavior/bugs/7003.zig+1
......@@ -5,4 +5,5 @@ test "@Type should resolve its children types" {
55 comptime var sparse_info = @typeInfo(anyerror!sparse);
66 sparse_info.ErrorUnion.payload = dense;
77 const B = @Type(sparse_info);
8 _ = B;
89}
test/behavior/bugs/828.zig+4
......@@ -30,4 +30,8 @@ test "comptime struct return should not return the same instance" {
3030 //a second parameter is required to trigger the bug
3131 const ValA = constCount(&CountBy.One, 12);
3232 const ValB = constCount(&CountBy.One, 15);
33 if (false) {
34 ValA;
35 ValB;
36 }
3337}
test/behavior/cast.zig+3
......@@ -102,6 +102,7 @@ fn castToOptionalTypeError(z: i32) !void {
102102
103103 const f = z;
104104 const g: anyerror!?i32 = f;
105 _ = g catch {};
105106
106107 const a = A{ .a = z };
107108 const b: anyerror!?A = a;
......@@ -114,7 +115,9 @@ test "implicitly cast from int to anyerror!?T" {
114115}
115116fn implicitIntLitToOptional() void {
116117 const f: ?i32 = 1;
118 _ = f;
117119 const g: anyerror!?i32 = 1;
120 _ = g catch {};
118121}
119122
120123test "return null from fn() anyerror!?&T" {
test/behavior/enum.zig+2
......@@ -111,6 +111,8 @@ test "enum type" {
111111 .y = 5678,
112112 },
113113 };
114 try expect(foo1.One == 13);
115 try expect(foo2.Two.x == 1234 and foo2.Two.y == 5678);
114116 const bar = Bar.B;
115117
116118 try expect(bar == Bar.B);
test/behavior/error.zig+5-1
......@@ -103,6 +103,7 @@ fn testErrorSetType() !void {
103103
104104 const a: MyErrSet!i32 = 5678;
105105 const b: MyErrSet!i32 = MyErrSet.OutOfMemory;
106 try expect(b catch error.OutOfMemory == error.OutOfMemory);
106107
107108 if (a) |value| try expect(value == 5678) else |err| switch (err) {
108109 error.OutOfMemory => unreachable,
......@@ -162,6 +163,7 @@ fn testErrToIntWithOnePossibleValue(
162163
163164test "empty error union" {
164165 const x = error{} || error{};
166 _ = x;
165167}
166168
167169test "error union peer type resolution" {
......@@ -204,6 +206,7 @@ fn entry() void {
204206
205207fn foo2(f: fn () anyerror!void) void {
206208 const x = f();
209 x catch {};
207210}
208211
209212fn bar2() (error{}!void) {}
......@@ -338,6 +341,7 @@ test "optional error set is the same size as error set" {
338341test "debug info for optional error set" {
339342 const SomeError = error{Hello};
340343 var a_local_variable: ?SomeError = null;
344 _ = a_local_variable;
341345}
342346
343347test "nested catch" {
......@@ -349,7 +353,7 @@ test "nested catch" {
349353 return error.Wrong;
350354 }
351355 fn func() anyerror!Foo {
352 const x = fail() catch
356 _ = fail() catch
353357 fail() catch
354358 return error.Bad;
355359 unreachable;
test/behavior/eval.zig+2
......@@ -184,6 +184,7 @@ fn testTryToTrickEvalWithRuntimeIf(b: bool) usize {
184184 comptime var i: usize = 0;
185185 inline while (i < 10) : (i += 1) {
186186 const result = if (b) false else true;
187 _ = result;
187188 }
188189 comptime {
189190 return i;
......@@ -195,6 +196,7 @@ test "inlined loop has array literal with elided runtime scope on first iteratio
195196 comptime var i: usize = 0;
196197 inline while (i < 2) : (i += 1) {
197198 const result = if (i == 0) [1]i32{2} else runtime;
199 _ = result;
198200 }
199201 comptime {
200202 try expect(i == 2);
test/behavior/import.zig+1-1
......@@ -18,5 +18,5 @@ test "import in non-toplevel scope" {
1818}
1919
2020test "import empty file" {
21 const empty = @import("import/empty.zig");
21 _ = @import("import/empty.zig");
2222}
test/behavior/inttoptr.zig+1-1
......@@ -5,7 +5,7 @@ test "casting random address to function pointer" {
55
66fn randomAddressToFunction() void {
77 var addr: usize = 0xdeadbeef;
8 var ptr = @intToPtr(fn () void, addr);
8 _ = @intToPtr(fn () void, addr);
99}
1010
1111test "mutate through ptr initialized with constant intToPtr value" {
test/behavior/ir_block_deps.zig+1
......@@ -5,6 +5,7 @@ fn foo(id: u64) !i32 {
55 1 => getErrInt(),
66 2 => {
77 const size = try getErrInt();
8 _ = size;
89 return try getErrInt();
910 },
1011 else => error.ItBroke,
test/behavior/math.zig+11
......@@ -333,6 +333,12 @@ test "quad hex float literal parsing in range" {
333333 const b = 0x1.dedafcff354b6ae9758763545432p-9;
334334 const c = 0x1.2f34dd5f437e849b4baab754cdefp+4534;
335335 const d = 0x1.edcbff8ad76ab5bf46463233214fp-435;
336 if (false) {
337 a;
338 b;
339 c;
340 d;
341 }
336342}
337343
338344test "quad hex float literal parsing accurate" {
......@@ -457,6 +463,11 @@ test "hex float literal within range" {
457463 const a = 0x1.0p16383;
458464 const b = 0x0.1p16387;
459465 const c = 0x1.0p-16382;
466 if (false) {
467 a;
468 b;
469 c;
470 }
460471}
461472
462473test "truncating shift left" {
test/behavior/misc.zig+1
......@@ -234,6 +234,7 @@ test "compile time global reinterpret" {
234234test "explicit cast maybe pointers" {
235235 const a: ?*i32 = undefined;
236236 const b: ?*f32 = @ptrCast(?*f32, a);
237 _ = b;
237238}
238239
239240test "generic malloc free" {
test/behavior/null.zig+1
......@@ -39,6 +39,7 @@ test "test maybe object and get a pointer to the inner value" {
3939test "rhs maybe unwrap return" {
4040 const x: ?bool = true;
4141 const y = x orelse return;
42 _ = y;
4243}
4344
4445test "maybe return" {
test/behavior/optional.zig+1
......@@ -128,6 +128,7 @@ test "nested orelse" {
128128 const x = maybe() orelse
129129 maybe() orelse
130130 return null;
131 _ = x;
131132 unreachable;
132133 }
133134 const Foo = struct {
test/behavior/pointers.zig+5-1
......@@ -65,6 +65,10 @@ test "assigning integer to C pointer" {
6565 var x: i32 = 0;
6666 var ptr: [*c]u8 = 0;
6767 var ptr2: [*c]u8 = x;
68 if (false) {
69 ptr;
70 ptr2;
71 }
6872}
6973
7074test "implicit cast single item pointer to C pointer and back" {
......@@ -78,7 +82,6 @@ test "implicit cast single item pointer to C pointer and back" {
7882test "C pointer comparison and arithmetic" {
7983 const S = struct {
8084 fn doTheTest() !void {
81 var one: usize = 1;
8285 var ptr1: [*c]u32 = 0;
8386 var ptr2 = ptr1 + 10;
8487 try expect(ptr1 == 0);
......@@ -325,6 +328,7 @@ test "@ptrToInt on null optional at comptime" {
325328 {
326329 const pointer = @intToPtr(?*u8, 0x000);
327330 const x = @ptrToInt(pointer);
331 _ = x;
328332 comptime try expect(0 == @ptrToInt(pointer));
329333 }
330334 {
test/behavior/sizeof_and_typeof.zig+2-2
......@@ -195,11 +195,11 @@ test "branching logic inside @TypeOf" {
195195
196196fn fn1(alpha: bool) void {
197197 const n: usize = 7;
198 const v = if (alpha) n else @sizeOf(usize);
198 _ = if (alpha) n else @sizeOf(usize);
199199}
200200
201201test "lazy @sizeOf result is checked for definedness" {
202 const f = fn1;
202 _ = fn1;
203203}
204204
205205test "@bitSizeOf" {
test/behavior/slice.zig+1
......@@ -104,6 +104,7 @@ test "obtaining a null terminated slice" {
104104
105105 // now we obtain a null terminated slice:
106106 const ptr = buf[0..3 :0];
107 _ = ptr;
107108
108109 var runtime_len: usize = 3;
109110 const ptr2 = buf[0..runtime_len :0];
test/behavior/slice_sentinel_comptime.zig+28
......@@ -3,6 +3,7 @@ test "comptime slice-sentinel in bounds (unterminated)" {
33 comptime {
44 var target = [_]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10;
55 const slice = target[0..3 :'d'];
6 _ = slice;
67 }
78
89 // ptr_array
......@@ -10,6 +11,7 @@ test "comptime slice-sentinel in bounds (unterminated)" {
1011 var buf = [_]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10;
1112 var target = &buf;
1213 const slice = target[0..3 :'d'];
14 _ = slice;
1315 }
1416
1517 // vector_ConstPtrSpecialBaseArray
......@@ -17,6 +19,7 @@ test "comptime slice-sentinel in bounds (unterminated)" {
1719 var buf = [_]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10;
1820 var target: [*]u8 = &buf;
1921 const slice = target[0..3 :'d'];
22 _ = slice;
2023 }
2124
2225 // vector_ConstPtrSpecialRef
......@@ -24,6 +27,7 @@ test "comptime slice-sentinel in bounds (unterminated)" {
2427 var buf = [_]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10;
2528 var target: [*]u8 = @ptrCast([*]u8, &buf);
2629 const slice = target[0..3 :'d'];
30 _ = slice;
2731 }
2832
2933 // cvector_ConstPtrSpecialBaseArray
......@@ -31,6 +35,7 @@ test "comptime slice-sentinel in bounds (unterminated)" {
3135 var buf = [_]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10;
3236 var target: [*c]u8 = &buf;
3337 const slice = target[0..3 :'d'];
38 _ = slice;
3439 }
3540
3641 // cvector_ConstPtrSpecialRef
......@@ -38,6 +43,7 @@ test "comptime slice-sentinel in bounds (unterminated)" {
3843 var buf = [_]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10;
3944 var target: [*c]u8 = @ptrCast([*c]u8, &buf);
4045 const slice = target[0..3 :'d'];
46 _ = slice;
4147 }
4248
4349 // slice
......@@ -45,6 +51,7 @@ test "comptime slice-sentinel in bounds (unterminated)" {
4551 var buf = [_]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10;
4652 var target: []u8 = &buf;
4753 const slice = target[0..3 :'d'];
54 _ = slice;
4855 }
4956}
5057
......@@ -53,6 +60,7 @@ test "comptime slice-sentinel in bounds (end,unterminated)" {
5360 comptime {
5461 var target = [_]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{0xff} ** 10;
5562 const slice = target[0..13 :0xff];
63 _ = slice;
5664 }
5765
5866 // ptr_array
......@@ -60,6 +68,7 @@ test "comptime slice-sentinel in bounds (end,unterminated)" {
6068 var buf = [_]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{0xff} ** 10;
6169 var target = &buf;
6270 const slice = target[0..13 :0xff];
71 _ = slice;
6372 }
6473
6574 // vector_ConstPtrSpecialBaseArray
......@@ -67,6 +76,7 @@ test "comptime slice-sentinel in bounds (end,unterminated)" {
6776 var buf = [_]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{0xff} ** 10;
6877 var target: [*]u8 = &buf;
6978 const slice = target[0..13 :0xff];
79 _ = slice;
7080 }
7181
7282 // vector_ConstPtrSpecialRef
......@@ -74,6 +84,7 @@ test "comptime slice-sentinel in bounds (end,unterminated)" {
7484 var buf = [_]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{0xff} ** 10;
7585 var target: [*]u8 = @ptrCast([*]u8, &buf);
7686 const slice = target[0..13 :0xff];
87 _ = slice;
7788 }
7889
7990 // cvector_ConstPtrSpecialBaseArray
......@@ -81,6 +92,7 @@ test "comptime slice-sentinel in bounds (end,unterminated)" {
8192 var buf = [_]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{0xff} ** 10;
8293 var target: [*c]u8 = &buf;
8394 const slice = target[0..13 :0xff];
95 _ = slice;
8496 }
8597
8698 // cvector_ConstPtrSpecialRef
......@@ -88,6 +100,7 @@ test "comptime slice-sentinel in bounds (end,unterminated)" {
88100 var buf = [_]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{0xff} ** 10;
89101 var target: [*c]u8 = @ptrCast([*c]u8, &buf);
90102 const slice = target[0..13 :0xff];
103 _ = slice;
91104 }
92105
93106 // slice
......@@ -95,6 +108,7 @@ test "comptime slice-sentinel in bounds (end,unterminated)" {
95108 var buf = [_]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{0xff} ** 10;
96109 var target: []u8 = &buf;
97110 const slice = target[0..13 :0xff];
111 _ = slice;
98112 }
99113}
100114
......@@ -103,6 +117,7 @@ test "comptime slice-sentinel in bounds (terminated)" {
103117 comptime {
104118 var target = [_:0]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10;
105119 const slice = target[0..3 :'d'];
120 _ = slice;
106121 }
107122
108123 // ptr_array
......@@ -110,6 +125,7 @@ test "comptime slice-sentinel in bounds (terminated)" {
110125 var buf = [_:0]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10;
111126 var target = &buf;
112127 const slice = target[0..3 :'d'];
128 _ = slice;
113129 }
114130
115131 // vector_ConstPtrSpecialBaseArray
......@@ -117,6 +133,7 @@ test "comptime slice-sentinel in bounds (terminated)" {
117133 var buf = [_:0]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10;
118134 var target: [*]u8 = &buf;
119135 const slice = target[0..3 :'d'];
136 _ = slice;
120137 }
121138
122139 // vector_ConstPtrSpecialRef
......@@ -124,6 +141,7 @@ test "comptime slice-sentinel in bounds (terminated)" {
124141 var buf = [_:0]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10;
125142 var target: [*]u8 = @ptrCast([*]u8, &buf);
126143 const slice = target[0..3 :'d'];
144 _ = slice;
127145 }
128146
129147 // cvector_ConstPtrSpecialBaseArray
......@@ -131,6 +149,7 @@ test "comptime slice-sentinel in bounds (terminated)" {
131149 var buf = [_:0]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10;
132150 var target: [*c]u8 = &buf;
133151 const slice = target[0..3 :'d'];
152 _ = slice;
134153 }
135154
136155 // cvector_ConstPtrSpecialRef
......@@ -138,6 +157,7 @@ test "comptime slice-sentinel in bounds (terminated)" {
138157 var buf = [_:0]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10;
139158 var target: [*c]u8 = @ptrCast([*c]u8, &buf);
140159 const slice = target[0..3 :'d'];
160 _ = slice;
141161 }
142162
143163 // slice
......@@ -145,6 +165,7 @@ test "comptime slice-sentinel in bounds (terminated)" {
145165 var buf = [_:0]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10;
146166 var target: []u8 = &buf;
147167 const slice = target[0..3 :'d'];
168 _ = slice;
148169 }
149170}
150171
......@@ -153,6 +174,7 @@ test "comptime slice-sentinel in bounds (on target sentinel)" {
153174 comptime {
154175 var target = [_:0]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10;
155176 const slice = target[0..14 :0];
177 _ = slice;
156178 }
157179
158180 // ptr_array
......@@ -160,6 +182,7 @@ test "comptime slice-sentinel in bounds (on target sentinel)" {
160182 var buf = [_:0]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10;
161183 var target = &buf;
162184 const slice = target[0..14 :0];
185 _ = slice;
163186 }
164187
165188 // vector_ConstPtrSpecialBaseArray
......@@ -167,6 +190,7 @@ test "comptime slice-sentinel in bounds (on target sentinel)" {
167190 var buf = [_:0]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10;
168191 var target: [*]u8 = &buf;
169192 const slice = target[0..14 :0];
193 _ = slice;
170194 }
171195
172196 // vector_ConstPtrSpecialRef
......@@ -174,6 +198,7 @@ test "comptime slice-sentinel in bounds (on target sentinel)" {
174198 var buf = [_:0]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10;
175199 var target: [*]u8 = @ptrCast([*]u8, &buf);
176200 const slice = target[0..14 :0];
201 _ = slice;
177202 }
178203
179204 // cvector_ConstPtrSpecialBaseArray
......@@ -181,6 +206,7 @@ test "comptime slice-sentinel in bounds (on target sentinel)" {
181206 var buf = [_:0]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10;
182207 var target: [*c]u8 = &buf;
183208 const slice = target[0..14 :0];
209 _ = slice;
184210 }
185211
186212 // cvector_ConstPtrSpecialRef
......@@ -188,6 +214,7 @@ test "comptime slice-sentinel in bounds (on target sentinel)" {
188214 var buf = [_:0]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10;
189215 var target: [*c]u8 = @ptrCast([*c]u8, &buf);
190216 const slice = target[0..14 :0];
217 _ = slice;
191218 }
192219
193220 // slice
......@@ -195,5 +222,6 @@ test "comptime slice-sentinel in bounds (on target sentinel)" {
195222 var buf = [_:0]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10;
196223 var target: []u8 = &buf;
197224 const slice = target[0..14 :0];
225 _ = slice;
198226 }
199227}
test/behavior/struct.zig+5-3
......@@ -584,13 +584,14 @@ test "default struct initialization fields" {
584584 const x = S{
585585 .b = 5,
586586 };
587 if (x.a + x.b != 1239) {
588 @compileError("it should be comptime known");
589 }
590587 var five: i32 = 5;
591588 const y = S{
592589 .b = five,
593590 };
591 if (x.a + x.b != 1239) {
592 @compileError("it should be comptime known");
593 }
594 try expectEqual(y, x);
594595 try expectEqual(1239, x.a + x.b);
595596}
596597
......@@ -654,6 +655,7 @@ test "zero-bit field in packed struct" {
654655 y: void,
655656 };
656657 var x: S = undefined;
658 _ = x;
657659}
658660
659661test "struct field init with catch" {
test/behavior/switch.zig+2
......@@ -103,6 +103,7 @@ fn switchProngWithVarFn(a: SwitchProngWithVarEnum) !void {
103103 },
104104 SwitchProngWithVarEnum.Meh => |x| {
105105 const v: void = x;
106 _ = v;
106107 },
107108 }
108109}
......@@ -454,6 +455,7 @@ test "switch variable for range and multiple prongs" {
454455 }
455456 }
456457 };
458 _ = S;
457459}
458460
459461var state: u32 = 0;
test/behavior/tuple.zig+1
......@@ -105,6 +105,7 @@ test "tuple initializer for var" {
105105 .id = @as(usize, 2),
106106 .name = Bytes{ .id = 20 },
107107 };
108 _ = tmp;
108109 }
109110 };
110111
test/behavior/type.zig+1
......@@ -436,6 +436,7 @@ test "Type.Fn" {
436436 }.func;
437437 const Foo = @Type(@typeInfo(@TypeOf(foo)));
438438 const foo_2: Foo = foo;
439 _ = foo_2;
439440}
440441
441442test "Type.BoundFn" {
test/behavior/type_info.zig+1
......@@ -329,6 +329,7 @@ test "typeInfo with comptime parameter in struct fn def" {
329329 pub fn func(comptime x: f32) void {}
330330 };
331331 comptime var info = @typeInfo(S);
332 _ = info;
332333}
333334
334335test "type info: vectors" {
test/behavior/union.zig+1
......@@ -781,6 +781,7 @@ test "@unionInit on union w/ tag but no fields" {
781781
782782 fn doTheTest() !void {
783783 var data: Data = .{ .no_op = .{} };
784 _ = data;
784785 var o = Data.decode(&[_]u8{});
785786 try expectEqual(Type.no_op, o);
786787 }
test/behavior/var_args.zig+2-2
......@@ -18,7 +18,7 @@ test "add arbitrary args" {
1818}
1919
2020fn readFirstVarArg(args: anytype) void {
21 const value = args[0];
21 _ = args[0];
2222}
2323
2424test "send void arg to var args" {
......@@ -79,5 +79,5 @@ test "pass zero length array to var args param" {
7979}
8080
8181fn doNothingWithFirstArg(args: anytype) void {
82 const a = args[0];
82 _ = args[0];
8383}
test/behavior/vector.zig+2
......@@ -113,6 +113,7 @@ test "array to vector" {
113113 var foo: f32 = 3.14;
114114 var arr = [4]f32{ foo, 1.5, 0.0, 0.0 };
115115 var vec: Vector(4, f32) = arr;
116 _ = vec;
116117}
117118
118119test "vector casts of sizes not divisable by 8" {
......@@ -264,6 +265,7 @@ test "initialize vector which is a struct field" {
264265 var foo = Vec4Obj{
265266 .data = [_]f32{ 1, 2, 3, 4 },
266267 };
268 _ = foo;
267269 }
268270 };
269271 try S.doTheTest();
test/behavior/void.zig+1-1
......@@ -36,5 +36,5 @@ test "void optional" {
3636
3737test "void array as a local variable initializer" {
3838 var x = [_]void{{}} ** 1004;
39 var y = x[0];
39 _ = x[0];
4040}
test/stage2/test.zig+1
......@@ -899,6 +899,7 @@ pub fn addCases(ctx: *TestContext) !void {
899899 \\ try expect(false);
900900 \\ }
901901 \\ };
902 \\ _ = S;
902903 \\}
903904 ,
904905 &.{":4:13: error: invalid 'try' outside function scope"},
test/tests.zig-1
......@@ -525,7 +525,6 @@ pub fn addPkgTests(
525525 if (skip_single_threaded and test_target.single_threaded)
526526 continue;
527527
528 const ArchTag = std.meta.Tag(std.Target.Cpu.Arch);
529528 if (test_target.disable_native and
530529 test_target.target.getOsTag() == std.Target.current.os.tag and
531530 test_target.target.getCpuArch() == std.Target.current.cpu.arch)