From 093d28dfae39a64ef315c334e70ab3b72a698bb7 Mon Sep 17 00:00:00 2001 From: hixuyuming Date: Fri, 1 May 2026 17:04:01 +0800 Subject: [PATCH] Remove deprecated aliases of ArrayList and update usage sites. --- build.zig | 8 ++--- lib/build-web/fuzz.zig | 2 +- lib/build-web/main.zig | 2 +- lib/compiler/aro/aro/Preprocessor.zig | 2 +- lib/compiler/reduce.zig | 8 ++--- lib/compiler/reduce/Walk.zig | 43 ++++++++++++++------------- lib/docs/wasm/html_render.zig | 2 +- lib/std/crypto/argon2.zig | 4 +-- lib/std/std.zig | 7 ----- src/codegen/spork8/CodeGen.zig | 2 +- src/link/Spork8.zig | 2 +- 11 files changed, 38 insertions(+), 44 deletions(-) diff --git a/build.zig b/build.zig index 6280bf961ae17bd563625c0587b225b4a18e5878..e89d48cf11411cbc0fdbc0920b957c8f2381c917 100644 --- a/build.zig +++ b/build.zig @@ -1119,11 +1119,11 @@ fn addCxxKnownPath( const arena = b.graph.arena; const path_padded = run: { - var args = std.array_list.Managed([]const u8).init(arena); - try args.append(ctx.cxx_compiler); + var args: std.ArrayList([]const u8) = .empty; + try args.append(arena, ctx.cxx_compiler); var it = std.mem.tokenizeAny(u8, ctx.cxx_compiler_arg1, &std.ascii.whitespace); - while (it.next()) |arg| try args.append(arg); - try args.append(b.fmt("-print-file-name={s}", .{objname})); + while (it.next()) |arg| try args.append(arena, arg); + try args.append(arena, b.fmt("-print-file-name={s}", .{objname})); break :run b.run(args.items); }; var tokenizer = mem.tokenizeAny(u8, path_padded, "\r\n"); diff --git a/lib/build-web/fuzz.zig b/lib/build-web/fuzz.zig index 4dcaa9029fff86fcd9a8d65221d4cec52ac432c2..6e88e65ff8103fdd028cc4409e8d54882f803194 100644 --- a/lib/build-web/fuzz.zig +++ b/lib/build-web/fuzz.zig @@ -46,7 +46,7 @@ var coverage = Coverage.init; /// Index of type `SourceLocationIndex`. var coverage_source_locations: std.ArrayList(Coverage.SourceLocation) = .empty; /// Contains the most recent coverage update message, unmodified. -var recent_coverage_update: std.ArrayListAlignedUnmanaged(u8, .of(u64)) = .empty; +var recent_coverage_update: std.array_list.Aligned(u8, .of(u64)) = .empty; fn updateCoverageSources( directories: []const Coverage.String, diff --git a/lib/build-web/main.zig b/lib/build-web/main.zig index 3556d4e2da967e58331d8ea7e793d1053953761d..3084ec2663ec6f8c6184639760633a2a0739f627 100644 --- a/lib/build-web/main.zig +++ b/lib/build-web/main.zig @@ -68,7 +68,7 @@ export fn alloc(n: usize) [*]u8 { return slice.ptr; } -var message_buffer: std.ArrayListAlignedUnmanaged(u8, .of(u64)) = .empty; +var message_buffer: std.array_list.Aligned(u8, .of(u64)) = .empty; /// Resizes the message buffer to be the correct length; returns the pointer to /// the query string. diff --git a/lib/compiler/aro/aro/Preprocessor.zig b/lib/compiler/aro/aro/Preprocessor.zig index 47270ecfed2e361c4d451b682a46950f632d5430..5df5c1c8f9969ff25b83cf11e5b1610f8e14a725 100644 --- a/lib/compiler/aro/aro/Preprocessor.zig +++ b/lib/compiler/aro/aro/Preprocessor.zig @@ -2699,7 +2699,7 @@ const PragmaLoc = struct { name_tok: TokenWithExpansionLocs, start: Tree.TokenIn fn addTokensFromExpandBuf(pp: *Preprocessor, tokens: []const TokenWithExpansionLocs, tokenizer_nl: TokenWithExpansionLocs) !void { const gpa = pp.comp.gpa; - var pragma_locs: std.ArrayListUnmanaged(PragmaLoc) = .empty; + var pragma_locs: std.ArrayList(PragmaLoc) = .empty; defer pragma_locs.deinit(gpa); try pp.ensureUnusedTokenCapacity(tokens.len); diff --git a/lib/compiler/reduce.zig b/lib/compiler/reduce.zig index 398a44a9b4e1d9ec0670db4cd0d2878c37ff6c83..578dc8e2866c06848e4740f4a05b1139575ffc7f 100644 --- a/lib/compiler/reduce.zig +++ b/lib/compiler/reduce.zig @@ -153,9 +153,9 @@ pub fn main(init: std.process.Init) !void { // result, restart the whole process, reparsing the AST and re-generating the list // of all possible transformations and shuffling it again. - var transformations = std.array_list.Managed(Walk.Transformation).init(gpa); - defer transformations.deinit(); - try Walk.findTransformations(arena, &tree, &transformations); + var transformations: std.ArrayList(Walk.Transformation) = .empty; + defer transformations.deinit(gpa); + try Walk.findTransformations(arena, gpa, &tree, &transformations); sortTransformations(transformations.items, rng.random()); fresh: while (transformations.items.len > 0) { @@ -238,7 +238,7 @@ pub fn main(init: std.process.Init) !void { tree.deinit(gpa); tree = new_tree; - try Walk.findTransformations(arena, &tree, &transformations); + try Walk.findTransformations(arena, gpa, &tree, &transformations); sortTransformations(transformations.items, rng.random()); continue :fresh; diff --git a/lib/compiler/reduce/Walk.zig b/lib/compiler/reduce/Walk.zig index 1873c23d77f6c08230e69743e5b6db09285284f4..57ab4579d4c12ef3e6de181b3f7483c8a139b9f4 100644 --- a/lib/compiler/reduce/Walk.zig +++ b/lib/compiler/reduce/Walk.zig @@ -5,7 +5,7 @@ const assert = std.debug.assert; const BuiltinFn = std.zig.BuiltinFn; ast: *const Ast, -transformations: *std.array_list.Managed(Transformation), +transformations: *std.ArrayList(Transformation), unreferenced_globals: std.array_hash_map.String(Ast.Node.Index), in_scope_names: std.array_hash_map.String(u32), replace_names: std.array_hash_map.String(u32), @@ -53,15 +53,16 @@ pub const Error = error{OutOfMemory}; /// The result will be priority shuffled. pub fn findTransformations( arena: std.mem.Allocator, + gpa: std.mem.Allocator, ast: *const Ast, - transformations: *std.array_list.Managed(Transformation), + transformations: *std.ArrayList(Transformation), ) !void { transformations.clearRetainingCapacity(); var walk: Walk = .{ .ast = ast, .transformations = transformations, - .gpa = transformations.allocator, + .gpa = gpa, .arena = arena, .unreferenced_globals = .empty, .in_scope_names = .empty, @@ -76,7 +77,7 @@ pub fn findTransformations( try walkMembers(&walk, walk.ast.rootDecls()); const unreferenced_globals = walk.unreferenced_globals.values(); - try transformations.ensureUnusedCapacity(unreferenced_globals.len); + try transformations.ensureUnusedCapacity(gpa, unreferenced_globals.len); for (unreferenced_globals) |node| { transformations.appendAssumeCapacity(.{ .delete_node = node }); } @@ -148,7 +149,7 @@ fn walkMember(w: *Walk, decl: Ast.Node.Index) Error!void { try walkExpression(w, fn_proto); if (!isFnBodyGutted(ast, body_node)) { w.replace_names.clearRetainingCapacity(); - try w.transformations.append(.{ .gut_function = decl }); + try w.transformations.append(w.gpa, .{ .gut_function = decl }); try walkExpression(w, body_node); } }, @@ -167,7 +168,7 @@ fn walkMember(w: *Walk, decl: Ast.Node.Index) Error!void { => try walkGlobalVarDecl(w, decl, ast.fullVarDecl(decl).?), .test_decl => { - try w.transformations.append(.{ .delete_node = decl }); + try w.transformations.append(w.gpa, .{ .delete_node = decl }); try walkExpression(w, ast.nodeData(decl).opt_token_and_node[1]); }, @@ -175,12 +176,12 @@ fn walkMember(w: *Walk, decl: Ast.Node.Index) Error!void { .container_field_align, .container_field, => { - try w.transformations.append(.{ .delete_node = decl }); + try w.transformations.append(w.gpa, .{ .delete_node = decl }); try walkContainerField(w, ast.fullContainerField(decl).?); }, .@"comptime" => { - try w.transformations.append(.{ .delete_node = decl }); + try w.transformations.append(w.gpa, .{ .delete_node = decl }); try walkExpression(w, decl); }, @@ -536,7 +537,7 @@ fn walkGlobalVarDecl(w: *Walk, decl_node: Ast.Node.Index, var_decl: Ast.full.Var if (var_decl.ast.init_node.unwrap()) |init_node| { if (!isUndefinedIdent(w.ast, init_node)) { - try w.transformations.append(.{ .replace_with_undef = init_node }); + try w.transformations.append(w.gpa, .{ .replace_with_undef = init_node }); } try walkExpression(w, init_node); } @@ -563,7 +564,7 @@ fn walkLocalVarDecl(w: *Walk, var_decl: Ast.full.VarDecl) Error!void { if (var_decl.ast.init_node.unwrap()) |init_node| { if (!isUndefinedIdent(w.ast, init_node)) { - try w.transformations.append(.{ .replace_with_undef = init_node }); + try w.transformations.append(w.gpa, .{ .replace_with_undef = init_node }); } try walkExpression(w, init_node); } @@ -600,7 +601,7 @@ fn walkBlock( if (var_decl.ast.init_node != .none and isUndefinedIdent(w.ast, var_decl.ast.init_node.unwrap().?)) { - try w.transformations.append(.{ .delete_var_decl = .{ + try w.transformations.append(w.gpa, .{ .delete_var_decl = .{ .var_decl_node = stmt, .references = .empty, } }); @@ -618,7 +619,7 @@ fn walkBlock( .discard_identifier => {}, // definitely try to remove `_ = undefined;` though. .discard_undefined, .trap_call, .other => { - try w.transformations.append(.{ .delete_node = stmt }); + try w.transformations.append(w.gpa, .{ .delete_node = stmt }); }, } try walkExpression(w, stmt); @@ -720,7 +721,7 @@ fn walkBuiltinCall( if (std.mem.endsWith(u8, token_bytes, ".zig\"")) { const imported_string = std.zig.string_literal.parseAlloc(w.arena, token_bytes) catch unreachable; - try w.transformations.append(.{ .inline_imported_file = .{ + try w.transformations.append(w.gpa, .{ .inline_imported_file = .{ .builtin_call_node = call_node, .imported_string = imported_string, .in_scope_names = try std.array_hash_map.String(void).init( @@ -792,19 +793,19 @@ fn walkWhile(w: *Walk, node_index: Ast.Node.Index, while_node: Ast.full.While) E if (!isTrueIdent(w.ast, while_node.ast.cond_expr) and (while_node.ast.else_expr == .none or isEmptyBlock(w.ast, while_node.ast.else_expr.unwrap().?))) { - try w.transformations.ensureUnusedCapacity(1); + try w.transformations.ensureUnusedCapacity(w.gpa, 1); w.transformations.appendAssumeCapacity(.{ .replace_with_true = while_node.ast.cond_expr }); } else if (!isFalseIdent(w.ast, while_node.ast.cond_expr) and isEmptyBlock(w.ast, while_node.ast.then_expr)) { - try w.transformations.ensureUnusedCapacity(1); + try w.transformations.ensureUnusedCapacity(w.gpa, 1); w.transformations.appendAssumeCapacity(.{ .replace_with_false = while_node.ast.cond_expr }); } else if (isTrueIdent(w.ast, while_node.ast.cond_expr)) { - try w.transformations.ensureUnusedCapacity(1); + try w.transformations.ensureUnusedCapacity(w.gpa, 1); w.transformations.appendAssumeCapacity(.{ .replace_node = .{ .to_replace = node_index, .replacement = while_node.ast.then_expr, } }); } else if (isFalseIdent(w.ast, while_node.ast.cond_expr)) { - try w.transformations.ensureUnusedCapacity(1); + try w.transformations.ensureUnusedCapacity(w.gpa, 1); w.transformations.appendAssumeCapacity(.{ .replace_node = .{ .to_replace = node_index, .replacement = while_node.ast.else_expr.unwrap().?, @@ -841,19 +842,19 @@ fn walkIf(w: *Walk, node_index: Ast.Node.Index, if_node: Ast.full.If) Error!void if (!isTrueIdent(w.ast, if_node.ast.cond_expr) and (if_node.ast.else_expr == .none or isEmptyBlock(w.ast, if_node.ast.else_expr.unwrap().?))) { - try w.transformations.ensureUnusedCapacity(1); + try w.transformations.ensureUnusedCapacity(w.gpa, 1); w.transformations.appendAssumeCapacity(.{ .replace_with_true = if_node.ast.cond_expr }); } else if (!isFalseIdent(w.ast, if_node.ast.cond_expr) and isEmptyBlock(w.ast, if_node.ast.then_expr)) { - try w.transformations.ensureUnusedCapacity(1); + try w.transformations.ensureUnusedCapacity(w.gpa, 1); w.transformations.appendAssumeCapacity(.{ .replace_with_false = if_node.ast.cond_expr }); } else if (isTrueIdent(w.ast, if_node.ast.cond_expr)) { - try w.transformations.ensureUnusedCapacity(1); + try w.transformations.ensureUnusedCapacity(w.gpa, 1); w.transformations.appendAssumeCapacity(.{ .replace_node = .{ .to_replace = node_index, .replacement = if_node.ast.then_expr, } }); } else if (isFalseIdent(w.ast, if_node.ast.cond_expr)) { - try w.transformations.ensureUnusedCapacity(1); + try w.transformations.ensureUnusedCapacity(w.gpa, 1); w.transformations.appendAssumeCapacity(.{ .replace_node = .{ .to_replace = node_index, .replacement = if_node.ast.else_expr.unwrap().?, diff --git a/lib/docs/wasm/html_render.zig b/lib/docs/wasm/html_render.zig index cb94a016e44aff8d1b219d2f206a42109f635f17..194042ecf5d953311268cfa891344d2b66516af5 100644 --- a/lib/docs/wasm/html_render.zig +++ b/lib/docs/wasm/html_render.zig @@ -32,7 +32,7 @@ pub const Annotation = struct { pub fn fileSourceLineNumbersHtml( file_index: Walk.File.Index, - out: *std.ArrayListUnmanaged(u8), + out: *std.ArrayList(u8), root_node: Ast.Node.Index, ) !void { const ast = file_index.get_ast(); diff --git a/lib/std/crypto/argon2.zig b/lib/std/crypto/argon2.zig index 58f3e2afbbd1d570b2df3d4370fbbd2fe79ccb80..2eedc8dfbb7db84018fef46a0db7fb2a53c65555 100644 --- a/lib/std/crypto/argon2.zig +++ b/lib/std/crypto/argon2.zig @@ -12,7 +12,7 @@ const mem = std.mem; const phc_format = pwhash.phc_format; const pwhash = crypto.pwhash; const Blake2b512 = blake2.Blake2b512; -const Blocks = std.array_list.AlignedManaged([block_length]u64, .@"16"); +const Blocks = std.array_list.Aligned([block_length]u64, .@"16"); const H0 = [Blake2b512.digest_length + 8]u8; const EncodingError = crypto.errors.EncodingError; @@ -504,7 +504,7 @@ pub fn kdf( const memory = blockCount(params); var blocks = try Blocks.initCapacity(allocator, memory); - defer blocks.deinit(); + defer blocks.deinit(allocator); const items = blocks.addManyAsSliceAssumeCapacity(memory); diff --git a/lib/std/std.zig b/lib/std/std.zig index d1d8361967220fe75485de92ef207dfdac3363a0..6f26f556f54eb90c4b312300b9ad3bbd4abd8bbd 100644 --- a/lib/std/std.zig +++ b/lib/std/std.zig @@ -54,13 +54,6 @@ pub fn ArrayList(comptime T: type) type { } pub const array_list = @import("array_list.zig"); -/// Deprecated; use `array_list.Aligned`. -pub const ArrayListAligned = array_list.Aligned; -/// Deprecated; use `array_list.Aligned`. -pub const ArrayListAlignedUnmanaged = array_list.Aligned; -/// Deprecated; use `ArrayList`. -pub const ArrayListUnmanaged = ArrayList; - pub const array_hash_map = @import("array_hash_map.zig"); pub const atomic = @import("atomic.zig"); pub const base64 = @import("base64.zig"); diff --git a/src/codegen/spork8/CodeGen.zig b/src/codegen/spork8/CodeGen.zig index 94ed016dc40b72983234b61a5889eedad9ef0088..baa981bb2bf3fd4530cd63401df39095990ce7f3 100644 --- a/src/codegen/spork8/CodeGen.zig +++ b/src/codegen/spork8/CodeGen.zig @@ -21,7 +21,7 @@ owner_nav: InternPool.Nav.Index, func_index: InternPool.Index, mir_instructions: std.MultiArrayList(Mir.Inst), /// Contains extra data for MIR -mir_extra: std.ArrayListUnmanaged(u32), +mir_extra: std.ArrayList(u32), pub fn legalizeFeatures(_: *const std.Target) *const Air.Legalize.Features { return comptime &.initMany(&.{ diff --git a/src/link/Spork8.zig b/src/link/Spork8.zig index d36922e9257a4981e1c287b12a668c60fbca1e79..80caa5cc3c3316cf21656c9abb35996b6fc94c85 100644 --- a/src/link/Spork8.zig +++ b/src/link/Spork8.zig @@ -24,7 +24,7 @@ base: link.File, /// All MIR instructions for all Zcu functions. mir_instructions: std.MultiArrayList(Mir.Inst) = .empty, /// Corresponds to `mir_instructions`. -mir_extra: std.ArrayListUnmanaged(u32) = .empty, +mir_extra: std.ArrayList(u32) = .empty, /// When the key is an enum type, this represents a `@tagName` function. zcu_funcs: std.array_hash_map.Auto(InternPool.Index, ZcuFunc) = .empty, -- 2.54.0