From d944296ab95571b02aea5a9c8c0818cbf5c0417b Mon Sep 17 00:00:00 2001 From: Robert Burnett Date: Wed, 28 May 2025 18:52:31 -0500 Subject: [PATCH 1/7] remove std.BoundedArray.constSlice() --- lib/std/bounded_array.zig | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/lib/std/bounded_array.zig b/lib/std/bounded_array.zig index 1a4407e6876f..1d5a9c254625 100644 --- a/lib/std/bounded_array.zig +++ b/lib/std/bounded_array.zig @@ -30,7 +30,7 @@ pub fn BoundedArray(comptime T: type, comptime buffer_capacity: usize) type { // var a = try BoundedArrayAligned(u8, 16, 2).init(0); // try a.append(255); // try a.append(255); -// const b = @ptrCast(*const [1]u16, a.constSlice().ptr); +// const b = @ptrCast(*const [1]u16, a.slice().ptr); // try testing.expectEqual(@as(u16, 65535), b[0]); /// ``` pub fn BoundedArrayAligned( @@ -59,11 +59,6 @@ pub fn BoundedArrayAligned( return self.buffer[0..self.len]; } - /// View the internal array as a constant slice whose size was previously set. - pub fn constSlice(self: *const Self) []align(alignment.toByteUnits()) const T { - return self.slice(); - } - /// Adjust the slice's length to `len`. /// Does not initialize added items if any. pub fn resize(self: *Self, len: usize) error{Overflow}!void { @@ -85,7 +80,7 @@ pub fn BoundedArrayAligned( /// Return the element at index `i` of the slice. pub fn get(self: Self, i: usize) T { - return self.constSlice()[i]; + return self.slice()[i]; } /// Set the value of the element at index `i` of the slice. @@ -172,7 +167,7 @@ pub fn BoundedArrayAligned( pub fn insertSlice(self: *Self, i: usize, items: []const T) error{Overflow}!void { try self.ensureUnusedCapacity(items.len); self.len += items.len; - mem.copyBackwards(T, self.slice()[i + items.len .. self.len], self.constSlice()[i .. self.len - items.len]); + mem.copyBackwards(T, self.slice()[i + items.len .. self.len], self.slice()[i .. self.len - items.len]); @memcpy(self.slice()[i..][0..items.len], items); } @@ -198,7 +193,7 @@ pub fn BoundedArrayAligned( } else { @memcpy(range[0..new_items.len], new_items); const after_subrange = start + new_items.len; - for (self.constSlice()[after_range..], 0..) |item, i| { + for (self.slice()[after_range..], 0..) |item, i| { self.slice()[after_subrange..][i] = item; } self.len -= len - new_items.len; @@ -298,17 +293,17 @@ test BoundedArray { try testing.expectEqual(a.capacity(), 64); try testing.expectEqual(a.slice().len, 32); - try testing.expectEqual(a.constSlice().len, 32); + try testing.expectEqual(a.slice().len, 32); try a.resize(48); try testing.expectEqual(a.len, 48); const x = [_]u8{1} ** 10; a = try BoundedArray(u8, 64).fromSlice(&x); - try testing.expectEqualSlices(u8, &x, a.constSlice()); + try testing.expectEqualSlices(u8, &x, a.slice()); var a2 = a; - try testing.expectEqualSlices(u8, a.constSlice(), a2.constSlice()); + try testing.expectEqualSlices(u8, a.slice(), a2.slice()); a2.set(0, 0); try testing.expect(a.get(0) != a2.get(0)); @@ -396,7 +391,7 @@ test BoundedArray { const w = a.writer(); const s = "hello, this is a test string"; try w.writeAll(s); - try testing.expectEqualStrings(s, a.constSlice()); + try testing.expectEqualStrings(s, a.slice()); } test "BoundedArrayAligned" { @@ -406,7 +401,7 @@ test "BoundedArrayAligned" { try a.append(255); try a.append(255); - const b = @as(*const [2]u16, @ptrCast(a.constSlice().ptr)); + const b = @as(*const [2]u16, @ptrCast(a.slice().ptr)); try testing.expectEqual(@as(u16, 0), b[0]); try testing.expectEqual(@as(u16, 65535), b[1]); } From 03c0b024567adde735ed4391669be91721828ef2 Mon Sep 17 00:00:00 2001 From: Robert Burnett Date: Wed, 28 May 2025 19:10:56 -0500 Subject: [PATCH 2/7] remove other uses of constSlice --- lib/compiler/aro/aro/Driver/Multilib.zig | 8 ++++---- lib/compiler/aro/aro/Toolchain.zig | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/compiler/aro/aro/Driver/Multilib.zig b/lib/compiler/aro/aro/Driver/Multilib.zig index 1486cf47bbbb..e242d1e0aba1 100644 --- a/lib/compiler/aro/aro/Driver/Multilib.zig +++ b/lib/compiler/aro/aro/Driver/Multilib.zig @@ -15,7 +15,7 @@ pub const Detected = struct { pub fn filter(self: *Detected, multilib_filter: Filter, fs: Filesystem) void { var found_count: usize = 0; - for (self.multilibs.constSlice()) |multilib| { + for (self.multilibs.slice()) |multilib| { if (multilib_filter.exists(multilib, fs)) { self.multilibs.set(found_count, multilib); found_count += 1; @@ -26,9 +26,9 @@ pub const Detected = struct { pub fn select(self: *Detected, flags: Flags) !bool { var filtered: MultilibArray = .{}; - for (self.multilibs.constSlice()) |multilib| { - for (multilib.flags.constSlice()) |multilib_flag| { - const matched = for (flags.constSlice()) |arg_flag| { + for (self.multilibs.slice()) |multilib| { + for (multilib.flags.slice()) |multilib_flag| { + const matched = for (flags.slice()) |arg_flag| { if (std.mem.eql(u8, arg_flag[1..], multilib_flag[1..])) break arg_flag; } else multilib_flag; if (matched[0] != multilib_flag[0]) break; diff --git a/lib/compiler/aro/aro/Toolchain.zig b/lib/compiler/aro/aro/Toolchain.zig index bbd540b1b6d3..8c2a0c5c9942 100644 --- a/lib/compiler/aro/aro/Toolchain.zig +++ b/lib/compiler/aro/aro/Toolchain.zig @@ -225,7 +225,7 @@ fn getProgramPath(tc: *const Toolchain, name: []const u8, buf: []u8) []const u8 var tool_specific_buf: [64]u8 = undefined; const possible_names = possibleProgramNames(tc.driver.raw_target_triple, name, &tool_specific_buf); - for (possible_names.constSlice()) |tool_name| { + for (possible_names.slice()) |tool_name| { for (tc.program_paths.items) |program_path| { defer fib.reset(); From 64c84142b6ee6547ef592b1a28d32a82517ef439 Mon Sep 17 00:00:00 2001 From: Robert Burnett Date: Wed, 28 May 2025 22:00:10 -0500 Subject: [PATCH 3/7] rename .slice() to .items() --- lib/compiler/aro/aro/Driver/Multilib.zig | 8 +-- lib/compiler/aro/aro/Toolchain.zig | 2 +- lib/std/base64.zig | 4 +- lib/std/bounded_array.zig | 66 ++++++++++++------------ lib/std/io/Reader/test.zig | 4 +- src/Zcu.zig | 2 +- src/Zcu/PerThread.zig | 2 +- 7 files changed, 44 insertions(+), 44 deletions(-) diff --git a/lib/compiler/aro/aro/Driver/Multilib.zig b/lib/compiler/aro/aro/Driver/Multilib.zig index e242d1e0aba1..4788ca464248 100644 --- a/lib/compiler/aro/aro/Driver/Multilib.zig +++ b/lib/compiler/aro/aro/Driver/Multilib.zig @@ -15,7 +15,7 @@ pub const Detected = struct { pub fn filter(self: *Detected, multilib_filter: Filter, fs: Filesystem) void { var found_count: usize = 0; - for (self.multilibs.slice()) |multilib| { + for (self.multilibs.items()) |multilib| { if (multilib_filter.exists(multilib, fs)) { self.multilibs.set(found_count, multilib); found_count += 1; @@ -26,9 +26,9 @@ pub const Detected = struct { pub fn select(self: *Detected, flags: Flags) !bool { var filtered: MultilibArray = .{}; - for (self.multilibs.slice()) |multilib| { - for (multilib.flags.slice()) |multilib_flag| { - const matched = for (flags.slice()) |arg_flag| { + for (self.multilibs.items()) |multilib| { + for (multilib.flags.items()) |multilib_flag| { + const matched = for (flags.items()) |arg_flag| { if (std.mem.eql(u8, arg_flag[1..], multilib_flag[1..])) break arg_flag; } else multilib_flag; if (matched[0] != multilib_flag[0]) break; diff --git a/lib/compiler/aro/aro/Toolchain.zig b/lib/compiler/aro/aro/Toolchain.zig index 8c2a0c5c9942..c6df679fd6e3 100644 --- a/lib/compiler/aro/aro/Toolchain.zig +++ b/lib/compiler/aro/aro/Toolchain.zig @@ -225,7 +225,7 @@ fn getProgramPath(tc: *const Toolchain, name: []const u8, buf: []u8) []const u8 var tool_specific_buf: [64]u8 = undefined; const possible_names = possibleProgramNames(tc.driver.raw_target_triple, name, &tool_specific_buf); - for (possible_names.slice()) |tool_name| { + for (possible_names.items()) |tool_name| { for (tc.program_paths.items) |program_path| { defer fib.reset(); diff --git a/lib/std/base64.zig b/lib/std/base64.zig index e88b72343984..001c89b86848 100644 --- a/lib/std/base64.zig +++ b/lib/std/base64.zig @@ -521,13 +521,13 @@ fn testAllApis(codecs: Codecs, expected_decoded: []const u8, expected_encoded: [ // stream encode var list = try std.BoundedArray(u8, 0x100).init(0); try codecs.Encoder.encodeWriter(list.writer(), expected_decoded); - try testing.expectEqualSlices(u8, expected_encoded, list.slice()); + try testing.expectEqualSlices(u8, expected_encoded, list.items()); // reader to writer encode var stream = std.io.fixedBufferStream(expected_decoded); list = try std.BoundedArray(u8, 0x100).init(0); try codecs.Encoder.encodeFromReaderToWriter(list.writer(), stream.reader()); - try testing.expectEqualSlices(u8, expected_encoded, list.slice()); + try testing.expectEqualSlices(u8, expected_encoded, list.items()); } // Base64Decoder diff --git a/lib/std/bounded_array.zig b/lib/std/bounded_array.zig index 1d5a9c254625..bf37fcfc64a2 100644 --- a/lib/std/bounded_array.zig +++ b/lib/std/bounded_array.zig @@ -13,7 +13,7 @@ const Alignment = std.mem.Alignment; /// ```zig /// var actual_size = 32; /// var a = try BoundedArray(u8, 64).init(actual_size); -/// var slice = a.slice(); // a slice of the 64-byte array +/// var slice = a.items(); // a slice of the 64-byte array /// var a_clone = a; // creates a copy - the structure doesn't use any internal pointers /// ``` pub fn BoundedArray(comptime T: type, comptime buffer_capacity: usize) type { @@ -30,7 +30,7 @@ pub fn BoundedArray(comptime T: type, comptime buffer_capacity: usize) type { // var a = try BoundedArrayAligned(u8, 16, 2).init(0); // try a.append(255); // try a.append(255); -// const b = @ptrCast(*const [1]u16, a.slice().ptr); +// const b = @ptrCast(*const [1]u16, a.items().ptr); // try testing.expectEqual(@as(u16, 65535), b[0]); /// ``` pub fn BoundedArrayAligned( @@ -51,7 +51,7 @@ pub fn BoundedArrayAligned( } /// View the internal array as a slice whose size was previously set. - pub fn slice(self: anytype) switch (@TypeOf(&self.buffer)) { + pub fn items(self: anytype) switch (@TypeOf(&self.buffer)) { *align(alignment.toByteUnits()) [buffer_capacity]T => []align(alignment.toByteUnits()) T, *align(alignment.toByteUnits()) const [buffer_capacity]T => []align(alignment.toByteUnits()) const T, else => unreachable, @@ -74,18 +74,18 @@ pub fn BoundedArrayAligned( /// Copy the content of an existing slice. pub fn fromSlice(m: []const T) error{Overflow}!Self { var list = try init(m.len); - @memcpy(list.slice(), m); + @memcpy(list.items(), m); return list; } /// Return the element at index `i` of the slice. pub fn get(self: Self, i: usize) T { - return self.slice()[i]; + return self.items()[i]; } /// Set the value of the element at index `i` of the slice. pub fn set(self: *Self, i: usize, item: T) void { - self.slice()[i] = item; + self.items()[i] = item; } /// Return the maximum length of a slice. @@ -111,7 +111,7 @@ pub fn BoundedArrayAligned( pub fn addOneAssumeCapacity(self: *Self) *T { assert(self.len < buffer_capacity); self.len += 1; - return &self.slice()[self.len - 1]; + return &self.items()[self.len - 1]; } /// Resize the slice, adding `n` new elements, which have `undefined` values. @@ -119,7 +119,7 @@ pub fn BoundedArrayAligned( pub fn addManyAsArray(self: *Self, comptime n: usize) error{Overflow}!*align(alignment.toByteUnits()) [n]T { const prev_len = self.len; try self.resize(self.len + n); - return self.slice()[prev_len..][0..n]; + return self.items()[prev_len..][0..n]; } /// Resize the slice, adding `n` new elements, which have `undefined` values. @@ -127,7 +127,7 @@ pub fn BoundedArrayAligned( pub fn addManyAsSlice(self: *Self, n: usize) error{Overflow}![]align(alignment.toByteUnits()) T { const prev_len = self.len; try self.resize(self.len + n); - return self.slice()[prev_len..][0..n]; + return self.items()[prev_len..][0..n]; } /// Remove and return the last element from the slice, or return `null` if the slice is empty. @@ -157,18 +157,18 @@ pub fn BoundedArrayAligned( return error.Overflow; } _ = try self.addOne(); - var s = self.slice(); + var s = self.items(); mem.copyBackwards(T, s[i + 1 .. s.len], s[i .. s.len - 1]); self.buffer[i] = item; } /// Insert slice `items` at index `i` by moving `slice[i .. slice.len]` to make room. /// This operation is O(N). - pub fn insertSlice(self: *Self, i: usize, items: []const T) error{Overflow}!void { - try self.ensureUnusedCapacity(items.len); - self.len += items.len; - mem.copyBackwards(T, self.slice()[i + items.len .. self.len], self.slice()[i .. self.len - items.len]); - @memcpy(self.slice()[i..][0..items.len], items); + pub fn insertSlice(self: *Self, i: usize, new_items: []const T) error{Overflow}!void { + try self.ensureUnusedCapacity(new_items.len); + self.len += new_items.len; + mem.copyBackwards(T, self.items()[i + new_items.len .. self.len], self.items()[i .. self.len - new_items.len]); + @memcpy(self.items()[i..][0..new_items.len], new_items); } /// Replace range of elements `slice[start..][0..len]` with `new_items`. @@ -181,7 +181,7 @@ pub fn BoundedArrayAligned( new_items: []const T, ) error{Overflow}!void { const after_range = start + len; - var range = self.slice()[start..after_range]; + var range = self.items()[start..after_range]; if (range.len == new_items.len) { @memcpy(range[0..new_items.len], new_items); @@ -193,8 +193,8 @@ pub fn BoundedArrayAligned( } else { @memcpy(range[0..new_items.len], new_items); const after_subrange = start + new_items.len; - for (self.slice()[after_range..], 0..) |item, i| { - self.slice()[after_subrange..][i] = item; + for (self.items()[after_range..], 0..) |item, i| { + self.items()[after_subrange..][i] = item; } self.len -= len - new_items.len; } @@ -221,7 +221,7 @@ pub fn BoundedArrayAligned( const newlen = self.len - 1; if (newlen == i) return self.pop().?; const old_item = self.get(i); - for (self.slice()[i..newlen], 0..) |*b, j| b.* = self.get(i + 1 + j); + for (self.items()[i..newlen], 0..) |*b, j| b.* = self.get(i + 1 + j); self.set(newlen, undefined); self.len = newlen; return old_item; @@ -238,17 +238,17 @@ pub fn BoundedArrayAligned( } /// Append the slice of items to the slice. - pub fn appendSlice(self: *Self, items: []const T) error{Overflow}!void { - try self.ensureUnusedCapacity(items.len); - self.appendSliceAssumeCapacity(items); + pub fn appendSlice(self: *Self, new_items: []const T) error{Overflow}!void { + try self.ensureUnusedCapacity(new_items.len); + self.appendSliceAssumeCapacity(new_items); } /// Append the slice of items to the slice, asserting the capacity is already /// enough to store the new items. - pub fn appendSliceAssumeCapacity(self: *Self, items: []const T) void { + pub fn appendSliceAssumeCapacity(self: *Self, new_items: []const T) void { const old_len = self.len; - self.len += items.len; - @memcpy(self.slice()[old_len..][0..items.len], items); + self.len += new_items.len; + @memcpy(self.items()[old_len..][0..new_items.len], new_items); } /// Append a value to the slice `n` times. @@ -256,7 +256,7 @@ pub fn BoundedArrayAligned( pub fn appendNTimes(self: *Self, value: T, n: usize) error{Overflow}!void { const old_len = self.len; try self.resize(old_len + n); - @memset(self.slice()[old_len..self.len], value); + @memset(self.items()[old_len..self.len], value); } /// Append a value to the slice `n` times. @@ -265,7 +265,7 @@ pub fn BoundedArrayAligned( const old_len = self.len; self.len += n; assert(self.len <= buffer_capacity); - @memset(self.slice()[old_len..self.len], value); + @memset(self.items()[old_len..self.len], value); } pub const Writer = if (T != u8) @@ -292,18 +292,18 @@ test BoundedArray { var a = try BoundedArray(u8, 64).init(32); try testing.expectEqual(a.capacity(), 64); - try testing.expectEqual(a.slice().len, 32); - try testing.expectEqual(a.slice().len, 32); + try testing.expectEqual(a.items().len, 32); + try testing.expectEqual(a.items().len, 32); try a.resize(48); try testing.expectEqual(a.len, 48); const x = [_]u8{1} ** 10; a = try BoundedArray(u8, 64).fromSlice(&x); - try testing.expectEqualSlices(u8, &x, a.slice()); + try testing.expectEqualSlices(u8, &x, a.items()); var a2 = a; - try testing.expectEqualSlices(u8, a.slice(), a2.slice()); + try testing.expectEqualSlices(u8, a.items(), a2.items()); a2.set(0, 0); try testing.expect(a.get(0) != a2.get(0)); @@ -391,7 +391,7 @@ test BoundedArray { const w = a.writer(); const s = "hello, this is a test string"; try w.writeAll(s); - try testing.expectEqualStrings(s, a.slice()); + try testing.expectEqualStrings(s, a.items()); } test "BoundedArrayAligned" { @@ -401,7 +401,7 @@ test "BoundedArrayAligned" { try a.append(255); try a.append(255); - const b = @as(*const [2]u16, @ptrCast(a.slice().ptr)); + const b = @as(*const [2]u16, @ptrCast(a.items().ptr)); try testing.expectEqual(@as(u16, 0), b[0]); try testing.expectEqual(@as(u16, 65535), b[1]); } diff --git a/lib/std/io/Reader/test.zig b/lib/std/io/Reader/test.zig index 30f0e1269c32..b63100aeb39a 100644 --- a/lib/std/io/Reader/test.zig +++ b/lib/std/io/Reader/test.zig @@ -356,7 +356,7 @@ test "readBoundedBytes correctly reads into a new bounded array" { const reader = fis.reader(); var array = try reader.readBoundedBytes(10000); - try testing.expectEqualStrings(array.slice(), test_string); + try testing.expectEqualStrings(array.items(), test_string); } test "readIntoBoundedBytes correctly reads into a provided bounded array" { @@ -368,5 +368,5 @@ test "readIntoBoundedBytes correctly reads into a provided bounded array" { // compile time error if the size is not the same at the provided `bounded.capacity()` try reader.readIntoBoundedBytes(10000, &bounded_array); - try testing.expectEqualStrings(bounded_array.slice(), test_string); + try testing.expectEqualStrings(bounded_array.items(), test_string); } diff --git a/src/Zcu.zig b/src/Zcu.zig index 7617085f8ef2..7c99927a949b 100644 --- a/src/Zcu.zig +++ b/src/Zcu.zig @@ -4072,7 +4072,7 @@ fn resolveReferencesInner(zcu: *Zcu) !std.AutoHashMapUnmanaged(AnalUnit, ?Resolv try result.ensureTotalCapacity(gpa, @intCast(zcu.reference_table.count())); try type_queue.ensureTotalCapacity(gpa, zcu.analysis_roots.len); - for (zcu.analysis_roots.slice()) |mod| { + for (zcu.analysis_roots.items()) |mod| { const file = zcu.module_roots.get(mod).?.unwrap() orelse continue; const root_ty = zcu.fileRootType(file); if (root_ty == .none) continue; diff --git a/src/Zcu/PerThread.zig b/src/Zcu/PerThread.zig index 65ccfbb19089..2b14865618dc 100644 --- a/src/Zcu/PerThread.zig +++ b/src/Zcu/PerThread.zig @@ -2177,7 +2177,7 @@ pub fn computeAliveFiles(pt: Zcu.PerThread) Allocator.Error!bool { // The roots of our file liveness analysis will be the analysis roots. try zcu.alive_files.ensureTotalCapacity(gpa, zcu.analysis_roots.len); - for (zcu.analysis_roots.slice()) |mod| { + for (zcu.analysis_roots.items()) |mod| { const file_index = zcu.module_roots.get(mod).?.unwrap() orelse continue; const file = zcu.fileByIndex(file_index); From 867bfc919d3e5850ac101320401955348aa48639 Mon Sep 17 00:00:00 2001 From: Robert Burnett Date: Wed, 28 May 2025 22:07:59 -0500 Subject: [PATCH 4/7] fix compile error --- src/Compilation.zig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Compilation.zig b/src/Compilation.zig index 8f986a5cdf03..525d6d4223e5 100644 --- a/src/Compilation.zig +++ b/src/Compilation.zig @@ -4439,7 +4439,7 @@ fn performAllTheWorkInner( try zcu.flushRetryableFailures(); // It's analysis time! Queue up our initial analysis. - for (zcu.analysis_roots.slice()) |mod| { + for (zcu.analysis_roots.items()) |mod| { try comp.queueJob(.{ .analyze_mod = mod }); } From ddf83ebe1b5efc754e53c5e46553ceea6b74989c Mon Sep 17 00:00:00 2001 From: Robert Burnett Date: Thu, 29 May 2025 06:36:24 -0500 Subject: [PATCH 5/7] fix compile errors in Parser.zig --- lib/docs/wasm/markdown/Parser.zig | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/docs/wasm/markdown/Parser.zig b/lib/docs/wasm/markdown/Parser.zig index ce8db08d96e8..6b560403ff50 100644 --- a/lib/docs/wasm/markdown/Parser.zig +++ b/lib/docs/wasm/markdown/Parser.zig @@ -480,8 +480,8 @@ fn appendBlockStart(p: *Parser, block_start: BlockStart) !void { // available in the BlockStart. We can immediately parse and append // these children now. const containing_table = p.pending_blocks.items[p.pending_blocks.items.len - 2]; - const column_alignments = containing_table.data.table.column_alignments.slice(); - for (block_start.data.table_row.cells.slice(), 0..) |cell_content, i| { + const column_alignments = containing_table.data.table.column_alignments.items(); + for (block_start.data.table_row.cells.items(), 0..) |cell_content, i| { const cell_children = try p.parseInlines(cell_content); const alignment = if (i < column_alignments.len) column_alignments[i] else .unset; const cell = try p.addNode(.{ @@ -650,7 +650,7 @@ fn parseTableHeaderDelimiter( row_cells: std.BoundedArray([]const u8, max_table_columns), ) ?std.BoundedArray(Node.TableCellAlignment, max_table_columns) { var alignments: std.BoundedArray(Node.TableCellAlignment, max_table_columns) = .{}; - for (row_cells.slice()) |content| { + for (row_cells.items()) |content| { const alignment = parseTableHeaderDelimiterCell(content) orelse return null; alignments.appendAssumeCapacity(alignment); } From 6f21cc633fbe53e68243eae262e9bf28011189a9 Mon Sep 17 00:00:00 2001 From: Robert Burnett Date: Sat, 31 May 2025 14:30:07 -0500 Subject: [PATCH 6/7] make change suggested by @Fri3dNstuff --- lib/std/bounded_array.zig | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/std/bounded_array.zig b/lib/std/bounded_array.zig index bf37fcfc64a2..07587340e39e 100644 --- a/lib/std/bounded_array.zig +++ b/lib/std/bounded_array.zig @@ -51,10 +51,10 @@ pub fn BoundedArrayAligned( } /// View the internal array as a slice whose size was previously set. - pub fn items(self: anytype) switch (@TypeOf(&self.buffer)) { - *align(alignment.toByteUnits()) [buffer_capacity]T => []align(alignment.toByteUnits()) T, - *align(alignment.toByteUnits()) const [buffer_capacity]T => []align(alignment.toByteUnits()) const T, - else => unreachable, + pub fn items(self: anytype) switch (@TypeOf(self)) { + *Self => []align(alignment.toByteUnits()) T, + *const Self => []align(alignment.toByteUnits()) const T, + else => @compileError("Bad type"), } { return self.buffer[0..self.len]; } From 4a0a9d9591d2b72d8b44fc3409afb48e6c9a991c Mon Sep 17 00:00:00 2001 From: Robert Burnett Date: Wed, 11 Jun 2025 13:59:03 -0500 Subject: [PATCH 7/7] add deprecated warnings for old interfaces --- lib/std/bounded_array.zig | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/std/bounded_array.zig b/lib/std/bounded_array.zig index 07587340e39e..5ab817ead8cd 100644 --- a/lib/std/bounded_array.zig +++ b/lib/std/bounded_array.zig @@ -59,6 +59,16 @@ pub fn BoundedArrayAligned( return self.buffer[0..self.len]; } + pub fn constSlice(self: *const Self) void { + _ = self; + @compileError("This function has been deprecated, use .items() instead"); + } + + pub fn slice(self: *const Self) void { + _ = self; + @compileError("This function has been deprecated, use .items() instead"); + } + /// Adjust the slice's length to `len`. /// Does not initialize added items if any. pub fn resize(self: *Self, len: usize) error{Overflow}!void {