From f8e8371f04d4cf342a5e88b670cbfdc356e6d3d8 Mon Sep 17 00:00:00 2001 From: Lee Cannon Date: Sun, 18 Jun 2023 22:29:24 +0100 Subject: [PATCH] Fixed compatibility with latest builds of Zig (#1246) * zig_change: `alignForward` requires type parameter * zig_change: `std.builtin.Version` -> `std.SemanticVersion` --- build.zig | 6 +++--- src/analyser/encoding.zig | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/build.zig b/build.zig index 3ceacfa..7f56f63 100644 --- a/build.zig +++ b/build.zig @@ -2,12 +2,12 @@ const std = @import("std"); const builtin = @import("builtin"); const shared = @import("src/shared.zig"); -const zls_version = std.builtin.Version{ .major = 0, .minor = 11, .patch = 0 }; +const zls_version = std.SemanticVersion{ .major = 0, .minor = 11, .patch = 0 }; pub fn build(b: *std.build.Builder) !void { comptime { const current_zig = builtin.zig_version; - const min_zig = std.SemanticVersion.parse("0.11.0-dev.3312+ab37ab33c") catch unreachable; // poly1305: properly cast the mask from u1 to u64 + const min_zig = std.SemanticVersion.parse("0.11.0-dev.3696+8d0a8c285") catch unreachable; // std.builtin.Version -> std.SemanticVersion if (current_zig.order(min_zig) == .lt) { @compileError(std.fmt.comptimePrint("Your Zig version v{} does not meet the minimum build requirement of v{}", .{ current_zig, min_zig })); } @@ -65,7 +65,7 @@ pub fn build(b: *std.build.Builder) !void { const commit_height = it.next().?; const commit_id = it.next().?; - const ancestor_ver = try std.builtin.Version.parse(tagged_ancestor); + const ancestor_ver = try std.SemanticVersion.parse(tagged_ancestor); std.debug.assert(zls_version.order(ancestor_ver) == .gt); // zls version must be greater than its previous version std.debug.assert(std.mem.startsWith(u8, commit_id, "g")); // commit hash is prefixed with a 'g' diff --git a/src/analyser/encoding.zig b/src/analyser/encoding.zig index 79f9709..12eda49 100644 --- a/src/analyser/encoding.zig +++ b/src/analyser/encoding.zig @@ -193,7 +193,7 @@ pub fn canEncodeAsBytes(comptime T: type) bool { /// forward aligns `extra` until it has the given alignment pub fn alignForward(extra: []const u8, alignment: usize) []const u8 { const unaligned = @ptrToInt(extra.ptr); - const offset = std.mem.alignForward(unaligned, alignment) - unaligned; + const offset = std.mem.alignForward(usize, unaligned, alignment) - unaligned; const result = extra[offset..]; std.debug.assert(std.mem.isAligned(@ptrToInt(result.ptr), alignment)); return result;