diff --git a/ci/azure/linux_script b/ci/azure/linux_script index cf46b2c222..56823755ac 100755 --- a/ci/azure/linux_script +++ b/ci/azure/linux_script @@ -59,6 +59,9 @@ unset CXX make $JOBS install +# look for formatting errors +release/bin/zig fmt --check .. || (echo "Please run 'zig fmt' to fix the non-conforming files listed above." && false) + # Here we rebuild zig but this time using the Zig binary we just now produced to # build zig1.o rather than relying on the one built with stage0. See # https://github.com/ziglang/zig/issues/6830 for more details. diff --git a/lib/std/Thread/Futex.zig b/lib/std/Thread/Futex.zig index 01353e9fb8..356a4e2046 100644 --- a/lib/std/Thread/Futex.zig +++ b/lib/std/Thread/Futex.zig @@ -84,7 +84,7 @@ else const WindowsFutex = struct { const windows = std.os.windows; - + fn wait(ptr: *const Atomic(u32), expect: u32, timeout: ?u64) error{TimedOut}!void { var timeout_value: windows.LARGE_INTEGER = undefined; var timeout_ptr: ?*const windows.LARGE_INTEGER = null; @@ -299,7 +299,7 @@ const PosixFutex = struct { state: State = .empty, cond: std.c.pthread_cond_t = .{}, mutex: std.c.pthread_mutex_t = .{}, - + const Self = @This(); const State = enum { empty, @@ -381,7 +381,7 @@ test "Futex - wait/wake" { const wait_noop_result = Futex.wait(&value, 0, 0); try testing.expectError(error.TimedOut, wait_noop_result); - + const wait_longer_result = Futex.wait(&value, 0, std.time.ns_per_ms); try testing.expectError(error.TimedOut, wait_longer_result); @@ -416,7 +416,7 @@ test "Futex - Signal" { const Thread = struct { tx: *Self, rx: *Self, - + const start_value = 1; fn run(self: Thread) void { @@ -472,7 +472,7 @@ test "Futex - Broadcast" { self.broadcast.store(BROADCAST_RECEIVED, .Release); Futex.wake(&self.broadcast, 1); } - } + } fn run() !void { var self = Self{}; @@ -542,7 +542,7 @@ test "Futex - Chain" { if (chain.index + 1 < chain.self.threads.len) { next_signal = &chain.self.threads[chain.index + 1].signal; } - + this_signal.wait(); next_signal.notify(); } @@ -554,7 +554,7 @@ test "Futex - Chain" { for (self.threads) |*entry, index| { entry.signal = .{}; entry.thread = try std.Thread.spawn(Chain.run, .{ - .self = &self, + .self = &self, .index = index, }); } @@ -567,4 +567,4 @@ test "Futex - Chain" { } } }).run(); -} \ No newline at end of file +} diff --git a/lib/std/c/darwin.zig b/lib/std/c/darwin.zig index b8a554721f..ca18b5130a 100644 --- a/lib/std/c/darwin.zig +++ b/lib/std/c/darwin.zig @@ -246,7 +246,7 @@ pub const ULF_WAIT_ADAPTIVE_SPIN = 0x40000; pub extern "c" fn __ulock_wait2(op: u32, addr: ?*const c_void, val: u64, timeout_us: u32, val2: u64) c_int; pub extern "c" fn __ulock_wait(op: u32, addr: ?*const c_void, val: u64, timeout_us: u32) c_int; -pub extern "c" fn __ulock_wake(op: u32, addr: ?*const c_void, val: u64) c_int; +pub extern "c" fn __ulock_wake(op: u32, addr: ?*const c_void, val: u64) c_int; pub const OS_UNFAIR_LOCK_INIT = os_unfair_lock{}; pub const os_unfair_lock_t = *os_unfair_lock; @@ -258,4 +258,4 @@ pub extern "c" fn os_unfair_lock_lock(o: os_unfair_lock_t) void; pub extern "c" fn os_unfair_lock_unlock(o: os_unfair_lock_t) void; pub extern "c" fn os_unfair_lock_trylock(o: os_unfair_lock_t) bool; pub extern "c" fn os_unfair_lock_assert_owner(o: os_unfair_lock_t) void; -pub extern "c" fn os_unfair_lock_assert_not_owner(o: os_unfair_lock_t) void; \ No newline at end of file +pub extern "c" fn os_unfair_lock_assert_not_owner(o: os_unfair_lock_t) void; diff --git a/lib/std/zig/parse.zig b/lib/std/zig/parse.zig index 4d5cadb37b..cc323382cd 100644 --- a/lib/std/zig/parse.zig +++ b/lib/std/zig/parse.zig @@ -2005,9 +2005,12 @@ const Parser = struct { if (field_init != 0) { try p.scratch.append(p.gpa, field_init); while (true) { - switch (p.token_tags[p.tok_i]) { + switch (p.token_tags[p.tok_i]) { .comma => p.tok_i += 1, - .r_brace => { p.tok_i += 1; break; }, + .r_brace => { + p.tok_i += 1; + break; + }, .colon, .r_paren, .r_bracket => return p.failExpected(.r_brace), // Likely just a missing comma; give error but continue parsing. else => try p.warnExpected(.comma), @@ -2045,7 +2048,10 @@ const Parser = struct { try p.scratch.append(p.gpa, elem_init); switch (p.token_tags[p.tok_i]) { .comma => p.tok_i += 1, - .r_brace => { p.tok_i += 1; break; }, + .r_brace => { + p.tok_i += 1; + break; + }, .colon, .r_paren, .r_bracket => return p.failExpected(.r_brace), // Likely just a missing comma; give error but continue parsing. else => try p.warnExpected(.comma), @@ -2121,7 +2127,10 @@ const Parser = struct { try p.scratch.append(p.gpa, param); switch (p.token_tags[p.tok_i]) { .comma => p.tok_i += 1, - .r_paren => { p.tok_i += 1; break; }, + .r_paren => { + p.tok_i += 1; + break; + }, .colon, .r_brace, .r_bracket => return p.failExpected(.r_paren), // Likely just a missing comma; give error but continue parsing. else => try p.warnExpected(.comma), @@ -2129,7 +2138,7 @@ const Parser = struct { } const comma = (p.token_tags[p.tok_i - 2] == .comma); const params = p.scratch.items[scratch_top..]; - switch(params.len) { + switch (params.len) { 0 => return p.addNode(.{ .tag = if (comma) .async_call_one_comma else .async_call_one, .main_token = lparen, @@ -2174,7 +2183,10 @@ const Parser = struct { try p.scratch.append(p.gpa, param); switch (p.token_tags[p.tok_i]) { .comma => p.tok_i += 1, - .r_paren => { p.tok_i += 1; break; }, + .r_paren => { + p.tok_i += 1; + break; + }, .colon, .r_brace, .r_bracket => return p.failExpected(.r_paren), // Likely just a missing comma; give error but continue parsing. else => try p.warnExpected(.comma), @@ -2182,7 +2194,7 @@ const Parser = struct { } const comma = (p.token_tags[p.tok_i - 2] == .comma); const params = p.scratch.items[scratch_top..]; - res = switch(params.len) { + res = switch (params.len) { 0 => try p.addNode(.{ .tag = if (comma) .call_one_comma else .call_one, .main_token = lparen, @@ -2448,7 +2460,10 @@ const Parser = struct { while (true) { switch (p.token_tags[p.tok_i]) { .comma => p.tok_i += 1, - .r_brace => { p.tok_i += 1; break; }, + .r_brace => { + p.tok_i += 1; + break; + }, .colon, .r_paren, .r_bracket => return p.failExpected(.r_brace), // Likely just a missing comma; give error but continue parsing. else => try p.warnExpected(.comma), @@ -2497,7 +2512,10 @@ const Parser = struct { try p.scratch.append(p.gpa, elem_init); switch (p.token_tags[p.tok_i]) { .comma => p.tok_i += 1, - .r_brace => { p.tok_i += 1; break; }, + .r_brace => { + p.tok_i += 1; + break; + }, .colon, .r_paren, .r_bracket => return p.failExpected(.r_brace), // Likely just a missing comma; give error but continue parsing. else => try p.warnExpected(.comma), @@ -2555,7 +2573,10 @@ const Parser = struct { const identifier = try p.expectToken(.identifier); switch (p.token_tags[p.tok_i]) { .comma => p.tok_i += 1, - .r_brace => { p.tok_i += 1; break; }, + .r_brace => { + p.tok_i += 1; + break; + }, .colon, .r_paren, .r_bracket => return p.failExpected(.r_brace), // Likely just a missing comma; give error but continue parsing. else => try p.warnExpected(.comma), @@ -2992,14 +3013,14 @@ const Parser = struct { _ = try p.parsePtrPayload(); const items = p.scratch.items[scratch_top..]; - switch(items.len) { + switch (items.len) { 0 => return p.addNode(.{ .tag = .switch_case_one, .main_token = arrow_token, .data = .{ .lhs = 0, .rhs = try p.expectAssignExpr(), - } + }, }), 1 => return p.addNode(.{ .tag = .switch_case_one, @@ -3007,7 +3028,7 @@ const Parser = struct { .data = .{ .lhs = items[0], .rhs = try p.expectAssignExpr(), - } + }, }), else => return p.addNode(.{ .tag = .switch_case, @@ -3375,7 +3396,10 @@ const Parser = struct { } switch (p.token_tags[p.tok_i]) { .comma => p.tok_i += 1, - .r_paren => { p.tok_i += 1; break; }, + .r_paren => { + p.tok_i += 1; + break; + }, .colon, .r_brace, .r_bracket => return p.failExpected(.r_paren), // Likely just a missing comma; give error but continue parsing. else => try p.warnExpected(.comma), @@ -3444,7 +3468,10 @@ const Parser = struct { try p.scratch.append(p.gpa, param); switch (p.token_tags[p.tok_i]) { .comma => p.tok_i += 1, - .r_paren => { p.tok_i += 1; break; }, + .r_paren => { + p.tok_i += 1; + break; + }, // Likely just a missing comma; give error but continue parsing. else => try p.warnExpected(.comma), } diff --git a/test/tests.zig b/test/tests.zig index 1b944634a5..26f38d4e28 100644 --- a/test/tests.zig +++ b/test/tests.zig @@ -107,7 +107,6 @@ const test_targets = blk: { .link_libc = true, }, - TestTarget{ .target = .{ .cpu_arch = .aarch64, @@ -228,7 +227,6 @@ const test_targets = blk: { .link_libc = true, }, - TestTarget{ .target = .{ .cpu_arch = .riscv64, @@ -656,7 +654,7 @@ pub const StackTracesContext = struct { const b = self.b; const src_basename = "source.zig"; const write_src = b.addWriteFile(src_basename, source); - const exe = b.addExecutableSource("test", write_src.getFileSource(src_basename).?); + const exe = b.addExecutableSource("test", write_src.getFileSource(src_basename).?); exe.setBuildMode(mode); const run_and_compare = RunAndCompareStep.create( @@ -670,7 +668,6 @@ pub const StackTracesContext = struct { self.step.dependOn(&run_and_compare.step); } - const RunAndCompareStep = struct { pub const base_id = .custom; @@ -1376,4 +1373,4 @@ fn printInvocation(args: []const []const u8) void { warn("{s} ", .{arg}); } warn("\n", .{}); -} \ No newline at end of file +}