authorgravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2026-02-23 13:24:54+00:00
committergravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2026-03-10 10:26:13+00:00
log82be338964ed5bbc596a48075e52724fdf92cde4
tree9536f08d24c56911d5a304b2d8e89930c841d659
parent2651b5ccdf2485172e9ba0345b9529733ee39273
signaturelock-open Commit is signed but in an unrecognized format.

aro: stop depending on ArrayList default field values


3 files changed, 19 insertions(+), 13 deletions(-)

lib/compiler/aro/aro/InitList.zig+13-7
......@@ -22,9 +22,15 @@ const Item = struct {
2222
2323const InitList = @This();
2424
25list: std.ArrayList(Item) = .empty,
26node: Node.OptIndex = .null,
27tok: TokenIndex = 0,
25list: std.ArrayList(Item),
26node: Node.OptIndex,
27tok: TokenIndex,
28
29pub const empty: InitList = .{
30 .list = .empty,
31 .node = .null,
32 .tok = 0,
33};
2834
2935/// Deinitialize freeing all memory.
3036pub fn deinit(il: *InitList, gpa: Allocator) void {
......@@ -43,7 +49,7 @@ pub fn find(il: *InitList, gpa: Allocator, index: u64) !*InitList {
4349 if (il.list.items.len == 0) {
4450 const item = try il.list.addOne(gpa);
4551 item.* = .{
46 .list = .{},
52 .list = .empty,
4753 .index = index,
4854 };
4955 return &item.list;
......@@ -51,7 +57,7 @@ pub fn find(il: *InitList, gpa: Allocator, index: u64) !*InitList {
5157 // Append a new value to the end of the list.
5258 const new = try il.list.addOne(gpa);
5359 new.* = .{
54 .list = .{},
60 .list = .empty,
5561 .index = index,
5662 };
5763 return &new.list;
......@@ -70,7 +76,7 @@ pub fn find(il: *InitList, gpa: Allocator, index: u64) !*InitList {
7076
7177 // Insert a new value into a sorted position.
7278 try il.list.insert(gpa, left, .{
73 .list = .{},
79 .list = .empty,
7480 .index = index,
7581 });
7682 return &il.list.items[left].list;
......@@ -78,7 +84,7 @@ pub fn find(il: *InitList, gpa: Allocator, index: u64) !*InitList {
7884
7985test "basic usage" {
8086 const gpa = testing.allocator;
81 var il: InitList = .{};
87 var il: InitList = .empty;
8288 defer il.deinit(gpa);
8389
8490 {
lib/compiler/aro/aro/Parser.zig+3-3
......@@ -3977,7 +3977,7 @@ fn initializer(p: *Parser, init_qt: QualType) Error!Result {
39773977 final_init_qt = .invalid;
39783978 }
39793979
3980 var il: InitList = .{};
3980 var il: InitList = .empty;
39813981 defer il.deinit(p.comp.gpa);
39823982
39833983 try p.initializerItem(&il, final_init_qt, l_brace);
......@@ -4028,12 +4028,12 @@ fn initializerItem(p: *Parser, il: *InitList, init_qt: QualType, l_brace: TokenI
40284028 try p.err(first_tok, .initializer_overrides, .{});
40294029 try p.err(item.il.tok, .previous_initializer, .{});
40304030 item.il.deinit(gpa);
4031 item.il.* = .{};
4031 item.il.* = .empty;
40324032 }
40334033 try p.initializerItem(item.il, item.qt, inner_l_brace);
40344034 } else {
40354035 // discard further values
4036 var tmp_il: InitList = .{};
4036 var tmp_il: InitList = .empty;
40374037 defer tmp_il.deinit(gpa);
40384038 try p.initializerItem(&tmp_il, .invalid, inner_l_brace);
40394039 if (!warned_excess) try p.err(first_tok, switch (init_qt.base(p.comp).type) {
lib/compiler/aro/aro/Toolchain.zig+3-3
......@@ -43,13 +43,13 @@ const Toolchain = @This();
4343driver: *Driver,
4444
4545/// The list of toolchain specific path prefixes to search for libraries.
46library_paths: PathList = .{},
46library_paths: PathList = .empty,
4747
4848/// The list of toolchain specific path prefixes to search for files.
49file_paths: PathList = .{},
49file_paths: PathList = .empty,
5050
5151/// The list of toolchain specific path prefixes to search for programs.
52program_paths: PathList = .{},
52program_paths: PathList = .empty,
5353
5454selected_multilib: Multilib = .{},
5555