From aeaef8c0ffadab4145fd002f2edd87a6db66ebd1 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Sat, 18 Feb 2023 09:02:57 -0700 Subject: update std lib and compiler sources to new for loop syntax --- lib/std/atomic/Atomic.zig | 12 ++++++------ lib/std/atomic/queue.zig | 4 ++-- lib/std/atomic/stack.zig | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) (limited to 'lib/std/atomic') diff --git a/lib/std/atomic/Atomic.zig b/lib/std/atomic/Atomic.zig index 850075d4cb..51e61ca628 100644 --- a/lib/std/atomic/Atomic.zig +++ b/lib/std/atomic/Atomic.zig @@ -548,7 +548,7 @@ test "Atomic.bitSet" { var x = Atomic(Int).init(0); const bit_array = @as([@bitSizeOf(Int)]void, undefined); - for (bit_array) |_, bit_index| { + for (bit_array, 0..) |_, bit_index| { const bit = @intCast(std.math.Log2Int(Int), bit_index); const mask = @as(Int, 1) << bit; @@ -562,7 +562,7 @@ test "Atomic.bitSet" { try testing.expect(x.load(.SeqCst) & mask != 0); // all the previous bits should have not changed (still be set) - for (bit_array[0..bit_index]) |_, prev_bit_index| { + for (bit_array[0..bit_index], 0..) |_, prev_bit_index| { const prev_bit = @intCast(std.math.Log2Int(Int), prev_bit_index); const prev_mask = @as(Int, 1) << prev_bit; try testing.expect(x.load(.SeqCst) & prev_mask != 0); @@ -578,7 +578,7 @@ test "Atomic.bitReset" { var x = Atomic(Int).init(0); const bit_array = @as([@bitSizeOf(Int)]void, undefined); - for (bit_array) |_, bit_index| { + for (bit_array, 0..) |_, bit_index| { const bit = @intCast(std.math.Log2Int(Int), bit_index); const mask = @as(Int, 1) << bit; x.storeUnchecked(x.loadUnchecked() | mask); @@ -593,7 +593,7 @@ test "Atomic.bitReset" { try testing.expect(x.load(.SeqCst) & mask == 0); // all the previous bits should have not changed (still be reset) - for (bit_array[0..bit_index]) |_, prev_bit_index| { + for (bit_array[0..bit_index], 0..) |_, prev_bit_index| { const prev_bit = @intCast(std.math.Log2Int(Int), prev_bit_index); const prev_mask = @as(Int, 1) << prev_bit; try testing.expect(x.load(.SeqCst) & prev_mask == 0); @@ -609,7 +609,7 @@ test "Atomic.bitToggle" { var x = Atomic(Int).init(0); const bit_array = @as([@bitSizeOf(Int)]void, undefined); - for (bit_array) |_, bit_index| { + for (bit_array, 0..) |_, bit_index| { const bit = @intCast(std.math.Log2Int(Int), bit_index); const mask = @as(Int, 1) << bit; @@ -623,7 +623,7 @@ test "Atomic.bitToggle" { try testing.expect(x.load(.SeqCst) & mask == 0); // all the previous bits should have not changed (still be toggled back) - for (bit_array[0..bit_index]) |_, prev_bit_index| { + for (bit_array[0..bit_index], 0..) |_, prev_bit_index| { const prev_bit = @intCast(std.math.Log2Int(Int), prev_bit_index); const prev_mask = @as(Int, 1) << prev_bit; try testing.expect(x.load(.SeqCst) & prev_mask == 0); diff --git a/lib/std/atomic/queue.zig b/lib/std/atomic/queue.zig index 8100a9e26a..7c9ffa2684 100644 --- a/lib/std/atomic/queue.zig +++ b/lib/std/atomic/queue.zig @@ -212,11 +212,11 @@ test "std.atomic.Queue" { try expect(context.queue.isEmpty()); var putters: [put_thread_count]std.Thread = undefined; - for (putters) |*t| { + for (&putters) |*t| { t.* = try std.Thread.spawn(.{}, startPuts, .{&context}); } var getters: [put_thread_count]std.Thread = undefined; - for (getters) |*t| { + for (&getters) |*t| { t.* = try std.Thread.spawn(.{}, startGets, .{&context}); } diff --git a/lib/std/atomic/stack.zig b/lib/std/atomic/stack.zig index a6396bb22b..9ad7c76d81 100644 --- a/lib/std/atomic/stack.zig +++ b/lib/std/atomic/stack.zig @@ -117,11 +117,11 @@ test "std.atomic.stack" { } } else { var putters: [put_thread_count]std.Thread = undefined; - for (putters) |*t| { + for (&putters) |*t| { t.* = try std.Thread.spawn(.{}, startPuts, .{&context}); } var getters: [put_thread_count]std.Thread = undefined; - for (getters) |*t| { + for (&getters) |*t| { t.* = try std.Thread.spawn(.{}, startGets, .{&context}); } -- cgit v1.2.3