mirror of
https://github.com/ziglang/zig.git
synced 2025-12-06 14:23:09 +00:00
stage2 tests: remove unused vars
This commit is contained in:
parent
f8b8f50b63
commit
18c1007a34
@ -896,7 +896,6 @@ fn printLineFromFileAnyOs(out_stream: anytype, line_info: LineInfo) !void {
|
|||||||
var buf: [mem.page_size]u8 = undefined;
|
var buf: [mem.page_size]u8 = undefined;
|
||||||
var line: usize = 1;
|
var line: usize = 1;
|
||||||
var column: usize = 1;
|
var column: usize = 1;
|
||||||
var abs_index: usize = 0;
|
|
||||||
while (true) {
|
while (true) {
|
||||||
const amt_read = try f.read(buf[0..]);
|
const amt_read = try f.read(buf[0..]);
|
||||||
const slice = buf[0..amt_read];
|
const slice = buf[0..amt_read];
|
||||||
|
|||||||
@ -590,7 +590,8 @@ pub const Pdb = struct {
|
|||||||
|
|
||||||
var sect_cont_offset: usize = 0;
|
var sect_cont_offset: usize = 0;
|
||||||
if (section_contrib_size != 0) {
|
if (section_contrib_size != 0) {
|
||||||
const version = reader.readEnum(SectionContrSubstreamVersion, .Little) catch |err| switch (err) {
|
// the version
|
||||||
|
_ = reader.readEnum(SectionContrSubstreamVersion, .Little) catch |err| switch (err) {
|
||||||
error.InvalidValue => return error.InvalidDebugInfo,
|
error.InvalidValue => return error.InvalidDebugInfo,
|
||||||
else => |e| return e,
|
else => |e| return e,
|
||||||
};
|
};
|
||||||
@ -616,7 +617,8 @@ pub const Pdb = struct {
|
|||||||
|
|
||||||
// Parse the InfoStreamHeader.
|
// Parse the InfoStreamHeader.
|
||||||
const version = try reader.readIntLittle(u32);
|
const version = try reader.readIntLittle(u32);
|
||||||
const signature = try reader.readIntLittle(u32);
|
// The signature
|
||||||
|
_ = try reader.readIntLittle(u32);
|
||||||
const age = try reader.readIntLittle(u32);
|
const age = try reader.readIntLittle(u32);
|
||||||
const guid = try reader.readBytesNoEof(16);
|
const guid = try reader.readBytesNoEof(16);
|
||||||
|
|
||||||
|
|||||||
@ -1005,7 +1005,7 @@ const Parser = struct {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
const else_payload = try p.parsePayload();
|
_ = try p.parsePayload();
|
||||||
const else_expr = try p.expectStatement();
|
const else_expr = try p.expectStatement();
|
||||||
return p.addNode(.{
|
return p.addNode(.{
|
||||||
.tag = .@"if",
|
.tag = .@"if",
|
||||||
@ -1189,7 +1189,7 @@ const Parser = struct {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
const else_payload = try p.parsePayload();
|
_ = try p.parsePayload();
|
||||||
const else_expr = try p.expectStatement();
|
const else_expr = try p.expectStatement();
|
||||||
return p.addNode(.{
|
return p.addNode(.{
|
||||||
.tag = .@"while",
|
.tag = .@"while",
|
||||||
|
|||||||
@ -93,16 +93,16 @@ pub fn addCases(ctx: *TestContext) !void {
|
|||||||
, "");
|
, "");
|
||||||
case.addError(
|
case.addError(
|
||||||
\\pub export fn main() c_int {
|
\\pub export fn main() c_int {
|
||||||
\\ const c = @intToError(0);
|
\\ _ = @intToError(0);
|
||||||
\\ return 0;
|
\\ return 0;
|
||||||
\\}
|
\\}
|
||||||
, &.{":2:27: error: integer value 0 represents no error"});
|
, &.{":2:21: error: integer value 0 represents no error"});
|
||||||
case.addError(
|
case.addError(
|
||||||
\\pub export fn main() c_int {
|
\\pub export fn main() c_int {
|
||||||
\\ const c = @intToError(3);
|
\\ _ = @intToError(3);
|
||||||
\\ return 0;
|
\\ return 0;
|
||||||
\\}
|
\\}
|
||||||
, &.{":2:27: error: integer value 3 represents no error"});
|
, &.{":2:21: error: integer value 3 represents no error"});
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
@ -383,6 +383,7 @@ pub fn addCases(ctx: *TestContext) !void {
|
|||||||
\\ true => 2,
|
\\ true => 2,
|
||||||
\\ false => 3,
|
\\ false => 3,
|
||||||
\\ };
|
\\ };
|
||||||
|
\\ _ = b;
|
||||||
\\}
|
\\}
|
||||||
, &.{
|
, &.{
|
||||||
":6:9: error: duplicate switch value",
|
":6:9: error: duplicate switch value",
|
||||||
@ -398,6 +399,7 @@ pub fn addCases(ctx: *TestContext) !void {
|
|||||||
\\ f64, i32 => 3,
|
\\ f64, i32 => 3,
|
||||||
\\ else => 4,
|
\\ else => 4,
|
||||||
\\ };
|
\\ };
|
||||||
|
\\ _ = b;
|
||||||
\\}
|
\\}
|
||||||
, &.{
|
, &.{
|
||||||
":6:14: error: duplicate switch value",
|
":6:14: error: duplicate switch value",
|
||||||
@ -414,6 +416,7 @@ pub fn addCases(ctx: *TestContext) !void {
|
|||||||
\\ f16...f64 => 3,
|
\\ f16...f64 => 3,
|
||||||
\\ else => 4,
|
\\ else => 4,
|
||||||
\\ };
|
\\ };
|
||||||
|
\\ _ = b;
|
||||||
\\}
|
\\}
|
||||||
, &.{
|
, &.{
|
||||||
":3:30: error: ranges not allowed when switching on type 'type'",
|
":3:30: error: ranges not allowed when switching on type 'type'",
|
||||||
@ -431,6 +434,7 @@ pub fn addCases(ctx: *TestContext) !void {
|
|||||||
\\ 3 => 40,
|
\\ 3 => 40,
|
||||||
\\ else => 50,
|
\\ else => 50,
|
||||||
\\ };
|
\\ };
|
||||||
|
\\ _ = b;
|
||||||
\\}
|
\\}
|
||||||
, &.{
|
, &.{
|
||||||
":8:14: error: unreachable else prong; all cases already handled",
|
":8:14: error: unreachable else prong; all cases already handled",
|
||||||
@ -556,10 +560,10 @@ pub fn addCases(ctx: *TestContext) !void {
|
|||||||
\\const E1 = packed enum { a, b, c };
|
\\const E1 = packed enum { a, b, c };
|
||||||
\\const E2 = extern enum { a, b, c };
|
\\const E2 = extern enum { a, b, c };
|
||||||
\\export fn foo() void {
|
\\export fn foo() void {
|
||||||
\\ const x = E1.a;
|
\\ _ = E1.a;
|
||||||
\\}
|
\\}
|
||||||
\\export fn bar() void {
|
\\export fn bar() void {
|
||||||
\\ const x = E2.a;
|
\\ _ = E2.a;
|
||||||
\\}
|
\\}
|
||||||
, &.{
|
, &.{
|
||||||
":1:12: error: enums do not support 'packed' or 'extern'; instead provide an explicit integer tag type",
|
":1:12: error: enums do not support 'packed' or 'extern'; instead provide an explicit integer tag type",
|
||||||
@ -579,10 +583,10 @@ pub fn addCases(ctx: *TestContext) !void {
|
|||||||
\\ c,
|
\\ c,
|
||||||
\\};
|
\\};
|
||||||
\\export fn foo() void {
|
\\export fn foo() void {
|
||||||
\\ const x = E1.a;
|
\\ _ = E1.a;
|
||||||
\\}
|
\\}
|
||||||
\\export fn bar() void {
|
\\export fn bar() void {
|
||||||
\\ const x = E2.a;
|
\\ _ = E2.a;
|
||||||
\\}
|
\\}
|
||||||
, &.{
|
, &.{
|
||||||
":3:5: error: enum fields cannot be marked comptime",
|
":3:5: error: enum fields cannot be marked comptime",
|
||||||
@ -621,7 +625,7 @@ pub fn addCases(ctx: *TestContext) !void {
|
|||||||
\\ c,
|
\\ c,
|
||||||
\\};
|
\\};
|
||||||
\\export fn foo() void {
|
\\export fn foo() void {
|
||||||
\\ const x = E1.a;
|
\\ _ = E1.a;
|
||||||
\\}
|
\\}
|
||||||
, &.{
|
, &.{
|
||||||
":3:7: error: expected ',', found 'align'",
|
":3:7: error: expected ',', found 'align'",
|
||||||
@ -638,7 +642,7 @@ pub fn addCases(ctx: *TestContext) !void {
|
|||||||
\\ _,
|
\\ _,
|
||||||
\\};
|
\\};
|
||||||
\\export fn foo() void {
|
\\export fn foo() void {
|
||||||
\\ const x = E1.a;
|
\\ _ = E1.a;
|
||||||
\\}
|
\\}
|
||||||
, &.{
|
, &.{
|
||||||
":6:5: error: redundant non-exhaustive enum mark",
|
":6:5: error: redundant non-exhaustive enum mark",
|
||||||
@ -653,7 +657,7 @@ pub fn addCases(ctx: *TestContext) !void {
|
|||||||
\\ _ = 10,
|
\\ _ = 10,
|
||||||
\\};
|
\\};
|
||||||
\\export fn foo() void {
|
\\export fn foo() void {
|
||||||
\\ const x = E1.a;
|
\\ _ = E1.a;
|
||||||
\\}
|
\\}
|
||||||
, &.{
|
, &.{
|
||||||
":5:9: error: '_' is used to mark an enum as non-exhaustive and cannot be assigned a value",
|
":5:9: error: '_' is used to mark an enum as non-exhaustive and cannot be assigned a value",
|
||||||
@ -662,7 +666,7 @@ pub fn addCases(ctx: *TestContext) !void {
|
|||||||
case.addError(
|
case.addError(
|
||||||
\\const E1 = enum {};
|
\\const E1 = enum {};
|
||||||
\\export fn foo() void {
|
\\export fn foo() void {
|
||||||
\\ const x = E1.a;
|
\\ _ = E1.a;
|
||||||
\\}
|
\\}
|
||||||
, &.{
|
, &.{
|
||||||
":1:12: error: enum declarations must have at least one tag",
|
":1:12: error: enum declarations must have at least one tag",
|
||||||
@ -671,7 +675,7 @@ pub fn addCases(ctx: *TestContext) !void {
|
|||||||
case.addError(
|
case.addError(
|
||||||
\\const E1 = enum { a, b, _ };
|
\\const E1 = enum { a, b, _ };
|
||||||
\\export fn foo() void {
|
\\export fn foo() void {
|
||||||
\\ const x = E1.a;
|
\\ _ = E1.a;
|
||||||
\\}
|
\\}
|
||||||
, &.{
|
, &.{
|
||||||
":1:12: error: non-exhaustive enum missing integer tag type",
|
":1:12: error: non-exhaustive enum missing integer tag type",
|
||||||
@ -681,7 +685,7 @@ pub fn addCases(ctx: *TestContext) !void {
|
|||||||
case.addError(
|
case.addError(
|
||||||
\\const E1 = enum { a, b, c, b, d };
|
\\const E1 = enum { a, b, c, b, d };
|
||||||
\\pub export fn main() c_int {
|
\\pub export fn main() c_int {
|
||||||
\\ const x = E1.a;
|
\\ _ = E1.a;
|
||||||
\\}
|
\\}
|
||||||
, &.{
|
, &.{
|
||||||
":1:28: error: duplicate enum tag",
|
":1:28: error: duplicate enum tag",
|
||||||
@ -691,28 +695,28 @@ pub fn addCases(ctx: *TestContext) !void {
|
|||||||
case.addError(
|
case.addError(
|
||||||
\\pub export fn main() c_int {
|
\\pub export fn main() c_int {
|
||||||
\\ const a = true;
|
\\ const a = true;
|
||||||
\\ const b = @enumToInt(a);
|
\\ _ = @enumToInt(a);
|
||||||
\\}
|
\\}
|
||||||
, &.{
|
, &.{
|
||||||
":3:26: error: expected enum or tagged union, found bool",
|
":3:20: error: expected enum or tagged union, found bool",
|
||||||
});
|
});
|
||||||
|
|
||||||
case.addError(
|
case.addError(
|
||||||
\\pub export fn main() c_int {
|
\\pub export fn main() c_int {
|
||||||
\\ const a = 1;
|
\\ const a = 1;
|
||||||
\\ const b = @intToEnum(bool, a);
|
\\ _ = @intToEnum(bool, a);
|
||||||
\\}
|
\\}
|
||||||
, &.{
|
, &.{
|
||||||
":3:26: error: expected enum, found bool",
|
":3:20: error: expected enum, found bool",
|
||||||
});
|
});
|
||||||
|
|
||||||
case.addError(
|
case.addError(
|
||||||
\\const E = enum { a, b, c };
|
\\const E = enum { a, b, c };
|
||||||
\\pub export fn main() c_int {
|
\\pub export fn main() c_int {
|
||||||
\\ const b = @intToEnum(E, 3);
|
\\ _ = @intToEnum(E, 3);
|
||||||
\\}
|
\\}
|
||||||
, &.{
|
, &.{
|
||||||
":3:15: error: enum 'test_case.E' has no tag with value 3",
|
":3:9: error: enum 'test_case.E' has no tag with value 3",
|
||||||
":1:11: note: enum declared here",
|
":1:11: note: enum declared here",
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -780,10 +784,10 @@ pub fn addCases(ctx: *TestContext) !void {
|
|||||||
case.addError(
|
case.addError(
|
||||||
\\const E = enum { a, b, c };
|
\\const E = enum { a, b, c };
|
||||||
\\pub export fn main() c_int {
|
\\pub export fn main() c_int {
|
||||||
\\ var x = E.d;
|
\\ _ = E.d;
|
||||||
\\}
|
\\}
|
||||||
, &.{
|
, &.{
|
||||||
":3:14: error: enum 'test_case.E' has no member named 'd'",
|
":3:10: error: enum 'test_case.E' has no member named 'd'",
|
||||||
":1:11: note: enum declared here",
|
":1:11: note: enum declared here",
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -791,6 +795,7 @@ pub fn addCases(ctx: *TestContext) !void {
|
|||||||
\\const E = enum { a, b, c };
|
\\const E = enum { a, b, c };
|
||||||
\\pub export fn main() c_int {
|
\\pub export fn main() c_int {
|
||||||
\\ var x: E = .d;
|
\\ var x: E = .d;
|
||||||
|
\\ _ = x;
|
||||||
\\}
|
\\}
|
||||||
, &.{
|
, &.{
|
||||||
":3:17: error: enum 'test_case.E' has no field named 'd'",
|
":3:17: error: enum 'test_case.E' has no field named 'd'",
|
||||||
|
|||||||
@ -259,6 +259,7 @@ pub fn addCases(ctx: *TestContext) !void {
|
|||||||
case.addCompareOutput(
|
case.addCompareOutput(
|
||||||
\\pub fn main() void {
|
\\pub fn main() void {
|
||||||
\\ var x: usize = 0;
|
\\ var x: usize = 0;
|
||||||
|
\\ _ = x;
|
||||||
\\ const z = @TypeOf(x, @as(u128, 5));
|
\\ const z = @TypeOf(x, @as(u128, 5));
|
||||||
\\ assert(z == u128);
|
\\ assert(z == u128);
|
||||||
\\}
|
\\}
|
||||||
@ -283,9 +284,9 @@ pub fn addCases(ctx: *TestContext) !void {
|
|||||||
);
|
);
|
||||||
case.addError(
|
case.addError(
|
||||||
\\pub fn main() void {
|
\\pub fn main() void {
|
||||||
\\ const z = @TypeOf(true, 1);
|
\\ _ = @TypeOf(true, 1);
|
||||||
\\}
|
\\}
|
||||||
, &[_][]const u8{":2:15: error: incompatible types: 'bool' and 'comptime_int'"});
|
, &[_][]const u8{":2:9: error: incompatible types: 'bool' and 'comptime_int'"});
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
@ -746,6 +747,7 @@ pub fn addCases(ctx: *TestContext) !void {
|
|||||||
\\ \\ cool thx
|
\\ \\ cool thx
|
||||||
\\ \\
|
\\ \\
|
||||||
\\ ;
|
\\ ;
|
||||||
|
\\ _ = ignore;
|
||||||
\\ add('ぁ', '\x03');
|
\\ add('ぁ', '\x03');
|
||||||
\\}
|
\\}
|
||||||
\\
|
\\
|
||||||
@ -987,6 +989,7 @@ pub fn addCases(ctx: *TestContext) !void {
|
|||||||
\\ return bar;
|
\\ return bar;
|
||||||
\\ }
|
\\ }
|
||||||
\\ };
|
\\ };
|
||||||
|
\\ _ = S;
|
||||||
\\}
|
\\}
|
||||||
, &.{
|
, &.{
|
||||||
":5:20: error: 'bar' not accessible from inner function",
|
":5:20: error: 'bar' not accessible from inner function",
|
||||||
@ -1072,6 +1075,7 @@ pub fn addCases(ctx: *TestContext) !void {
|
|||||||
\\ @compileLog(b, 20, f, x);
|
\\ @compileLog(b, 20, f, x);
|
||||||
\\ @compileLog(1000);
|
\\ @compileLog(1000);
|
||||||
\\ var bruh: usize = true;
|
\\ var bruh: usize = true;
|
||||||
|
\\ _ = bruh;
|
||||||
\\ unreachable;
|
\\ unreachable;
|
||||||
\\}
|
\\}
|
||||||
\\export fn other() void {
|
\\export fn other() void {
|
||||||
@ -1217,6 +1221,7 @@ pub fn addCases(ctx: *TestContext) !void {
|
|||||||
case.addError(
|
case.addError(
|
||||||
\\pub fn main() void {
|
\\pub fn main() void {
|
||||||
\\ var x = null;
|
\\ var x = null;
|
||||||
|
\\ _ = x;
|
||||||
\\}
|
\\}
|
||||||
, &[_][]const u8{
|
, &[_][]const u8{
|
||||||
":2:9: error: variable of type '@Type(.Null)' must be const or comptime",
|
":2:9: error: variable of type '@Type(.Null)' must be const or comptime",
|
||||||
@ -1456,14 +1461,14 @@ pub fn addCases(ctx: *TestContext) !void {
|
|||||||
case.addCompareOutput(
|
case.addCompareOutput(
|
||||||
\\pub fn main() void {
|
\\pub fn main() void {
|
||||||
\\ const E = error{ A, B, D } || error { A, B, C };
|
\\ const E = error{ A, B, D } || error { A, B, C };
|
||||||
\\ const a = E.A;
|
\\ E.A catch {};
|
||||||
\\ const b = E.B;
|
\\ E.B catch {};
|
||||||
\\ const c = E.C;
|
\\ E.C catch {};
|
||||||
\\ const d = E.D;
|
\\ E.D catch {};
|
||||||
\\ const E2 = error { X, Y } || @TypeOf(error.Z);
|
\\ const E2 = error { X, Y } || @TypeOf(error.Z);
|
||||||
\\ const x = E2.X;
|
\\ E2.X catch {};
|
||||||
\\ const y = E2.Y;
|
\\ E2.Y catch {};
|
||||||
\\ const z = E2.Z;
|
\\ E2.Z catch {};
|
||||||
\\ assert(anyerror || error { Z } == anyerror);
|
\\ assert(anyerror || error { Z } == anyerror);
|
||||||
\\}
|
\\}
|
||||||
\\fn assert(b: bool) void {
|
\\fn assert(b: bool) void {
|
||||||
@ -1485,6 +1490,7 @@ pub fn addCases(ctx: *TestContext) !void {
|
|||||||
\\ [arg1] "{rdi}" (code)
|
\\ [arg1] "{rdi}" (code)
|
||||||
\\ : "rcx", "r11", "memory"
|
\\ : "rcx", "r11", "memory"
|
||||||
\\ );
|
\\ );
|
||||||
|
\\ _ = x;
|
||||||
\\}
|
\\}
|
||||||
, &[_][]const u8{":4:27: error: expected type, found comptime_int"});
|
, &[_][]const u8{":4:27: error: expected type, found comptime_int"});
|
||||||
}
|
}
|
||||||
|
|||||||
@ -76,6 +76,10 @@ pub fn addCases(ctx: *TestContext) !void {
|
|||||||
\\ var i: u32 = 5;
|
\\ var i: u32 = 5;
|
||||||
\\ var y: f32 = 42.0;
|
\\ var y: f32 = 42.0;
|
||||||
\\ var x: u32 = 10;
|
\\ var x: u32 = 10;
|
||||||
|
\\ if (false) {
|
||||||
|
\\ y;
|
||||||
|
\\ x;
|
||||||
|
\\ }
|
||||||
\\ return i;
|
\\ return i;
|
||||||
\\}
|
\\}
|
||||||
, "5\n");
|
, "5\n");
|
||||||
@ -84,6 +88,7 @@ pub fn addCases(ctx: *TestContext) !void {
|
|||||||
\\pub export fn _start() u32 {
|
\\pub export fn _start() u32 {
|
||||||
\\ var i: u32 = 5;
|
\\ var i: u32 = 5;
|
||||||
\\ var y: f32 = 42.0;
|
\\ var y: f32 = 42.0;
|
||||||
|
\\ _ = y;
|
||||||
\\ var x: u32 = 10;
|
\\ var x: u32 = 10;
|
||||||
\\ foo(i, x);
|
\\ foo(i, x);
|
||||||
\\ i = x;
|
\\ i = x;
|
||||||
@ -388,6 +393,10 @@ pub fn addCases(ctx: *TestContext) !void {
|
|||||||
\\pub export fn _start() i32 {
|
\\pub export fn _start() i32 {
|
||||||
\\ var number1 = Number.One;
|
\\ var number1 = Number.One;
|
||||||
\\ var number2: Number = .Two;
|
\\ var number2: Number = .Two;
|
||||||
|
\\ if (false) {
|
||||||
|
\\ number1;
|
||||||
|
\\ number2;
|
||||||
|
\\ }
|
||||||
\\ const number3 = @intToEnum(Number, 2);
|
\\ const number3 = @intToEnum(Number, 2);
|
||||||
\\
|
\\
|
||||||
\\ return @enumToInt(number3);
|
\\ return @enumToInt(number3);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user