Fixed compatibility with latest builds of Zig (#1246)

* zig_change: `alignForward` requires type parameter

* zig_change: `std.builtin.Version` -> `std.SemanticVersion`
This commit is contained in:
Lee Cannon 2023-06-18 22:29:24 +01:00 committed by GitHub
parent f6da47fafd
commit f8e8371f04
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 4 deletions

View File

@ -2,12 +2,12 @@ const std = @import("std");
const builtin = @import("builtin"); const builtin = @import("builtin");
const shared = @import("src/shared.zig"); 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 { pub fn build(b: *std.build.Builder) !void {
comptime { comptime {
const current_zig = builtin.zig_version; 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) { 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 })); @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_height = it.next().?;
const commit_id = 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(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' std.debug.assert(std.mem.startsWith(u8, commit_id, "g")); // commit hash is prefixed with a 'g'

View File

@ -193,7 +193,7 @@ pub fn canEncodeAsBytes(comptime T: type) bool {
/// forward aligns `extra` until it has the given alignment /// forward aligns `extra` until it has the given alignment
pub fn alignForward(extra: []const u8, alignment: usize) []const u8 { pub fn alignForward(extra: []const u8, alignment: usize) []const u8 {
const unaligned = @ptrToInt(extra.ptr); 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..]; const result = extra[offset..];
std.debug.assert(std.mem.isAligned(@ptrToInt(result.ptr), alignment)); std.debug.assert(std.mem.isAligned(@ptrToInt(result.ptr), alignment));
return result; return result;