From 8eefe86939e917e4e85049325bff8c5a43f50f95 Mon Sep 17 00:00:00 2001 From: Matthew Lugg Date: Thu, 29 Jan 2026 18:11:19 +0000 Subject: [PATCH] std: remove default values from ArrayList These were deprecated in the 0.14.0 release cycle almost a year ago, so they can definitely be deleted now. --- lib/std/Build/Fuzz.zig | 4 ++-- lib/std/Build/Module.zig | 14 +++++++------- lib/std/Build/Step.zig | 2 +- lib/std/Build/Step/Run.zig | 8 ++++---- lib/std/Build/Step/UpdateSourceFiles.zig | 2 +- lib/std/Build/Step/WriteFile.zig | 4 ++-- lib/std/Io/Dir.zig | 2 +- lib/std/array_list.zig | 4 ++-- lib/std/compress/lzma.zig | 2 +- lib/std/compress/lzma2.zig | 2 +- lib/std/debug/Coverage.zig | 6 +++--- lib/std/zig/Ast.zig | 8 ++++---- lib/std/zig/AstGen.zig | 2 +- lib/std/zig/ErrorBundle.zig | 12 ++++++------ src/Package/Manifest.zig | 6 +++--- 15 files changed, 39 insertions(+), 39 deletions(-) diff --git a/lib/std/Build/Fuzz.zig b/lib/std/Build/Fuzz.zig index b2477f50884b34100e772960ca4a2c387ddd0008..e4104661add503c549ef09fbb3b16244683a9ce4 100644 --- a/lib/std/Build/Fuzz.zig +++ b/lib/std/Build/Fuzz.zig @@ -390,7 +390,7 @@ fn prepareTables(fuzz: *Fuzz, run_step: *Step.Run, coverage_id: u64) error{ OutO .coverage = std.debug.Coverage.init, .mapped_memory = undefined, // populated below .source_locations = undefined, // populated below - .entry_points = .{}, + .entry_points = .empty, .start_timestamp = ws.now(), .start_n_runs = undefined, // populated below }; @@ -450,7 +450,7 @@ fn prepareTables(fuzz: *Fuzz, run_step: *Step.Run, coverage_id: u64) error{ OutO // Unfortunately the PCs array that LLVM gives us from the 8-bit PC // counters feature is not sorted. - var sorted_pcs: std.MultiArrayList(struct { pc: u64, index: u32, sl: Coverage.SourceLocation }) = .{}; + var sorted_pcs: std.MultiArrayList(struct { pc: u64, index: u32, sl: Coverage.SourceLocation }) = .empty; defer sorted_pcs.deinit(gpa); try sorted_pcs.resize(gpa, pcs.len); @memcpy(sorted_pcs.items(.pc), pcs); diff --git a/lib/std/Build/Module.zig b/lib/std/Build/Module.zig index 657f8bb74eed1773400caa86c66e0b36211fbe1c..959e110c4ad47a5ddd95a508f91a3b49c66636ea 100644 --- a/lib/std/Build/Module.zig +++ b/lib/std/Build/Module.zig @@ -275,18 +275,18 @@ pub fn init( m.* = .{ .owner = owner, .root_source_file = if (options.root_source_file) |lp| lp.dupe(owner) else null, - .import_table = .{}, + .import_table = .empty, .resolved_target = options.target, .optimize = options.optimize, .link_libc = options.link_libc, .link_libcpp = options.link_libcpp, .dwarf_format = options.dwarf_format, - .c_macros = .{}, - .include_dirs = .{}, - .lib_paths = .{}, - .rpaths = .{}, - .frameworks = .{}, - .link_objects = .{}, + .c_macros = .empty, + .include_dirs = .empty, + .lib_paths = .empty, + .rpaths = .empty, + .frameworks = .empty, + .link_objects = .empty, .strip = options.strip, .unwind_tables = options.unwind_tables, .single_threaded = options.single_threaded, diff --git a/lib/std/Build/Step.zig b/lib/std/Build/Step.zig index b518826843caad753b23051f92840af7b6143a22..5876614099b38b9608006650b464978a87443b6f 100644 --- a/lib/std/Build/Step.zig +++ b/lib/std/Build/Step.zig @@ -250,7 +250,7 @@ pub fn init(options: StepOptions) Step { const first_ret_addr = options.first_ret_addr orelse @returnAddress(); break :blk std.debug.captureCurrentStackTrace(.{ .first_address = first_ret_addr }, addr_buf); }, - .result_error_msgs = .{}, + .result_error_msgs = .empty, .result_error_bundle = std.zig.ErrorBundle.empty, .result_stderr = "", .result_cached = false, diff --git a/lib/std/Build/Step/Run.zig b/lib/std/Build/Step/Run.zig index 8a21e6fef9b3da523b2ad087008b805c7da0e676..63c9f4e6d4c823a32d0d348935c44be2cec84eb9 100644 --- a/lib/std/Build/Step/Run.zig +++ b/lib/std/Build/Step/Run.zig @@ -213,13 +213,13 @@ pub fn create(owner: *std.Build, name: []const u8) *Run { .owner = owner, .makeFn = make, }), - .argv = .{}, + .argv = .empty, .cwd = null, .environ_map = null, .disable_zig_progress = false, .stdio = .infer_from_args, .stdin = .none, - .file_inputs = .{}, + .file_inputs = .empty, .rename_step_with_output_arg = true, .skip_foreign_checks = false, .failing_to_execute_foreign_is_an_error = true, @@ -228,7 +228,7 @@ pub fn create(owner: *std.Build, name: []const u8) *Run { .captured_stderr = null, .dep_output_file = null, .has_side_effects = false, - .fuzz_tests = .{}, + .fuzz_tests = .empty, .rebuilt_executable = null, .producer = null, }; @@ -642,7 +642,7 @@ pub fn addCheck(run: *Run, new_check: StdIo.Check) void { switch (run.stdio) { .infer_from_args => { - run.stdio = .{ .check = .{} }; + run.stdio = .{ .check = .empty }; run.stdio.check.append(b.allocator, new_check) catch @panic("OOM"); }, .check => |*checks| checks.append(b.allocator, new_check) catch @panic("OOM"), diff --git a/lib/std/Build/Step/UpdateSourceFiles.zig b/lib/std/Build/Step/UpdateSourceFiles.zig index 1c4c94f9cf65c1167d72a0ac92c8c5c9ec17a805..0cc3b787c3f8416c284b0977ea9e73b9bf405fd7 100644 --- a/lib/std/Build/Step/UpdateSourceFiles.zig +++ b/lib/std/Build/Step/UpdateSourceFiles.zig @@ -35,7 +35,7 @@ pub fn create(owner: *std.Build) *UpdateSourceFiles { .owner = owner, .makeFn = make, }), - .output_source_files = .{}, + .output_source_files = .empty, }; return usf; } diff --git a/lib/std/Build/Step/WriteFile.zig b/lib/std/Build/Step/WriteFile.zig index 0c0e2b5d8637c10a5c6acae515927c84d690c371..3613fa3fef8fa5ac1a5587a4c4cdcca96661b7b6 100644 --- a/lib/std/Build/Step/WriteFile.zig +++ b/lib/std/Build/Step/WriteFile.zig @@ -94,8 +94,8 @@ pub fn create(owner: *std.Build) *WriteFile { .owner = owner, .makeFn = make, }), - .files = .{}, - .directories = .{}, + .files = .empty, + .directories = .empty, .generated_directory = .{ .step = &write_file.step }, }; return write_file; diff --git a/lib/std/Io/Dir.zig b/lib/std/Io/Dir.zig index 85ab6b77d4990420c32086efaf634dc0fc830938..3e38849f7f60fa80cdd4b3903ccc4e5f07ad4d12 100644 --- a/lib/std/Io/Dir.zig +++ b/lib/std/Io/Dir.zig @@ -334,7 +334,7 @@ pub fn walkSelectively(dir: Dir, allocator: Allocator) !SelectiveWalker { return .{ .stack = stack, - .name_buffer = .{}, + .name_buffer = .empty, .allocator = allocator, }; } diff --git a/lib/std/array_list.zig b/lib/std/array_list.zig index f15388d7b5df62c3112b4ab0902ee587425c0442..d763233beda0ec7805ed71af07932bfe88fecf8a 100644 --- a/lib/std/array_list.zig +++ b/lib/std/array_list.zig @@ -582,10 +582,10 @@ pub fn Aligned(comptime T: type, comptime alignment: ?mem.Alignment) type { /// functions of this ArrayList in accordance with the respective /// documentation. In all cases, "invalidated" means that the memory /// has been passed to an allocator's resize or free function. - items: Slice = &[_]T{}, + items: Slice, /// How many T values this list can hold without allocating /// additional memory. - capacity: usize = 0, + capacity: usize, /// An ArrayList containing no elements. pub const empty: Self = .{ diff --git a/lib/std/compress/lzma.zig b/lib/std/compress/lzma.zig index 7a586298bea5f7b3db346ce9e5cccb834cb05e47..4e3c6146167868e04f257cdec38cb9eb83ae642a 100644 --- a/lib/std/compress/lzma.zig +++ b/lib/std/compress/lzma.zig @@ -349,7 +349,7 @@ pub const Decode = struct { pub fn init(dict_size: usize, mem_limit: usize) CircularBuffer { return .{ - .buf = .{}, + .buf = .empty, .dict_size = dict_size, .mem_limit = mem_limit, .cursor = 0, diff --git a/lib/std/compress/lzma2.zig b/lib/std/compress/lzma2.zig index 7d743f9a1b6c87c06b0aeca93cd8019eb0b75404..42c887c042bac9b239036e2f7bbfbb1657966b20 100644 --- a/lib/std/compress/lzma2.zig +++ b/lib/std/compress/lzma2.zig @@ -16,7 +16,7 @@ pub const AccumBuffer = struct { pub fn init(memlimit: usize) AccumBuffer { return .{ - .buf = .{}, + .buf = .empty, .memlimit = memlimit, .len = 0, }; diff --git a/lib/std/debug/Coverage.zig b/lib/std/debug/Coverage.zig index 81dfce853e0e66c706be73f09407de80d37f339f..b3e16382cc45dff17d34b9bf57f7accb63d918e5 100644 --- a/lib/std/debug/Coverage.zig +++ b/lib/std/debug/Coverage.zig @@ -27,10 +27,10 @@ string_bytes: std.ArrayList(u8), mutex: Io.Mutex, pub const init: Coverage = .{ - .directories = .{}, - .files = .{}, + .directories = .empty, + .files = .empty, .mutex = .init, - .string_bytes = .{}, + .string_bytes = .empty, }; pub const String = enum(u32) { diff --git a/lib/std/zig/Ast.zig b/lib/std/zig/Ast.zig index 3c039b5fe5a54be45e0ca9c4bcee2ba9699a7f57..8620df51fa0dea04e3c075951bf0df0c161dd363 100644 --- a/lib/std/zig/Ast.zig +++ b/lib/std/zig/Ast.zig @@ -175,10 +175,10 @@ pub fn parseTokens( .source = source, .gpa = gpa, .tokens = tokens, - .errors = .{}, - .nodes = .{}, - .extra_data = .{}, - .scratch = .{}, + .errors = .empty, + .nodes = .empty, + .extra_data = .empty, + .scratch = .empty, .tok_i = 0, }; defer parser.errors.deinit(gpa); diff --git a/lib/std/zig/AstGen.zig b/lib/std/zig/AstGen.zig index 046330c46bedffaa8d16036ccb041264373c34b7..1fcb9f5eb2aac77802763ac742913899c71ede4e 100644 --- a/lib/std/zig/AstGen.zig +++ b/lib/std/zig/AstGen.zig @@ -1780,7 +1780,7 @@ fn structInitExpr( try gop.value_ptr.append(sfba_allocator, name_token); any_duplicate = true; } else { - gop.value_ptr.* = .{}; + gop.value_ptr.* = .empty; try gop.value_ptr.append(sfba_allocator, name_token); } } diff --git a/lib/std/zig/ErrorBundle.zig b/lib/std/zig/ErrorBundle.zig index c5275729ae5f1a6efd58ff65b813cc98863b49ff..64aafd110efb9a4d8247450ac85049286871e05a 100644 --- a/lib/std/zig/ErrorBundle.zig +++ b/lib/std/zig/ErrorBundle.zig @@ -340,9 +340,9 @@ pub const Wip = struct { pub fn init(wip: *Wip, gpa: Allocator) !void { wip.* = .{ .gpa = gpa, - .string_bytes = .{}, - .extra = .{}, - .root_list = .{}, + .string_bytes = .empty, + .extra = .empty, + .root_list = .empty, }; // So that 0 can be used to indicate a null string. @@ -371,9 +371,9 @@ pub const Wip = struct { wip.deinit(); wip.* = .{ .gpa = gpa, - .string_bytes = .{}, - .extra = .{}, - .root_list = .{}, + .string_bytes = .empty, + .extra = .empty, + .root_list = .empty, }; return empty; } diff --git a/src/Package/Manifest.zig b/src/Package/Manifest.zig index 3370ef1d47dd6c771c5428adabe7160ea4964992..90d61c963b8a6ac8d6f62028f1e37f4d38a70fb5 100644 --- a/src/Package/Manifest.zig +++ b/src/Package/Manifest.zig @@ -66,7 +66,7 @@ pub fn parse(gpa: Allocator, ast: *const Ast, rng: std.Random, options: ParseOpt .gpa = gpa, .ast = ast.*, .arena = arena_instance.allocator(), - .errors = .{}, + .errors = .empty, .name = undefined, .id = 0, @@ -74,10 +74,10 @@ pub fn parse(gpa: Allocator, ast: *const Ast, rng: std.Random, options: ParseOpt .version_node = undefined, .dependencies = .{}, .dependencies_node = .none, - .paths = .{}, + .paths = .empty, .allow_missing_paths_field = options.allow_missing_paths_field, .minimum_zig_version = null, - .buf = .{}, + .buf = .empty, }; defer p.buf.deinit(gpa); defer p.errors.deinit(gpa); -- 2.54.0