Replace deprecated ArrayListUnmanaged with ArrayList

std.ArrayListUnmanaged is now std.ArrayList in Zig 0.15.
The old managed ArrayList is deprecated as std.array_list.Managed.
This commit is contained in:
2026-01-22 12:45:49 +05:30
parent 0f2f19f9b1
commit ca573f3166
6 changed files with 49 additions and 49 deletions

View File

@@ -65,7 +65,7 @@ const TemplateGenStep = struct {
const b = step.owner; const b = step.owner;
const allocator = b.allocator; const allocator = b.allocator;
var templates = std.ArrayListUnmanaged(TemplateInfo){}; var templates = std.ArrayList(TemplateInfo){};
defer templates.deinit(allocator); defer templates.deinit(allocator);
try findTemplates(allocator, self.options.source_dir, "", self.options.extension, &templates); try findTemplates(allocator, self.options.source_dir, "", self.options.extension, &templates);
@@ -86,7 +86,7 @@ fn findTemplates(
base_dir: []const u8, base_dir: []const u8,
sub_path: []const u8, sub_path: []const u8,
extension: []const u8, extension: []const u8,
templates: *std.ArrayListUnmanaged(TemplateInfo), templates: *std.ArrayList(TemplateInfo),
) !void { ) !void {
const full_path = if (sub_path.len > 0) const full_path = if (sub_path.len > 0)
try std.fs.path.join(allocator, &.{ base_dir, sub_path }) try std.fs.path.join(allocator, &.{ base_dir, sub_path })
@@ -144,7 +144,7 @@ fn generateSingleFile(
out_path: []const u8, out_path: []const u8,
templates: []const TemplateInfo, templates: []const TemplateInfo,
) !void { ) !void {
var out = std.ArrayListUnmanaged(u8){}; var out = std.ArrayList(u8){};
defer out.deinit(allocator); defer out.deinit(allocator);
const w = out.writer(allocator); const w = out.writer(allocator);
@@ -255,7 +255,7 @@ fn generateSingleFile(
fn compileTemplate( fn compileTemplate(
allocator: std.mem.Allocator, allocator: std.mem.Allocator,
w: std.ArrayListUnmanaged(u8).Writer, w: std.ArrayList(u8).Writer,
name: []const u8, name: []const u8,
source: []const u8, source: []const u8,
) !void { ) !void {
@@ -381,12 +381,12 @@ fn nodeHasDynamic(node: ast.Node) bool {
const Compiler = struct { const Compiler = struct {
allocator: std.mem.Allocator, allocator: std.mem.Allocator,
writer: std.ArrayListUnmanaged(u8).Writer, writer: std.ArrayList(u8).Writer,
buf: std.ArrayListUnmanaged(u8), // Buffer for merging static strings buf: std.ArrayList(u8), // Buffer for merging static strings
depth: usize, depth: usize,
loop_vars: std.ArrayListUnmanaged([]const u8), // Track loop variable names loop_vars: std.ArrayList([]const u8), // Track loop variable names
fn init(allocator: std.mem.Allocator, writer: std.ArrayListUnmanaged(u8).Writer) Compiler { fn init(allocator: std.mem.Allocator, writer: std.ArrayList(u8).Writer) Compiler {
return .{ return .{
.allocator = allocator, .allocator = allocator,
.writer = writer, .writer = writer,

View File

@@ -55,7 +55,7 @@ const whitespace_sensitive = std.StaticStringMap(void).initComptime(.{
pub const CodeGen = struct { pub const CodeGen = struct {
allocator: std.mem.Allocator, allocator: std.mem.Allocator,
options: Options, options: Options,
output: std.ArrayListUnmanaged(u8), output: std.ArrayList(u8),
depth: usize, depth: usize,
/// Track if we're inside a whitespace-sensitive element. /// Track if we're inside a whitespace-sensitive element.
preserve_whitespace: bool, preserve_whitespace: bool,

View File

@@ -29,7 +29,7 @@ pub fn compileDoc(allocator: std.mem.Allocator, name: []const u8, doc: ast.Docum
const Compiler = struct { const Compiler = struct {
alloc: std.mem.Allocator, alloc: std.mem.Allocator,
out: std.ArrayListUnmanaged(u8), out: std.ArrayList(u8),
depth: u8, depth: u8,
fn init(allocator: std.mem.Allocator) Compiler { fn init(allocator: std.mem.Allocator) Compiler {

View File

@@ -128,8 +128,8 @@ pub const Lexer = struct {
pos: usize, pos: usize,
line: usize, line: usize,
column: usize, column: usize,
indent_stack: std.ArrayListUnmanaged(usize), indent_stack: std.ArrayList(usize),
tokens: std.ArrayListUnmanaged(Token), tokens: std.ArrayList(Token),
allocator: std.mem.Allocator, allocator: std.mem.Allocator,
at_line_start: bool, at_line_start: bool,
current_indent: usize, current_indent: usize,

View File

@@ -54,7 +54,7 @@ pub const Parser = struct {
/// Parses all tokens and returns the document AST. /// Parses all tokens and returns the document AST.
pub fn parse(self: *Parser) Error!ast.Document { pub fn parse(self: *Parser) Error!ast.Document {
var nodes = std.ArrayListUnmanaged(Node).empty; var nodes = std.ArrayList(Node).empty;
errdefer nodes.deinit(self.allocator); errdefer nodes.deinit(self.allocator);
var extends_path: ?[]const u8 = null; var extends_path: ?[]const u8 = null;
@@ -122,9 +122,9 @@ pub const Parser = struct {
/// Parses an HTML element with optional tag, classes, id, attributes, and children. /// Parses an HTML element with optional tag, classes, id, attributes, and children.
fn parseElement(self: *Parser) Error!Node { fn parseElement(self: *Parser) Error!Node {
var tag: []const u8 = "div"; // default tag var tag: []const u8 = "div"; // default tag
var classes = std.ArrayListUnmanaged([]const u8).empty; var classes = std.ArrayList([]const u8).empty;
var id: ?[]const u8 = null; var id: ?[]const u8 = null;
var attributes = std.ArrayListUnmanaged(Attribute).empty; var attributes = std.ArrayList(Attribute).empty;
var spread_attributes: ?[]const u8 = null; var spread_attributes: ?[]const u8 = null;
var self_closing = false; var self_closing = false;
@@ -174,7 +174,7 @@ pub const Parser = struct {
self.skipWhitespace(); self.skipWhitespace();
// Parse the inline nested element // Parse the inline nested element
var children = std.ArrayListUnmanaged(Node).empty; var children = std.ArrayList(Node).empty;
errdefer children.deinit(self.allocator); errdefer children.deinit(self.allocator);
if (try self.parseNode()) |child| { if (try self.parseNode()) |child| {
@@ -223,7 +223,7 @@ pub const Parser = struct {
_ = self.advance(); _ = self.advance();
const raw_content = try self.parseRawTextBlock(); const raw_content = try self.parseRawTextBlock();
var children = std.ArrayListUnmanaged(Node).empty; var children = std.ArrayList(Node).empty;
errdefer children.deinit(self.allocator); errdefer children.deinit(self.allocator);
try children.append(self.allocator, .{ .raw_text = .{ .content = raw_content } }); try children.append(self.allocator, .{ .raw_text = .{ .content = raw_content } });
@@ -245,7 +245,7 @@ pub const Parser = struct {
self.skipNewlines(); self.skipNewlines();
// Parse children if indented // Parse children if indented
var children = std.ArrayListUnmanaged(Node).empty; var children = std.ArrayList(Node).empty;
errdefer children.deinit(self.allocator); errdefer children.deinit(self.allocator);
if (self.check(.indent)) { if (self.check(.indent)) {
@@ -267,7 +267,7 @@ pub const Parser = struct {
} }
/// Parses attributes within parentheses. /// Parses attributes within parentheses.
fn parseAttributes(self: *Parser, attributes: *std.ArrayListUnmanaged(Attribute)) Error!void { fn parseAttributes(self: *Parser, attributes: *std.ArrayList(Attribute)) Error!void {
while (!self.check(.rparen) and !self.isAtEnd()) { while (!self.check(.rparen) and !self.isAtEnd()) {
// Skip commas // Skip commas
if (self.check(.comma)) { if (self.check(.comma)) {
@@ -302,7 +302,7 @@ pub const Parser = struct {
/// Parses text segments (literals and interpolations). /// Parses text segments (literals and interpolations).
fn parseTextSegments(self: *Parser) Error![]TextSegment { fn parseTextSegments(self: *Parser) Error![]TextSegment {
var segments = std.ArrayListUnmanaged(TextSegment).empty; var segments = std.ArrayList(TextSegment).empty;
errdefer segments.deinit(self.allocator); errdefer segments.deinit(self.allocator);
while (self.check(.text) or self.check(.interp_start) or self.check(.interp_start_unesc) or self.check(.tag_interp_start)) { while (self.check(.text) or self.check(.interp_start) or self.check(.interp_start_unesc) or self.check(.tag_interp_start)) {
@@ -338,9 +338,9 @@ pub const Parser = struct {
_ = self.advance(); // skip #[ _ = self.advance(); // skip #[
var tag: []const u8 = "span"; // default tag var tag: []const u8 = "span"; // default tag
var classes = std.ArrayListUnmanaged([]const u8).empty; var classes = std.ArrayList([]const u8).empty;
var id: ?[]const u8 = null; var id: ?[]const u8 = null;
var attributes = std.ArrayListUnmanaged(Attribute).empty; var attributes = std.ArrayList(Attribute).empty;
errdefer classes.deinit(self.allocator); errdefer classes.deinit(self.allocator);
errdefer attributes.deinit(self.allocator); errdefer attributes.deinit(self.allocator);
@@ -369,7 +369,7 @@ pub const Parser = struct {
} }
// Parse inner text segments (may contain nested interpolations) // Parse inner text segments (may contain nested interpolations)
var text_segments = std.ArrayListUnmanaged(TextSegment).empty; var text_segments = std.ArrayList(TextSegment).empty;
errdefer text_segments.deinit(self.allocator); errdefer text_segments.deinit(self.allocator);
while (!self.check(.tag_interp_end) and !self.check(.newline) and !self.isAtEnd()) { while (!self.check(.tag_interp_end) and !self.check(.newline) and !self.isAtEnd()) {
@@ -415,7 +415,7 @@ pub const Parser = struct {
} }
/// Parses children within an indented block. /// Parses children within an indented block.
fn parseChildren(self: *Parser, children: *std.ArrayListUnmanaged(Node)) Error!void { fn parseChildren(self: *Parser, children: *std.ArrayList(Node)) Error!void {
while (!self.check(.dedent) and !self.isAtEnd()) { while (!self.check(.dedent) and !self.isAtEnd()) {
self.skipNewlines(); self.skipNewlines();
if (self.check(.dedent) or self.isAtEnd()) break; if (self.check(.dedent) or self.isAtEnd()) break;
@@ -433,7 +433,7 @@ pub const Parser = struct {
/// Parses a raw text block (after `.`). /// Parses a raw text block (after `.`).
fn parseRawTextBlock(self: *Parser) Error![]const u8 { fn parseRawTextBlock(self: *Parser) Error![]const u8 {
var lines = std.ArrayListUnmanaged(u8).empty; var lines = std.ArrayList(u8).empty;
errdefer lines.deinit(self.allocator); errdefer lines.deinit(self.allocator);
while (!self.check(.dedent) and !self.isAtEnd()) { while (!self.check(.dedent) and !self.isAtEnd()) {
@@ -470,7 +470,7 @@ pub const Parser = struct {
/// Parses conditional (if/else if/else/unless). /// Parses conditional (if/else if/else/unless).
fn parseConditional(self: *Parser) Error!Node { fn parseConditional(self: *Parser) Error!Node {
var branches = std.ArrayListUnmanaged(ast.Conditional.Branch).empty; var branches = std.ArrayList(ast.Conditional.Branch).empty;
errdefer branches.deinit(self.allocator); errdefer branches.deinit(self.allocator);
// Parse initial if/unless // Parse initial if/unless
@@ -483,7 +483,7 @@ pub const Parser = struct {
self.skipNewlines(); self.skipNewlines();
// Parse body // Parse body
var body = std.ArrayListUnmanaged(Node).empty; var body = std.ArrayList(Node).empty;
errdefer body.deinit(self.allocator); errdefer body.deinit(self.allocator);
if (self.check(.indent)) { if (self.check(.indent)) {
@@ -512,7 +512,7 @@ pub const Parser = struct {
self.skipNewlines(); self.skipNewlines();
var else_body = std.ArrayListUnmanaged(Node).empty; var else_body = std.ArrayList(Node).empty;
errdefer else_body.deinit(self.allocator); errdefer else_body.deinit(self.allocator);
if (self.check(.indent)) { if (self.check(.indent)) {
@@ -590,7 +590,7 @@ pub const Parser = struct {
self.skipNewlines(); self.skipNewlines();
// Parse body // Parse body
var body = std.ArrayListUnmanaged(Node).empty; var body = std.ArrayList(Node).empty;
errdefer body.deinit(self.allocator); errdefer body.deinit(self.allocator);
if (self.check(.indent)) { if (self.check(.indent)) {
@@ -599,7 +599,7 @@ pub const Parser = struct {
} }
// Check for else branch // Check for else branch
var else_children = std.ArrayListUnmanaged(Node).empty; var else_children = std.ArrayList(Node).empty;
errdefer else_children.deinit(self.allocator); errdefer else_children.deinit(self.allocator);
if (self.check(.kw_else)) { if (self.check(.kw_else)) {
@@ -629,7 +629,7 @@ pub const Parser = struct {
self.skipNewlines(); self.skipNewlines();
var body = std.ArrayListUnmanaged(Node).empty; var body = std.ArrayList(Node).empty;
errdefer body.deinit(self.allocator); errdefer body.deinit(self.allocator);
if (self.check(.indent)) { if (self.check(.indent)) {
@@ -651,10 +651,10 @@ pub const Parser = struct {
self.skipNewlines(); self.skipNewlines();
var whens = std.ArrayListUnmanaged(ast.Case.When).empty; var whens = std.ArrayList(ast.Case.When).empty;
errdefer whens.deinit(self.allocator); errdefer whens.deinit(self.allocator);
var default_children = std.ArrayListUnmanaged(Node).empty; var default_children = std.ArrayList(Node).empty;
errdefer default_children.deinit(self.allocator); errdefer default_children.deinit(self.allocator);
// Parse indented when/default clauses // Parse indented when/default clauses
@@ -675,7 +675,7 @@ pub const Parser = struct {
value = try self.parseRestOfLine(); value = try self.parseRestOfLine();
} }
var when_children = std.ArrayListUnmanaged(Node).empty; var when_children = std.ArrayList(Node).empty;
errdefer when_children.deinit(self.allocator); errdefer when_children.deinit(self.allocator);
var has_break = false; var has_break = false;
@@ -778,8 +778,8 @@ pub const Parser = struct {
} }
// Parse parameters if present // Parse parameters if present
var params = std.ArrayListUnmanaged([]const u8).empty; var params = std.ArrayList([]const u8).empty;
var defaults = std.ArrayListUnmanaged(?[]const u8).empty; var defaults = std.ArrayList(?[]const u8).empty;
errdefer params.deinit(self.allocator); errdefer params.deinit(self.allocator);
errdefer defaults.deinit(self.allocator); errdefer defaults.deinit(self.allocator);
@@ -830,7 +830,7 @@ pub const Parser = struct {
self.skipNewlines(); self.skipNewlines();
// Parse body // Parse body
var body = std.ArrayListUnmanaged(Node).empty; var body = std.ArrayList(Node).empty;
errdefer body.deinit(self.allocator); errdefer body.deinit(self.allocator);
if (self.check(.indent)) { if (self.check(.indent)) {
@@ -851,8 +851,8 @@ pub const Parser = struct {
fn parseMixinCall(self: *Parser) Error!Node { fn parseMixinCall(self: *Parser) Error!Node {
const name = self.advance().value; // +name const name = self.advance().value; // +name
var args = std.ArrayListUnmanaged([]const u8).empty; var args = std.ArrayList([]const u8).empty;
var attributes = std.ArrayListUnmanaged(Attribute).empty; var attributes = std.ArrayList(Attribute).empty;
errdefer args.deinit(self.allocator); errdefer args.deinit(self.allocator);
errdefer attributes.deinit(self.allocator); errdefer attributes.deinit(self.allocator);
@@ -894,7 +894,7 @@ pub const Parser = struct {
self.skipNewlines(); self.skipNewlines();
// Parse block content // Parse block content
var block_children = std.ArrayListUnmanaged(Node).empty; var block_children = std.ArrayList(Node).empty;
errdefer block_children.deinit(self.allocator); errdefer block_children.deinit(self.allocator);
if (self.check(.indent)) { if (self.check(.indent)) {
@@ -979,7 +979,7 @@ pub const Parser = struct {
self.skipNewlines(); self.skipNewlines();
// Parse body // Parse body
var body = std.ArrayListUnmanaged(Node).empty; var body = std.ArrayList(Node).empty;
errdefer body.deinit(self.allocator); errdefer body.deinit(self.allocator);
if (self.check(.indent)) { if (self.check(.indent)) {
@@ -1011,7 +1011,7 @@ pub const Parser = struct {
self.skipNewlines(); self.skipNewlines();
// Parse body // Parse body
var body = std.ArrayListUnmanaged(Node).empty; var body = std.ArrayList(Node).empty;
errdefer body.deinit(self.allocator); errdefer body.deinit(self.allocator);
if (self.check(.indent)) { if (self.check(.indent)) {
@@ -1052,7 +1052,7 @@ pub const Parser = struct {
self.skipNewlines(); self.skipNewlines();
// Parse nested comment content // Parse nested comment content
var children = std.ArrayListUnmanaged(Node).empty; var children = std.ArrayList(Node).empty;
errdefer children.deinit(self.allocator); errdefer children.deinit(self.allocator);
if (self.check(.indent)) { if (self.check(.indent)) {
@@ -1091,7 +1091,7 @@ pub const Parser = struct {
/// Parses rest of line as text. /// Parses rest of line as text.
fn parseRestOfLine(self: *Parser) Error![]const u8 { fn parseRestOfLine(self: *Parser) Error![]const u8 {
var result = std.ArrayListUnmanaged(u8).empty; var result = std.ArrayList(u8).empty;
errdefer result.deinit(self.allocator); errdefer result.deinit(self.allocator);
while (!self.check(.newline) and !self.check(.indent) and !self.check(.dedent) and !self.isAtEnd()) { while (!self.check(.newline) and !self.check(.indent) and !self.check(.dedent) and !self.isAtEnd()) {

View File

@@ -128,7 +128,7 @@ pub const Context = struct {
allocator: std.mem.Allocator, allocator: std.mem.Allocator,
/// Stack of variable scopes (innermost last). /// Stack of variable scopes (innermost last).
/// We keep all scopes allocated and track active depth with scope_depth. /// We keep all scopes allocated and track active depth with scope_depth.
scopes: std.ArrayListUnmanaged(std.StringHashMapUnmanaged(Value)), scopes: std.ArrayList(std.StringHashMapUnmanaged(Value)),
/// Current active scope depth (scopes[0..scope_depth] are active). /// Current active scope depth (scopes[0..scope_depth] are active).
scope_depth: usize, scope_depth: usize,
/// Mixin definitions available in this context. /// Mixin definitions available in this context.
@@ -242,7 +242,7 @@ const BlockDef = struct {
pub const Runtime = struct { pub const Runtime = struct {
allocator: std.mem.Allocator, allocator: std.mem.Allocator,
context: *Context, context: *Context,
output: std.ArrayListUnmanaged(u8), output: std.ArrayList(u8),
depth: usize, depth: usize,
options: Options, options: Options,
/// File resolver for loading external templates. /// File resolver for loading external templates.
@@ -431,7 +431,7 @@ pub const Runtime = struct {
} }
// Collect all classes: shorthand classes + class attributes (may be arrays) // Collect all classes: shorthand classes + class attributes (may be arrays)
var all_classes = std.ArrayListUnmanaged(u8).empty; var all_classes = std.ArrayList(u8).empty;
defer all_classes.deinit(self.allocator); defer all_classes.deinit(self.allocator);
// Add shorthand classes first (e.g., .bang) // Add shorthand classes first (e.g., .bang)
@@ -1580,7 +1580,7 @@ fn parseArrayToSpaceSeparated(allocator: std.mem.Allocator, input: []const u8) !
const content = std.mem.trim(u8, trimmed[1 .. trimmed.len - 1], " \t\n\r"); const content = std.mem.trim(u8, trimmed[1 .. trimmed.len - 1], " \t\n\r");
if (content.len == 0) return ""; if (content.len == 0) return "";
var result = std.ArrayListUnmanaged(u8).empty; var result = std.ArrayList(u8).empty;
errdefer result.deinit(allocator); errdefer result.deinit(allocator);
var pos: usize = 0; var pos: usize = 0;
@@ -1643,7 +1643,7 @@ fn parseObjectToCSS(allocator: std.mem.Allocator, input: []const u8) ![]const u8
const content = std.mem.trim(u8, trimmed[1 .. trimmed.len - 1], " \t\n\r"); const content = std.mem.trim(u8, trimmed[1 .. trimmed.len - 1], " \t\n\r");
if (content.len == 0) return ""; if (content.len == 0) return "";
var result = std.ArrayListUnmanaged(u8).empty; var result = std.ArrayList(u8).empty;
errdefer result.deinit(allocator); errdefer result.deinit(allocator);
var pos: usize = 0; var pos: usize = 0;