zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit 80bbf234e0d31266c72bb6e93db2d2199ac5920d (tree)
parent 1093b09a989edb8553e79b061bb15c5745f5d193
Author: Lee Cannon <leecannon@leecannon.xyz>
Date:   Fri, 29 Oct 2021 03:00:00 +0100

allocgate: fix failing tests

Diffstat:
Mlib/std/heap/logging_allocator.zig | 4++--
Mlib/std/mem.zig | 4++--
Mlib/std/testing/failing_allocator.zig | 4++--
Mtest/compile_errors.zig | 6+++---
Mtest/standalone/brace_expansion/main.zig | 2+-
5 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/lib/std/heap/logging_allocator.zig b/lib/std/heap/logging_allocator.zig @@ -53,7 +53,7 @@ pub fn ScopedLoggingAllocator( len_align: u29, ra: usize, ) error{OutOfMemory}![]u8 { - const result = self.parent_allocator.allocFn(self.parent_allocator, len, ptr_align, len_align, ra); + const result = self.parent_allocator.allocFn(self.parent_allocator.ptr, len, ptr_align, len_align, ra); if (result) |_| { logHelper( success_log_level, @@ -78,7 +78,7 @@ pub fn ScopedLoggingAllocator( len_align: u29, ra: usize, ) error{OutOfMemory}!usize { - if (self.parent_allocator.resizeFn(self.parent_allocator, buf, buf_align, new_len, len_align, ra)) |resized_len| { + if (self.parent_allocator.resizeFn(self.parent_allocator.ptr, buf, buf_align, new_len, len_align, ra)) |resized_len| { if (new_len == 0) { logHelper(success_log_level, "free - success - len: {}", .{buf.len}); } else if (new_len <= buf.len) { diff --git a/lib/std/mem.zig b/lib/std/mem.zig @@ -40,9 +40,9 @@ pub fn ValidationAllocator(comptime T: type) type { underlying_allocator: T, - pub fn init(allocator: T) @This() { + pub fn init(underlying_allocator: T) @This() { return .{ - .underlying_allocator = allocator, + .underlying_allocator = underlying_allocator, }; } diff --git a/lib/std/testing/failing_allocator.zig b/lib/std/testing/failing_allocator.zig @@ -28,9 +28,9 @@ pub const FailingAllocator = struct { /// var a = try failing_alloc.create(i32); /// var b = try failing_alloc.create(i32); /// testing.expectError(error.OutOfMemory, failing_alloc.create(i32)); - pub fn init(allocator: mem.Allocator, fail_index: usize) FailingAllocator { + pub fn init(internal_allocator: mem.Allocator, fail_index: usize) FailingAllocator { return FailingAllocator{ - .internal_allocator = allocator, + .internal_allocator = internal_allocator, .fail_index = fail_index, .index = 0, .allocated_bytes = 0, diff --git a/test/compile_errors.zig b/test/compile_errors.zig @@ -6550,9 +6550,9 @@ pub fn addCases(ctx: *TestContext) !void { ctx.objErrStage1("method call with first arg type wrong container", \\pub const List = struct { \\ len: usize, - \\ allocator: Allocator, + \\ allocator: *Allocator, \\ - \\ pub fn init(allocator: Allocator) List { + \\ pub fn init(allocator: *Allocator) List { \\ return List { \\ .len = 0, \\ .allocator = allocator, @@ -6573,7 +6573,7 @@ pub fn addCases(ctx: *TestContext) !void { \\ x.init(); \\} , &[_][]const u8{ - "tmp.zig:23:5: error: expected type 'Allocator', found '*List'", + "tmp.zig:23:5: error: expected type '*Allocator', found '*List'", }); ctx.objErrStage1("binary not on number literal", diff --git a/test/standalone/brace_expansion/main.zig b/test/standalone/brace_expansion/main.zig @@ -16,7 +16,7 @@ const Token = union(enum) { }; var gpa = std.heap.GeneralPurposeAllocator(.{}){}; -const global_allocator = gpa.allocator(); +var global_allocator = gpa.allocator(); fn tokenize(input: []const u8) !ArrayList(Token) { const State = enum {