diff --git a/build.zig.zon b/build.zig.zon index f36694d20..1be8c6410 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -11,24 +11,20 @@ // ``` // If you do not use Nix, a ZLS maintainer can take care of this. .minimum_zig_version = "0.16.0-dev.2736+3b515fbed", + // Must be kept in sync with the `deps.nix` for the Nix flake. // If you do not use Nix, a ZLS maintainer can take care of this. - // Whenever the dependencies are updated, run the following command: - // ```bash - // nix run github:nix-community/zon2nix#default_0_14 > deps.nix - // ``` - // The `deps.nix` should also be updated to not fetch `tracy`. .dependencies = .{ .known_folders = .{ - .url = "https://github.com/ziglibs/known-folders/archive/71f0a3d660401ee461cc42ae1f2360f4b83084d3.tar.gz", - .hash = "known_folders-0.0.0-Fy-PJjrKAAAY9ALC7ALIxFsmKFP314HJw6v3NLSS3NDB", + .url = "https://github.com/ziglibs/known-folders/archive/175f5596b3d2ee3c658282bb07885580895a0e73.tar.gz", + .hash = "known_folders-0.0.0-Fy-PJk7KAAC41mQXzmFyGa0Q7tvmQjatENkREa6Gc4zu", }, .diffz = .{ - .url = "https://github.com/ziglibs/diffz/archive/aa11caef328a3f20f2493f8fd676a1dfa7819246.tar.gz", - .hash = "diffz-0.0.1-G2tlIYrNAQAQx3cuIp7EVs0xvxbv9DCPf4YuHmvubsrZ", + .url = "https://github.com/ziglibs/diffz/archive/d93d5737d2c19a2fb279c8dcaa80a4ce35529a3b.tar.gz", + .hash = "diffz-0.0.1-G2tlIXvNAQCPPTvl-leqv4d5nfEdwLw2lfE11P7EGKhy", }, .lsp_kit = .{ - .url = "git+https://github.com/zigtools/lsp-kit.git#98d6bed6e42a0866e1e2ba0867673d9f57ca6687", - .hash = "lsp_kit-0.1.0-bi_PLwozDAApVpvVJHz80NPklig5biWlZCkyxjFbOtiD", + .url = "https://github.com//zigtools/lsp-kit/archive/ec325a3c33d1da7708cf513355208f74d9560580.tar.gz", + .hash = "lsp_kit-0.1.0-bi_PL_kyDACVTEhLaMq2-PJx0MocqRyjXDAN0ybMUyQQ", }, .tracy = .{ .url = "https://github.com/wolfpld/tracy/archive/refs/tags/v0.13.1.tar.gz", diff --git a/deps.nix b/deps.nix index 8c0fa8853..067e12bb7 100644 --- a/deps.nix +++ b/deps.nix @@ -1,27 +1,29 @@ -# generated by zon2nix (https://github.com/nix-community/zon2nix) - -{ linkFarm, fetchzip, fetchgit, emptyDirectory }: - +{ + linkFarm, + fetchzip, + fetchgit, + emptyDirectory, +}: linkFarm "zig-packages" [ { - name = "diffz-0.0.1-G2tlIYrNAQAQx3cuIp7EVs0xvxbv9DCPf4YuHmvubsrZ"; + name = "known_folders-0.0.0-Fy-PJk7KAAC41mQXzmFyGa0Q7tvmQjatENkREa6Gc4zu"; path = fetchzip { - url = "https://github.com/ziglibs/diffz/archive/aa11caef328a3f20f2493f8fd676a1dfa7819246.tar.gz"; - hash = "sha256-bdL+xLnYVzYS6T3zsw7xfLKTUCUFI0pIpQaOxV6oTis="; + url = "https://github.com/ziglibs/known-folders/archive/4575ac4088eb7d0c8421d5b3d642f19de392d898.tar.gz"; + hash = "sha256-YE4KRNvrqzMtB7sSPnnbhwCokfNP7RqNtO1QVgwbiBc="; }; } { - name = "known_folders-0.0.0-Fy-PJjrKAAAY9ALC7ALIxFsmKFP314HJw6v3NLSS3NDB"; + name = "diffz-0.0.1-G2tlIXvNAQCPPTvl-leqv4d5nfEdwLw2lfE11P7EGKhy"; path = fetchzip { - url = "https://github.com/ziglibs/known-folders/archive/71f0a3d660401ee461cc42ae1f2360f4b83084d3.tar.gz"; - hash = "sha256-oBLYbnIjOIRL1NWYANJZcT4vfUaWy2vDgzxnf8zMSPQ="; + url = "https://github.com/ziglibs/diffz/archive/d93d5737d2c19a2fb279c8dcaa80a4ce35529a3b.tar.gz"; + hash = "sha256-1IDqdr0+74IlH76eovC6m5Ww6bNMAAyHFt1ukat/UXk="; }; } { - name = "lsp_kit-0.1.0-bi_PLwozDAApVpvVJHz80NPklig5biWlZCkyxjFbOtiD"; + name = "lsp_kit-0.1.0-bi_PL_kyDACVTEhLaMq2-PJx0MocqRyjXDAN0ybMUyQQ"; path = fetchzip { - url = "https://github.com/zigtools/lsp-kit/archive/98d6bed6e42a0866e1e2ba0867673d9f57ca6687.tar.gz"; - hash = "sha256-/p/AknpFGicfOhpsvyqCNHxeVNVBoiXWh6ctKTwStCM="; + url = "https://github.com/zigtools/lsp-kit/archive/ec325a3c33d1da7708cf513355208f74d9560580.tar.gz"; + hash = "sha256-60F2BOCrl3CreQFmpH3HAz6zzxd3VgJ3iSEkP39gtgQ="; }; } # workaround: https://codeberg.org/ziglang/zig/issues/31162 diff --git a/src/DiagnosticsCollection.zig b/src/DiagnosticsCollection.zig index 09197d0d9..442f7806f 100644 --- a/src/DiagnosticsCollection.zig +++ b/src/DiagnosticsCollection.zig @@ -253,11 +253,11 @@ fn collectUrisFromErrorBundle( } fn pathToUri(allocator: std.mem.Allocator, base_path: ?[]const u8, src_path: []const u8) error{OutOfMemory}!?Uri { - if (std.fs.path.isAbsolute(src_path)) { + if (std.Io.Dir.path.isAbsolute(src_path)) { return try .fromPath(allocator, src_path); } const base = base_path orelse return null; - const absolute_src_path = try std.fs.path.join(allocator, &.{ base, src_path }); + const absolute_src_path = try std.Io.Dir.path.join(allocator, &.{ base, src_path }); defer allocator.free(absolute_src_path); return try .fromPath(allocator, absolute_src_path); diff --git a/src/DocumentStore.zig b/src/DocumentStore.zig index 89ef1e20d..6affb84c4 100644 --- a/src/DocumentStore.zig +++ b/src/DocumentStore.zig @@ -414,7 +414,7 @@ pub const Handle = struct { const tracy_zone = tracy.traceNamed(@src(), "Handle.refresh"); defer tracy_zone.end(); - const mode: Ast.Mode = if (std.mem.eql(u8, std.fs.path.extension(handle.uri.raw), ".zon")) .zon else .zig; + const mode: Ast.Mode = if (std.mem.eql(u8, std.Io.Dir.path.extension(handle.uri.raw), ".zon")) .zon else .zig; var new_tree = try parseTree(allocator, text, mode); errdefer new_tree.deinit(allocator); @@ -847,7 +847,7 @@ pub fn openLspSyncedDocument(self: *DocumentStore, uri: Uri, text: []const u8) e } } - const duped_text = try self.allocator.dupeZ(u8, text); + const duped_text = try self.allocator.dupeSentinel(u8, text, 0); _ = self.createAndStoreDocument( uri, .{ .text = duped_text }, @@ -1013,11 +1013,11 @@ pub fn loadDirectoryRecursive(store: *DocumentStore, directory_uri: Uri) LoadDir } continue; } - if (!std.mem.eql(u8, std.fs.path.extension(entry.basename), ".zig")) continue; + if (!std.mem.eql(u8, std.Io.Dir.path.extension(entry.basename), ".zig")) continue; file_count += 1; - const path = try std.fs.path.join(store.allocator, &.{ workspace_path, entry.path }); + const path = try std.Io.Dir.path.join(store.allocator, &.{ workspace_path, entry.path }); defer store.allocator.free(path); const uri: Uri = try .fromPath(store.allocator, path); @@ -1046,7 +1046,7 @@ pub fn loadTrigramStores( while (it.next()) |handle| { const uri = handle.uri.toStdUri(); - var component_it = std.fs.path.componentIterator(uri.path.percent_encoded); + var component_it = std.Io.Dir.path.componentIterator(uri.path.percent_encoded); const skip = while (component_it.next()) |component| { // Keep in sync with `loadDirectoryRecursive` if (std.mem.startsWith(u8, component.name, ".")) break true; @@ -1305,7 +1305,7 @@ fn loadBuildAssociatedConfiguration(io: std.Io, allocator: std.mem.Allocator, bu const build_file_path = try build_file.uri.toFsPath(allocator); defer allocator.free(build_file_path); - const config_file_path = try std.fs.path.resolve(allocator, &.{ build_file_path, "..", "zls.build.json" }); + const config_file_path = try std.Io.Dir.path.resolve(allocator, &.{ build_file_path, "..", "zls.build.json" }); defer allocator.free(config_file_path); const file_buf = try std.Io.Dir.cwd().readFileAlloc( @@ -1373,7 +1373,7 @@ fn loadBuildConfiguration(self: *DocumentStore, build_file_uri: Uri, build_file_ const build_file_path = try build_file_uri.toFsPath(self.allocator); defer self.allocator.free(build_file_path); - const cwd = std.fs.path.dirname(build_file_path).?; + const cwd = std.Io.Dir.path.dirname(build_file_path).?; const args = try self.prepareBuildRunnerArgs(build_file_uri); defer { @@ -1489,16 +1489,16 @@ fn collectPotentialBuildFiles(self: *DocumentStore, uri: Uri) error{ Canceled, O // https://github.com/ziglang/zig/issues/15607 const root_end_index: usize = root_end_index: { if (builtin.target.os.tag != .windows) break :root_end_index 0; - const component_iterator = std.fs.path.componentIterator(path); + const component_iterator = std.Io.Dir.path.componentIterator(path); break :root_end_index component_iterator.root_end_index; }; var current_path: []const u8 = path; - while (std.fs.path.dirname(current_path)) |potential_root_path| : (current_path = potential_root_path) { + while (std.Io.Dir.path.dirname(current_path)) |potential_root_path| : (current_path = potential_root_path) { if (potential_root_path.len < root_end_index) break; if (!try buildDotZigExists(self.io, potential_root_path)) continue; - const build_path = try std.fs.path.join(self.allocator, &.{ potential_root_path, "build.zig" }); + const build_path = try std.Io.Dir.path.join(self.allocator, &.{ potential_root_path, "build.zig" }); defer self.allocator.free(build_path); try potential_build_files.ensureUnusedCapacity(self.allocator, 1); @@ -1534,7 +1534,7 @@ fn createBuildFile(self: *DocumentStore, uri: Uri) error{ Canceled, OutOfMemory if (cfg.value.relative_builtin_path) |relative_builtin_path| blk: { const build_file_path = build_file.uri.toFsPath(self.allocator) catch break :blk; - const absolute_builtin_path = try std.fs.path.resolve(self.allocator, &.{ build_file_path, "..", relative_builtin_path }); + const absolute_builtin_path = try std.Io.Dir.path.resolve(self.allocator, &.{ build_file_path, "..", relative_builtin_path }); defer self.allocator.free(absolute_builtin_path); build_file.builtin_uri = try .fromPath(self.allocator, absolute_builtin_path); } @@ -1731,15 +1731,15 @@ pub fn collectIncludeDirs( try include_dirs.ensureUnusedCapacity(allocator, module.include_dirs.len); for (module.include_dirs) |include_path| { - const absolute_path = if (std.fs.path.isAbsolute(include_path)) + const absolute_path = if (std.Io.Dir.path.isAbsolute(include_path)) try allocator.dupe(u8, include_path) else blk: { const build_file_path = resolved.build_file.uri.toFsPath(allocator) catch |err| switch (err) { error.OutOfMemory => return error.OutOfMemory, error.UnsupportedScheme => continue, }; - const build_file_dirname = std.fs.path.dirname(build_file_path) orelse continue; - break :blk try std.fs.path.join(allocator, &.{ build_file_dirname, include_path }); + const build_file_dirname = std.Io.Dir.path.dirname(build_file_path) orelse continue; + break :blk try std.Io.Dir.path.join(allocator, &.{ build_file_dirname, include_path }); }; include_dirs.appendAssumeCapacity(absolute_path); diff --git a/src/Server.zig b/src/Server.zig index a12378b75..3bdb365fc 100644 --- a/src/Server.zig +++ b/src/Server.zig @@ -739,14 +739,14 @@ fn handleConfiguration(server: *Server, json: std.json.Value) error{ Canceled, O const field: *?[]const u8 = &@field(new_config, file_config.name); if (field.*) |maybe_relative| resolve: { if (maybe_relative.len == 0) break :resolve; - if (std.fs.path.isAbsolute(maybe_relative)) break :resolve; + if (std.Io.Dir.path.isAbsolute(maybe_relative)) break :resolve; const root_dir = maybe_root_dir orelse { log.err("relative path only supported for {s} with exactly one workspace", .{runtime_known_config_name}); break; }; - const absolute = try std.fs.path.resolve(arena, &.{ + const absolute = try std.Io.Dir.path.resolve(arena, &.{ root_dir, maybe_relative, }); @@ -902,7 +902,7 @@ fn didChangeWatchedFilesHandler(server: *Server, arena: std.mem.Allocator, notif error.OutOfMemory => return error.OutOfMemory, else => return error.InvalidParams, }; - const file_extension = std.fs.path.extension(uri.raw); + const file_extension = std.Io.Dir.path.extension(uri.raw); if (!std.mem.eql(u8, file_extension, ".zig") and !std.mem.eql(u8, file_extension, ".zon")) continue; switch (change.type) { diff --git a/src/Uri.zig b/src/Uri.zig index f8f3c23c9..1cd151e6d 100644 --- a/src/Uri.zig +++ b/src/Uri.zig @@ -198,8 +198,8 @@ fn fromPathWithOs( buf.appendSliceAssumeCapacity("file:"); if (is_windows and path.len >= 2 and - std.fs.path.PathType.isSep(.windows, u8, path[0]) and - std.fs.path.PathType.isSep(.windows, u8, path[1])) + std.Io.Dir.path.PathType.isSep(.windows, u8, path[0]) and + std.Io.Dir.path.PathType.isSep(.windows, u8, path[1])) { // UNC path } else if (!std.mem.startsWith(u8, path, "/")) { @@ -449,7 +449,7 @@ pub fn resolveImport( std.Uri.Component.percentEncode(&aw.writer, sub_path, isPathChar) catch unreachable; const percent_encoded_path = parsed_uri.path.percent_encoded; - const joined_path = try std.fs.path.resolvePosix(allocator, &.{ percent_encoded_path, "..", aw.written() }); + const joined_path = try std.Io.Dir.path.resolvePosix(allocator, &.{ percent_encoded_path, "..", aw.written() }); defer allocator.free(joined_path); var buffer = aw.toArrayList(); diff --git a/src/analyser/InternPool.zig b/src/analyser/InternPool.zig index 0ddc0c837..3c32988f1 100644 --- a/src/analyser/InternPool.zig +++ b/src/analyser/InternPool.zig @@ -426,7 +426,7 @@ pub const Key = union(enum) { => |a_data, t| { const b_data = @field(b, @tagName(t)); - const Int = std.meta.Int(.unsigned, @bitSizeOf(@TypeOf(a_data))); + const Int = @Int(.unsigned, @bitSizeOf(@TypeOf(a_data))); return @as(Int, @bitCast(a_data)) == @as(Int, @bitCast(b_data)); }, diff --git a/src/analyser/string_pool.zig b/src/analyser/string_pool.zig index 2fe81c82b..1ba65449d 100644 --- a/src/analyser/string_pool.zig +++ b/src/analyser/string_pool.zig @@ -127,7 +127,7 @@ pub fn StringPool(comptime config: Config) type { defer pool.mutex.unlock(io); const string_bytes: [*:0]u8 = @ptrCast(pool.bytes.items.ptr); const start = @intFromEnum(index); - return try allocator.dupeZ(u8, std.mem.sliceTo(string_bytes + start, 0)); + return try allocator.dupeSentinel(u8, std.mem.sliceTo(string_bytes + start, 0), 0); } /// storage a slice that points into the internal storage of the `StringPool`. diff --git a/src/analysis.zig b/src/analysis.zig index 45919db68..2cd79250c 100644 --- a/src/analysis.zig +++ b/src/analysis.zig @@ -1729,7 +1729,7 @@ fn resolveCallsiteReferences(analyser: *Analyser, decl_handle: DeclWithHandle) E }; const tree = &decl_handle.handle.tree; - const is_cimport = std.mem.eql(u8, std.fs.path.basename(decl_handle.handle.uri.raw), "cimport.zig"); + const is_cimport = std.mem.eql(u8, std.Io.Dir.path.basename(decl_handle.handle.uri.raw), "cimport.zig"); if (is_cimport or !analyser.collect_callsite_references) return null; @@ -4632,7 +4632,7 @@ pub const Type = struct { error.OutOfMemory => return error.OutOfMemory, error.UnsupportedScheme => handle.uri.raw, }; - const str = std.fs.path.stem(path); + const str = std.Io.Dir.path.stem(path); try writer.writeAll(str); if (referenced) |r| try r.put(analyser.arena, .of(str, handle, tree.firstToken(node)), {}); }, @@ -4954,7 +4954,7 @@ pub fn getFieldAccessType( source_index: usize, loc: offsets.Loc, ) Error!?Type { - const held_range = try analyser.arena.dupeZ(u8, offsets.locToSlice(handle.tree.source, loc)); + const held_range = try analyser.arena.dupeSentinel(u8, offsets.locToSlice(handle.tree.source, loc), 0); var tokenizer: std.zig.Tokenizer = .init(held_range); var current_type: ?Type = null; diff --git a/src/build_runner/build_runner.zig b/src/build_runner/build_runner.zig index ebe21eff6..587098f40 100644 --- a/src/build_runner/build_runner.zig +++ b/src/build_runner/build_runner.zig @@ -148,7 +148,7 @@ pub fn main(init: process.Init.Minimal) !void { const option_contents = arg[2..]; if (option_contents.len == 0) fatalWithHint("expected option name after '-D'", .{}); - if (mem.indexOfScalar(u8, option_contents, '=')) |name_end| { + if (mem.findScalar(u8, option_contents, '=')) |name_end| { const option_name = option_contents[0..name_end]; const option_value = option_contents[name_end + 1 ..]; if (try builder.addUserInputOption(option_name, option_value)) @@ -369,7 +369,7 @@ pub fn main(init: process.Init.Minimal) !void { try buffer.appendSlice(arena, k); try buffer.append(arena, '\n'); } - const s = std.fs.path.sep_str; + const s = std.Io.Dir.path.sep_str; const tmp_sub_path = "tmp" ++ s ++ (output_tmp_nonce orelse fatal("missing -Z arg", .{})); local_cache_directory.handle.writeFile(io, .{ .sub_path = tmp_sub_path, @@ -572,7 +572,7 @@ fn resolveStepNames( step_names: []const []const u8, check_step_only: bool, ) !std.AutoArrayHashMapUnmanaged(*Step, void) { - var starting_steps: std.AutoArrayHashMapUnmanaged(*Step, void) = .{}; + var starting_steps: std.AutoArrayHashMapUnmanaged(*Step, void) = .empty; errdefer starting_steps.deinit(gpa); if (step_names.len == 0) { @@ -1064,7 +1064,7 @@ fn extractBuildInformation( if (other.generated_h) |header| { try include_dirs.put( allocator, - std.fs.path.dirname(header.getPath()).?, + std.Io.Dir.path.dirname(header.getPath()).?, {}, ); } @@ -1091,7 +1091,7 @@ fn extractBuildInformation( const cwd = module.owner.graph.cache.cwd; - const root_source_file_path = try std.fs.path.resolve(allocator, &.{ cwd, root_source_file.getPath2(module.owner, null) }); + const root_source_file_path = try std.Io.Dir.path.resolve(allocator, &.{ cwd, root_source_file.getPath2(module.owner, null) }); // All modules with the same root source file are merged. This limitation may be lifted in the future. const gop = try modules.getOrPutValue(allocator, root_source_file_path, .{ @@ -1105,7 +1105,7 @@ fn extractBuildInformation( const gop_import = try gop.value_ptr.import_table.map.getOrPut(allocator, name); // This does not account for the possibility of collisions (i.e. modules with same root source file import different modules under the same name). if (!gop_import.found_existing) { - gop_import.value_ptr.* = try std.fs.path.resolve(allocator, &.{ cwd, import_root_source_file.getPath2(import.owner, null) }); + gop_import.value_ptr.* = try std.Io.Dir.path.resolve(allocator, &.{ cwd, import_root_source_file.getPath2(import.owner, null) }); } } gop.value_ptr.c_macros = try std.mem.concat(allocator, []const u8, &.{ gop.value_ptr.c_macros, c_macros.keys() }); @@ -1221,7 +1221,7 @@ fn extractBuildInformation( for (all_steps.keys()) |step| { const compile = step.cast(Step.Compile) orelse continue; const root_source_file = compile.root_module.root_source_file orelse continue; - const root_source_file_path = try std.fs.path.resolve(arena, &.{ b.graph.cache.cwd, root_source_file.getPath2(compile.root_module.owner, null) }); + const root_source_file_path = try std.Io.Dir.path.resolve(arena, &.{ b.graph.cache.cwd, root_source_file.getPath2(compile.root_module.owner, null) }); try compilations.append(arena, .{ .root_module = root_source_file_path, }); @@ -1252,7 +1252,7 @@ fn extractBuildInformation( try root_dependencies.put( arena, root_dep[0], - try std.fs.path.join(arena, &.{ package_info.build_root, "build.zig" }), + try std.Io.Dir.path.join(arena, &.{ package_info.build_root, "build.zig" }), ); } } @@ -1353,7 +1353,7 @@ const copied_from_zig = struct { // Now try appending ".0". for (pkgs) |pkg| { - if (std.ascii.indexOfIgnoreCase(pkg.name, lib_name)) |pos| { + if (std.ascii.findIgnoreCase(pkg.name, lib_name)) |pos| { if (pos != 0) continue; if (mem.eql(u8, pkg.name[lib_name.len..], ".0")) { break :match pkg.name; diff --git a/src/build_runner/shared.zig b/src/build_runner/shared.zig index 3ed7de68e..7047f5def 100644 --- a/src/build_runner/shared.zig +++ b/src/build_runner/shared.zig @@ -131,7 +131,12 @@ pub const BuildOnSaveSupport = union(enum) { /// Parses a Linux Kernel Version. The result will ignore pre-release and build metadata. fn parseUnameKernelVersion(kernel_version: []const u8) !std.SemanticVersion { - const extra_index = std.mem.indexOfAny(u8, kernel_version, "-+"); + const extra_index = for (kernel_version, 0..) |c, i| { + switch (c) { + '-', '+' => break i, + else => continue, + } + } else null; const required = kernel_version[0..(extra_index orelse kernel_version.len)]; var it = std.mem.splitScalar(u8, required, '.'); return .{ diff --git a/src/configuration.zig b/src/configuration.zig index 57781cf49..8e25b054f 100644 --- a/src/configuration.zig +++ b/src/configuration.zig @@ -195,7 +195,7 @@ pub const Manager = struct { const zig_exe = manager.zig_exe orelse break :blk; const zig_lib_dir = zig_exe.env.lib_dir orelse break :blk; - if (std.fs.path.isAbsolute(zig_lib_dir)) { + if (std.Io.Dir.path.isAbsolute(zig_lib_dir)) { config.zig_lib_path = try arena.dupe(u8, zig_lib_dir); } else { const cwd = std.process.currentPathAlloc(io, manager.allocator) catch |err| switch (err) { @@ -206,7 +206,7 @@ pub const Manager = struct { }, }; defer manager.allocator.free(cwd); - config.zig_lib_path = try std.fs.path.join(arena, &.{ cwd, zig_lib_dir }); + config.zig_lib_path = try std.Io.Dir.path.join(arena, &.{ cwd, zig_lib_dir }); } } @@ -278,7 +278,7 @@ pub const Manager = struct { const cache_path = try global_cache_dir.join(manager.allocator, &.{ "build_runner", &std.fmt.bytesToHex(build_runner_hash, .lower) }); defer manager.allocator.free(cache_path); - std.debug.assert(std.fs.path.isAbsolute(cache_path)); + std.debug.assert(std.Io.Dir.path.isAbsolute(cache_path)); var cache_dir = std.Io.Dir.cwd().createDirPathOpen(io, cache_path, .{}) catch |err| switch (err) { error.Canceled => return error.Canceled, else => { @@ -314,7 +314,7 @@ pub const Manager = struct { }, }; - config.build_runner_path = try std.fs.path.join(arena, &.{ cache_path, "build_runner.zig" }); + config.build_runner_path = try std.Io.Dir.path.join(arena, &.{ cache_path, "build_runner.zig" }); manager.build_runner_supported = .yes; } @@ -405,7 +405,7 @@ pub const Manager = struct { break :ok true; } - if (!std.fs.path.isAbsolute(path)) { + if (!std.Io.Dir.path.isAbsolute(path)) { try messages.ensureUnusedCapacity(allocator, 1); messages.appendAssumeCapacity(try std.fmt.allocPrint( allocator, @@ -643,7 +643,7 @@ pub fn getZigEnv( }, }; } else { - const source = try allocator.dupeZ(u8, zig_env_result.stdout); + const source = try allocator.dupeSentinel(u8, zig_env_result.stdout, 0); defer allocator.free(source); return std.zon.parse.fromSliceAlloc( @@ -729,8 +729,8 @@ pub fn findZig( var filename_buffer: std.ArrayList(u8) = .empty; defer filename_buffer.deinit(allocator); - var path_it = std.mem.tokenizeScalar(u8, env_path, std.fs.path.delimiter); - var ext_it = if (is_windows) std.mem.tokenizeScalar(u8, env_path_ext, std.fs.path.delimiter); + var path_it = std.mem.tokenizeScalar(u8, env_path, std.Io.Dir.path.delimiter); + var ext_it = if (is_windows) std.mem.tokenizeScalar(u8, env_path_ext, std.Io.Dir.path.delimiter); while (path_it.next()) |path| : (if (is_windows) ext_it.reset()) { var dir = std.Io.Dir.cwd().openDir(io, path, .{}) catch |err| switch (err) { @@ -760,17 +760,17 @@ pub fn findZig( error.Canceled => return error.Canceled, error.FileNotFound => continue, else => |e| { - log.warn("failed to access entry in PATH '{f}': {}", .{ std.fs.path.fmtJoin(&.{ path, filename }), e }); + log.warn("failed to access entry in PATH '{f}': {}", .{ std.Io.Dir.path.fmtJoin(&.{ path, filename }), e }); continue; }, }; if (stat.kind == .directory) { - log.warn("ignoring entry in PATH '{f}' because it is a directory", .{std.fs.path.fmtJoin(&.{ path, filename })}); + log.warn("ignoring entry in PATH '{f}' because it is a directory", .{std.Io.Dir.path.fmtJoin(&.{ path, filename })}); continue; } - return try std.fs.path.join(allocator, &.{ path, filename }); + return try std.Io.Dir.path.join(allocator, &.{ path, filename }); } } return null; diff --git a/src/features/completions.zig b/src/features/completions.zig index 71d83ce61..3cdb6c1f8 100644 --- a/src/features/completions.zig +++ b/src/features/completions.zig @@ -217,7 +217,7 @@ fn typeToCompletion(builder: *Builder, ty: Analyser.Type) Analyser.Error!void { fn declToCompletion(builder: *Builder, decl_handle: Analyser.DeclWithHandle) Analyser.Error!void { const name = decl_handle.handle.tree.tokenSlice(decl_handle.nameToken()); - const is_cimport = std.mem.eql(u8, std.fs.path.basename(decl_handle.handle.uri.raw), "cimport.zig"); + const is_cimport = std.mem.eql(u8, std.Io.Dir.path.basename(decl_handle.handle.uri.raw), "cimport.zig"); if (is_cimport) { if (std.mem.startsWith(u8, name, "_")) return; const exclusions: std.StaticStringMap(void) = .initComptime(.{ @@ -893,12 +893,12 @@ fn completeFileSystemStringLiteral(builder: *Builder, pos_context: Analyser.Posi const previous_separator_index: ?usize = blk: { var index: usize = builder.source_index; break :blk while (index > string_content_loc.start) : (index -= 1) { - if (std.fs.path.isSep(source[index - 1])) break index - 1; + if (std.Io.Dir.path.isSep(source[index - 1])) break index - 1; } else null; }; const next_separator_index: ?usize = for (builder.source_index..string_content_loc.end) |index| { - if (std.fs.path.isSep(source[index])) break index; + if (std.Io.Dir.path.isSep(source[index])) break index; } else null; const completing = offsets.locToSlice(source, .{ .start = string_content_loc.start, .end = previous_separator_index orelse string_content_loc.start }); @@ -984,7 +984,7 @@ fn completeFileSystemStringLiteral(builder: *Builder, pos_context: Analyser.Posi } var search_paths: std.ArrayList([]const u8) = .empty; - if (std.fs.path.isAbsolute(completing) and pos_context != .import_string_literal) { + if (std.Io.Dir.path.isAbsolute(completing) and pos_context != .import_string_literal) { try search_paths.append(builder.arena, completing); } else if (pos_context == .cinclude_string_literal) { if (!DocumentStore.supports_build_system) return; @@ -1000,12 +1000,12 @@ fn completeFileSystemStringLiteral(builder: *Builder, pos_context: Analyser.Posi error.OutOfMemory => return error.OutOfMemory, error.UnsupportedScheme => break :blk, }; - try search_paths.append(builder.arena, std.fs.path.dirname(document_path).?); + try search_paths.append(builder.arena, std.Io.Dir.path.dirname(document_path).?); } for (search_paths.items) |path| { - if (!std.fs.path.isAbsolute(path)) continue; - const dir_path = if (std.fs.path.isAbsolute(completing)) path else try std.fs.path.join(builder.arena, &.{ path, completing }); + if (!std.Io.Dir.path.isAbsolute(path)) continue; + const dir_path = if (std.Io.Dir.path.isAbsolute(completing)) path else try std.Io.Dir.path.join(builder.arena, &.{ path, completing }); var iterable_dir = std.Io.Dir.openDirAbsolute(io, dir_path, .{ .iterate = true }) catch |err| switch (err) { error.Canceled => return error.Canceled, @@ -1025,7 +1025,7 @@ fn completeFileSystemStringLiteral(builder: *Builder, pos_context: Analyser.Posi }; switch (entry.kind) { .file => if (expected_extension) |expected| { - const actual_extension = std.fs.path.extension(entry.name); + const actual_extension = std.Io.Dir.path.extension(entry.name); if (!std.mem.eql(u8, actual_extension, expected)) continue; }, .directory => {}, diff --git a/src/features/diagnostics.zig b/src/features/diagnostics.zig index 5b3088d51..0c7f2bb3c 100644 --- a/src/features/diagnostics.zig +++ b/src/features/diagnostics.zig @@ -422,7 +422,7 @@ pub fn getErrorBundleFromStderr( const maybe_source: ?[:0]const u8 = switch (path_resolution) { .single_source_file => |source| source, .dynamic => |dynamic| source: { - const file_path = try std.fs.path.resolve(allocator, &.{ dynamic.base_path, src_path }); + const file_path = try std.Io.Dir.path.resolve(allocator, &.{ dynamic.base_path, src_path }); defer allocator.free(file_path); const file_uri: Uri = try .fromPath(allocator, file_path); defer file_uri.deinit(allocator); diff --git a/src/features/goto.zig b/src/features/goto.zig index 04bb4c22a..953aa594f 100644 --- a/src/features/goto.zig +++ b/src/features/goto.zig @@ -256,14 +256,14 @@ fn gotoDefinitionString( .cinclude_string_literal => blk: { if (!DocumentStore.supports_build_system) return null; - if (std.fs.path.isAbsolute(import_str)) { + if (std.Io.Dir.path.isAbsolute(import_str)) { break :blk .{ .one = try .fromPath(arena, import_str) }; } var include_dirs: std.ArrayList([]const u8) = .empty; _ = try document_store.collectIncludeDirs(arena, handle, &include_dirs); for (include_dirs.items) |dir| { - const path = try std.fs.path.join(arena, &.{ dir, import_str }); + const path = try std.Io.Dir.path.join(arena, &.{ dir, import_str }); std.Io.Dir.accessAbsolute(io, path, .{}) catch |err| switch (err) { error.Canceled => return error.Canceled, else => {}, diff --git a/src/features/references.zig b/src/features/references.zig index 2a3e7c2b2..44542d5ab 100644 --- a/src/features/references.zig +++ b/src/features/references.zig @@ -757,7 +757,7 @@ pub fn referencesHandler(server: *Server, arena: std.mem.Allocator, request: Gen switch (request) { .rename => |rename| { const escaped_rename = try std.fmt.allocPrint(arena, "{f}", .{std.zig.fmtId(rename.newName)}); - var changes: std.StringArrayHashMapUnmanaged(std.ArrayList(types.TextEdit)) = .{}; + var changes: std.StringArrayHashMapUnmanaged(std.ArrayList(types.TextEdit)) = .empty; for (locations.items) |loc| { const gop = try changes.getOrPutValue(arena, loc.uri, .empty); diff --git a/src/main.zig b/src/main.zig index 30414c8f4..163227504 100644 --- a/src/main.zig +++ b/src/main.zig @@ -128,7 +128,7 @@ fn defaultLogFilePath( if (zig_builtin.target.os.tag == .wasi) return null; const cache_path = try known_folders.getPath(io, allocator, environ_map.*, .cache) orelse return null; defer allocator.free(cache_path); - return try std.fs.path.join(allocator, &.{ cache_path, "zls", "zls.log" }); + return try std.Io.Dir.path.join(allocator, &.{ cache_path, "zls", "zls.log" }); } fn createLogFile( @@ -143,7 +143,7 @@ fn createLogFile( try defaultLogFilePath(io, allocator, environ_map) orelse return null; errdefer allocator.free(log_file_path); - if (std.fs.path.dirname(log_file_path)) |dirname| { + if (std.Io.Dir.path.dirname(log_file_path)) |dirname| { std.Io.Dir.cwd().createDirPath(io, dirname) catch |err| switch (err) { error.Canceled => return error.Canceled, else => {}, @@ -197,7 +197,7 @@ fn @"zls env"( }; defer if (global_cache_dir) |path| allocator.free(path); - const zls_global_cache_dir = if (global_cache_dir) |cache_dir| try std.fs.path.join(allocator, &.{ cache_dir, "zls" }) else null; + const zls_global_cache_dir = if (global_cache_dir) |cache_dir| try std.Io.Dir.path.join(allocator, &.{ cache_dir, "zls" }) else null; defer if (zls_global_cache_dir) |path| allocator.free(path); const global_config_dir = known_folders.getPath(io, allocator, environ_map.*, .global_configuration) catch |err| switch (err) { @@ -354,7 +354,7 @@ fn loadConfigFromSystem(io: std.Io, allocator: std.mem.Allocator, environ_map: s const folder_path = try known_folders.getPath(io, allocator, environ_map, folder) orelse continue; defer allocator.free(folder_path); - const config_path = try std.fs.path.join(allocator, &.{ folder_path, "zls.json" }); + const config_path = try std.Io.Dir.path.join(allocator, &.{ folder_path, "zls.json" }); defer allocator.free(config_path); const result = try loadConfigFromFile(io, allocator, config_path); @@ -416,7 +416,7 @@ fn loadConfiguration( }; defer allocator.free(cache_dir_path); - config.global_cache_path = try std.fs.path.join(config_arena.allocator(), &.{ cache_dir_path, "zls" }); + config.global_cache_path = try std.Io.Dir.path.join(config_arena.allocator(), &.{ cache_dir_path, "zls" }); } try server.config_manager.setConfiguration2(.frontend, &config); diff --git a/src/tools/config_gen.zig b/src/tools/config_gen.zig index 8ecadd613..544c9dd56 100644 --- a/src/tools/config_gen.zig +++ b/src/tools/config_gen.zig @@ -913,7 +913,7 @@ fn generateVersionDataFile( defer allocator.free(signature1); const signature2 = try std.mem.replaceOwned(u8, allocator, signature1, "builtin.", ""); defer allocator.free(signature2); - const signature_with_sentinel = try allocator.dupeZ(u8, signature2); + const signature_with_sentinel = try allocator.dupeSentinel(u8, signature2, 0); defer allocator.free(signature_with_sentinel); const parameters, const return_type = try extractParametersAndReturnTypeFromSignature(allocator, signature_with_sentinel); diff --git a/src/translate_c.zig b/src/translate_c.zig index 9b2db39c9..a4f8fd783 100644 --- a/src/translate_c.zig +++ b/src/translate_c.zig @@ -123,8 +123,8 @@ pub fn translate( var random_bytes: [16]u8 = undefined; io.random(&random_bytes); - var sub_path: [std.fs.base64_encoder.calcSize(16)]u8 = undefined; - _ = std.fs.base64_encoder.encode(&sub_path, &random_bytes); + var sub_path: [std.base64.url_safe.Encoder.calcSize(16)]u8 = undefined; + _ = std.base64.url_safe.Encoder.encode(&sub_path, &random_bytes); var sub_dir = try global_cache_dir.handle.createDirPathOpen(io, &sub_path, .{}); defer sub_dir.close(io); @@ -144,7 +144,7 @@ pub fn translate( log.warn("failed to delete '{s}/{s}': {}", .{ global_cache_dir.path orelse ".", sub_path, err }); }; - const file_path = try std.fs.path.join(allocator, &.{ global_cache_dir.path orelse ".", &sub_path, "cimport.h" }); + const file_path = try std.Io.Dir.path.join(allocator, &.{ global_cache_dir.path orelse ".", &sub_path, "cimport.h" }); defer allocator.free(file_path); const base_args = &[_][]const u8{ diff --git a/tests/add_analysis_cases.zig b/tests/add_analysis_cases.zig index e215711cb..8d87481b3 100644 --- a/tests/add_analysis_cases.zig +++ b/tests/add_analysis_cases.zig @@ -37,7 +37,7 @@ pub fn addCases( std.debug.panic("failed to walk directory '{s}': {}", .{ cases_path_from_root, err }) orelse break; if (entry.kind != .file) continue; - if (!std.mem.eql(u8, std.fs.path.extension(entry.name), ".zig")) continue; + if (!std.mem.eql(u8, std.Io.Dir.path.extension(entry.name), ".zig")) continue; for (test_filters) |test_filter| { if (std.mem.find(u8, entry.name, test_filter) != null) break; diff --git a/tests/add_build_runner_cases.zig b/tests/add_build_runner_cases.zig index 4968af570..94a661774 100644 --- a/tests/add_build_runner_cases.zig +++ b/tests/add_build_runner_cases.zig @@ -34,14 +34,14 @@ pub fn addCases( std.debug.panic("failed to walk directory '{s}': {}", .{ cases_path_from_root, err }) orelse break; if (entry.kind != .file) continue; - if (!std.mem.eql(u8, std.fs.path.extension(entry.name), ".zig")) continue; + if (!std.mem.eql(u8, std.Io.Dir.path.extension(entry.name), ".zig")) continue; for (test_filters) |test_filter| { if (std.mem.find(u8, entry.name, test_filter) != null) break; } else if (test_filters.len > 0) continue; const build_file = cases_dir.path(b, entry.name); - const build_config_json_path = b.fmt("{s}/{s}.json", .{ cases_path_from_root, std.fs.path.stem(entry.name) }); + const build_config_json_path = b.fmt("{s}/{s}.json", .{ cases_path_from_root, std.Io.Dir.path.stem(entry.name) }); const expected_build_config_json = cases_dir.path(b, build_config_json_path); const build_cmd = std.Build.Step.Run.create(b, b.fmt("run build runner ({s})", .{entry.name})); diff --git a/tests/analysis_check.zig b/tests/analysis_check.zig index 6b345f0e3..7339e32f5 100644 --- a/tests/analysis_check.zig +++ b/tests/analysis_check.zig @@ -67,7 +67,7 @@ pub fn main(init: std.process.Init) Error!void { std.log.err("failed to get current working directory: {}", .{err}); std.process.exit(1); }; - const resolved_zig_lib_path = std.fs.path.resolve(arena, &.{ cwd, zig_lib_path }) catch |err| { + const resolved_zig_lib_path = std.Io.Dir.path.resolve(arena, &.{ cwd, zig_lib_path }) catch |err| { std.log.err("failed to resolve zig library directory '{s}/{s}': {}", .{ cwd, zig_lib_path, err }); std.process.exit(1); }; diff --git a/tests/build_runner_check.zig b/tests/build_runner_check.zig index b65eb9f13..96ee90a13 100644 --- a/tests/build_runner_check.zig +++ b/tests/build_runner_check.zig @@ -25,11 +25,11 @@ pub fn main(init: std.process.Init) !u8 { defer gpa.free(actual_unsanitized); std.debug.assert(std.mem.eql(u8, args[3], "--cache-dir")); - const local_cache_dir = try std.fs.path.resolve(gpa, &.{ cwd, args[4] }); + const local_cache_dir = try std.Io.Dir.path.resolve(gpa, &.{ cwd, args[4] }); defer gpa.free(local_cache_dir); std.debug.assert(std.mem.eql(u8, args[5], "--global-cache-dir")); - const global_cache_dir = try std.fs.path.resolve(gpa, &.{ cwd, args[6] }); + const global_cache_dir = try std.Io.Dir.path.resolve(gpa, &.{ cwd, args[6] }); defer gpa.free(global_cache_dir); const actual_sanitized = sanitized: { @@ -71,8 +71,8 @@ pub fn main(init: std.process.Init) !u8 { fn stripBasePath(base_dir: []const u8, path: []const u8) ?[]const u8 { if (!std.mem.startsWith(u8, path, base_dir)) return null; - if (!std.mem.startsWith(u8, path[base_dir.len..], std.fs.path.sep_str)) return null; - return path[base_dir.len + std.fs.path.sep_str.len ..]; + if (!std.mem.startsWith(u8, path[base_dir.len..], std.Io.Dir.path.sep_str)) return null; + return path[base_dir.len + std.Io.Dir.path.sep_str.len ..]; } fn sanitizePath( @@ -87,25 +87,25 @@ fn sanitizePath( break :new foo; } if (stripBasePath(local_cache_dir, path)) |to| { - var it = std.fs.path.componentIterator(to); + var it = std.Io.Dir.path.componentIterator(to); std.debug.assert(std.mem.eql(u8, it.next().?.name, "o")); std.debug.assert(it.next().?.name.len == std.Build.Cache.hex_digest_len); break :new try std.fmt.allocPrint(arena, ".zig-local-cache/{s}", .{to[it.end_index + 1 ..]}); } if (stripBasePath(global_cache_dir, path)) |to| { - var it = std.fs.path.componentIterator(to); + var it = std.Io.Dir.path.componentIterator(to); std.debug.assert(std.mem.eql(u8, it.next().?.name, "o")); std.debug.assert(it.next().?.name.len == std.Build.Cache.hex_digest_len); break :new try std.fmt.allocPrint(arena, ".zig-global-cache/{s}", .{to[it.end_index + 1 ..]}); } - std.debug.assert(!std.fs.path.isAbsolute(path)); // got an absolute path that is not in cwd or any cache dir + std.debug.assert(!std.Io.Dir.path.isAbsolute(path)); // got an absolute path that is not in cwd or any cache dir break :new path; }); // Convert windows style '\\' path separators to posix style '/'. - if (std.fs.path.sep == '\\') { + if (std.Io.Dir.path.sep == '\\') { for (new) |*c| { - if (c.* == std.fs.path.sep) c.* = '/'; + if (c.* == std.Io.Dir.path.sep) c.* = '/'; } } diff --git a/tests/context.zig b/tests/context.zig index 07586ed83..b3db24a05 100644 --- a/tests/context.zig +++ b/tests/context.zig @@ -34,9 +34,9 @@ pub const Context = struct { if (builtin.target.os.tag != .wasi) { const cwd = try std.process.currentPathAlloc(io, allocator); defer allocator.free(cwd); - config.zig_exe_path = try std.fs.path.resolve(allocator, &.{ cwd, test_options.zig_exe_path }); - config.zig_lib_path = try std.fs.path.resolve(allocator, &.{ cwd, test_options.zig_lib_path }); - config.global_cache_path = try std.fs.path.resolve(allocator, &.{ cwd, test_options.global_cache_path }); + config.zig_exe_path = try std.Io.Dir.path.resolve(allocator, &.{ cwd, test_options.zig_exe_path }); + config.zig_lib_path = try std.Io.Dir.path.resolve(allocator, &.{ cwd, test_options.zig_lib_path }); + config.global_cache_path = try std.Io.Dir.path.resolve(allocator, &.{ cwd, test_options.global_cache_path }); } const environ_map = try cached_config_arena.allocator().create(std.process.Environ.Map); diff --git a/tests/language_features/cimport.zig b/tests/language_features/cimport.zig index f1e80b6f6..bd9f0aaec 100644 --- a/tests/language_features/cimport.zig +++ b/tests/language_features/cimport.zig @@ -124,7 +124,7 @@ fn testTranslate(c_source: []const u8) !translate_c.Result { .success => |uri| { const path = try uri.toFsPath(allocator); defer allocator.free(path); - try std.testing.expect(std.fs.path.isAbsolute(path)); + try std.testing.expect(std.Io.Dir.path.isAbsolute(path)); try std.Io.Dir.accessAbsolute(io, path, .{}); }, .failure => |message| { diff --git a/tests/lifecycle.zig b/tests/lifecycle.zig index 18db471f6..e89c8ed8f 100644 --- a/tests/lifecycle.zig +++ b/tests/lifecycle.zig @@ -20,9 +20,9 @@ test "LSP lifecycle" { defer allocator.free(cwd); try config_manager.setConfiguration(.frontend, &.{ - .zig_exe_path = try std.fs.path.resolve(arena, &.{ cwd, test_options.zig_exe_path }), - .zig_lib_path = try std.fs.path.resolve(arena, &.{ cwd, test_options.zig_lib_path }), - .global_cache_path = try std.fs.path.resolve(arena, &.{ cwd, test_options.global_cache_path }), + .zig_exe_path = try std.Io.Dir.path.resolve(arena, &.{ cwd, test_options.zig_exe_path }), + .zig_lib_path = try std.Io.Dir.path.resolve(arena, &.{ cwd, test_options.zig_lib_path }), + .global_cache_path = try std.Io.Dir.path.resolve(arena, &.{ cwd, test_options.global_cache_path }), }); } diff --git a/tests/lsp_features/code_actions.zig b/tests/lsp_features/code_actions.zig index 0f804545d..0d8e58353 100644 --- a/tests/lsp_features/code_actions.zig +++ b/tests/lsp_features/code_actions.zig @@ -1036,7 +1036,7 @@ fn testDiagnostic( const actual = try zls.diff.applyTextEdits(allocator, source, text_edits.items, ctx.server.offset_encoding); defer allocator.free(actual); - try ctx.server.document_store.refreshLspSyncedDocument(uri, try allocator.dupeZ(u8, actual)); + try ctx.server.document_store.refreshLspSyncedDocument(uri, try allocator.dupeSentinel(u8, actual, 0)); try zls.testing.expectEqualStrings(after, handle.tree.source); } diff --git a/tests/utility/ast.zig b/tests/utility/ast.zig index 19e122490..c9bbacc9b 100644 --- a/tests/utility/ast.zig +++ b/tests/utility/ast.zig @@ -82,7 +82,7 @@ fn testNodesAtLoc(source: []const u8) !void { const inner_loc: offsets.Loc = .{ .start = locs[1].start, .end = locs[2].start }; const outer_loc: offsets.Loc = .{ .start = locs[0].start, .end = locs[3].end }; - const new_source = try allocator.dupeZ(u8, ccp.new_source); + const new_source = try allocator.dupeSentinel(u8, ccp.new_source, 0); defer allocator.free(new_source); var tree: std.zig.Ast = try .parse(allocator, new_source, .zig); diff --git a/tests/utility/position_context.zig b/tests/utility/position_context.zig index a55df31ab..0bc2eb753 100644 --- a/tests/utility/position_context.zig +++ b/tests/utility/position_context.zig @@ -728,7 +728,7 @@ fn testContext(source: []const u8, expected_tag: std.meta.Tag(Analyser.PositionC }; }; - const new_source = try allocator.dupeZ(u8, phr.new_source); + const new_source = try allocator.dupeSentinel(u8, phr.new_source, 0); defer allocator.free(new_source); var tree: std.zig.Ast = try .parse(allocator, new_source, .zig);