From 75548b50ff23a3de48d166170425001c073d27c1 Mon Sep 17 00:00:00 2001 From: Lee Cannon Date: Fri, 29 Oct 2021 02:03:15 +0100 Subject: allocgate: stage 1 and 2 building --- test/compile_errors.zig | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'test/compile_errors.zig') diff --git a/test/compile_errors.zig b/test/compile_errors.zig index 09a165304c..3ed4743275 100644 --- 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", @@ -7569,7 +7569,7 @@ pub fn addCases(ctx: *TestContext) !void { \\ \\export fn entry() void { \\ const a = MdNode.Header { - \\ .text = MdText.init(&std.testing.allocator), + \\ .text = MdText.init(std.testing.allocator), \\ .weight = HeaderWeight.H1, \\ }; \\ _ = a; -- cgit v1.2.3 From 80bbf234e0d31266c72bb6e93db2d2199ac5920d Mon Sep 17 00:00:00 2001 From: Lee Cannon Date: Fri, 29 Oct 2021 03:00:00 +0100 Subject: allocgate: fix failing tests --- lib/std/heap/logging_allocator.zig | 4 ++-- lib/std/mem.zig | 4 ++-- lib/std/testing/failing_allocator.zig | 4 ++-- test/compile_errors.zig | 6 +++--- test/standalone/brace_expansion/main.zig | 2 +- 5 files changed, 10 insertions(+), 10 deletions(-) (limited to 'test/compile_errors.zig') diff --git a/lib/std/heap/logging_allocator.zig b/lib/std/heap/logging_allocator.zig index da9e731fd5..698b37da6c 100644 --- 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 index 37b1141272..79c739ca62 100644 --- 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 index 15da5091fb..35eef3a98c 100644 --- 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 index 3ed4743275..8dfb44cf80 100644 --- 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 index 6bc5501853..54590c65b2 100644 --- 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 { -- cgit v1.2.3