Skip to content

Commit

Permalink
Miscellaneous zig std api breaking changes fix (#1620)
Browse files Browse the repository at this point in the history
* zig std had removed meta.trait

ps: this change need set minimum zig build version to 0.12.0-dev.1686+d5e21a4f1

* std.fs: split Dir into IterableDir

ziglang/zig#12060

* rework std.atomic

ziglang/zig#18085

* set minimum build version to 0.12.0-dev.1710+2bffd8101

* Update binned_allocator.zig

* build.zig.zon: Update `known-folders`

---------

Co-authored-by: nullptrdevs <[email protected]>
  • Loading branch information
jimying and llogick authored Nov 26, 2023
1 parent 38a1998 commit a0affc7
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ const builtin = @import("builtin");
const zls_version = std.SemanticVersion{ .major = 0, .minor = 12, .patch = 0 };

/// document the latest breaking change that caused a change to the string below:
/// compiler: add error for unnecessary use of 'var'
const min_zig_string = "0.12.0-dev.1663+6b1a823b2b";
/// compiler: rework std.atomic
const min_zig_string = "0.12.0-dev.1710+2bffd8101";

pub fn build(b: *std.build.Builder) !void {
comptime {
Expand Down
4 changes: 2 additions & 2 deletions build.zig.zon
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

.dependencies = .{
.known_folders = .{
.url = "https://github.com/ziglibs/known-folders/archive/855473062efac722624737f1adc56f9c0dd92017.tar.gz",
.hash = "1220f9d9dd88b1352b1a2bde4a96f547a1591d66ad0a9d76854d0c2c7fa59eef2508",
.url = "https://github.com/ziglibs/known-folders/archive/8bb4bf761bab20ffed74ffac83c3a9eb4456f28d.tar.gz",
.hash = "122002462f37b67a54fa1ab712d870d4637dae0d94437c0077b148e1fb75616c573d",
},
.diffz = .{
.url = "https://github.com/ziglibs/diffz/archive/86f5435f63961dcdba8b76e47b44e2381671fb09.tar.gz",
Expand Down
2 changes: 1 addition & 1 deletion src/DocumentStore.zig
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ pub const Handle = struct {
/// private field
impl: struct {
/// @bitCast from/to `Status`
status: std.atomic.Atomic(u32) = std.atomic.Atomic(u32).init(@bitCast(Status{})),
status: std.atomic.Value(u32) = std.atomic.Value(u32).init(@bitCast(Status{})),
/// TODO can we avoid storing one allocator per Handle?
allocator: std.mem.Allocator,

Expand Down
6 changes: 3 additions & 3 deletions src/analyser/InternPool.zig
Original file line number Diff line number Diff line change
Expand Up @@ -1703,7 +1703,7 @@ fn deepEql(a: anytype, b: @TypeOf(a)) bool {

switch (@typeInfo(T)) {
.Struct => |info| {
if (info.layout == .Packed and comptime std.meta.trait.hasUniqueRepresentation(T)) {
if (info.layout == .Packed and comptime std.meta.hasUniqueRepresentation(T)) {
return std.mem.eql(u8, std.mem.asBytes(&a), std.mem.asBytes(&b));
}
inline for (info.fields) |field_info| {
Expand Down Expand Up @@ -1757,7 +1757,7 @@ fn deepHash(hasher: anytype, key: anytype) void {

switch (@typeInfo(T)) {
.Int => {
if (comptime std.meta.trait.hasUniqueRepresentation(Tuple)) {
if (comptime std.meta.hasUniqueRepresentation(Tuple)) {
hasher.update(std.mem.asBytes(&key));
} else {
const byte_size = comptime std.math.divCeil(comptime_int, @bitSizeOf(T), 8) catch unreachable;
Expand Down Expand Up @@ -1794,7 +1794,7 @@ fn deepHash(hasher: anytype, key: anytype) void {
=> @compileError("Unable to hash pointer " ++ @typeName(T)),
},
.Struct => |info| {
if (info.layout == .Packed and comptime std.meta.trait.hasUniqueRepresentation(T)) {
if (info.layout == .Packed and comptime std.meta.hasUniqueRepresentation(T)) {
hasher.update(std.mem.asBytes(&key));
} else {
inline for (info.fields) |field| {
Expand Down
4 changes: 2 additions & 2 deletions src/binned_allocator.zig
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,9 @@ pub fn BinnedAllocator(comptime config: Config) type {

const Counter = if (config.thread_safe)
struct {
count: std.atomic.Atomic(usize),
count: std.atomic.Value(usize),
fn init() @This() {
return .{ .count = std.atomic.Atomic(usize).init(0) };
return .{ .count = std.atomic.Value(usize).init(0) };
}
fn load(self: *const @This()) usize {
return self.count.load(.Acquire);
Expand Down
2 changes: 1 addition & 1 deletion src/features/completions.zig
Original file line number Diff line number Diff line change
Expand Up @@ -843,7 +843,7 @@ fn completeFileSystemStringLiteral(
if (!std.fs.path.isAbsolute(path)) continue;
const dir_path = if (std.fs.path.isAbsolute(completing)) path else try std.fs.path.join(arena, &.{ path, completing });

var iterable_dir = std.fs.openIterableDirAbsolute(dir_path, .{}) catch continue;
var iterable_dir = std.fs.openDirAbsolute(dir_path, .{ .iterate = true }) catch continue;
defer iterable_dir.close();
var it = iterable_dir.iterateAssumeFirstIteration();

Expand Down

0 comments on commit a0affc7

Please sign in to comment.