From 9b83c6713a5d81a12b5c26b1b7e42beeb62192fa Mon Sep 17 00:00:00 2001 From: meowjesty Date: Sat, 22 Nov 2025 18:00:00 -0300 Subject: [PATCH 1/3] Fix use of deprecated std.array_list.Managed.init used as an example in testing_detect_leak. --- doc/langref/testing_detect_leak.zig | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/doc/langref/testing_detect_leak.zig b/doc/langref/testing_detect_leak.zig index c99fc03bf6d0..5a4e6804bb01 100644 --- a/doc/langref/testing_detect_leak.zig +++ b/doc/langref/testing_detect_leak.zig @@ -1,9 +1,10 @@ const std = @import("std"); test "detect leak" { - var list = std.array_list.Managed(u21).init(std.testing.allocator); - // missing `defer list.deinit();` - try list.append('☔'); + const allocator = std.testing.allocator; + var list = try std.ArrayList(u21).initCapacity(allocator, 1); + // missing `defer list.deinit(allocator);` + try list.append(allocator, '☔'); try std.testing.expect(list.items.len == 1); } From 6bcf0066b1a0b972b215f2ebb49c94aaaa3a151a Mon Sep 17 00:00:00 2001 From: meowjesty <43983236+meowjesty@users.noreply.github.com> Date: Sat, 22 Nov 2025 22:18:27 -0300 Subject: [PATCH 2/3] Use `.empty` for initialization. Co-authored-by: Rue <78876133+IOKG04@users.noreply.github.com> --- doc/langref/testing_detect_leak.zig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/langref/testing_detect_leak.zig b/doc/langref/testing_detect_leak.zig index 5a4e6804bb01..f3a3cfb82a2d 100644 --- a/doc/langref/testing_detect_leak.zig +++ b/doc/langref/testing_detect_leak.zig @@ -2,7 +2,7 @@ const std = @import("std"); test "detect leak" { const allocator = std.testing.allocator; - var list = try std.ArrayList(u21).initCapacity(allocator, 1); + var list: std.ArrayList(u21) = .empty; // missing `defer list.deinit(allocator);` try list.append(allocator, '☔'); From ee20305ec81d965501c525232b0aa05e04ecb6de Mon Sep 17 00:00:00 2001 From: meowjesty Date: Sat, 22 Nov 2025 22:20:21 -0300 Subject: [PATCH 3/3] Rename allocator to gpa. --- doc/langref/testing_detect_leak.zig | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/langref/testing_detect_leak.zig b/doc/langref/testing_detect_leak.zig index f3a3cfb82a2d..fd72fc9bba94 100644 --- a/doc/langref/testing_detect_leak.zig +++ b/doc/langref/testing_detect_leak.zig @@ -1,10 +1,10 @@ const std = @import("std"); test "detect leak" { - const allocator = std.testing.allocator; + const gpa = std.testing.allocator; var list: std.ArrayList(u21) = .empty; - // missing `defer list.deinit(allocator);` - try list.append(allocator, '☔'); + // missing `defer list.deinit(gpa);` + try list.append(gpa, '☔'); try std.testing.expect(list.items.len == 1); }