diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2025-12-14 23:35:33 -0800 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2025-12-23 22:15:09 -0800 |
| commit | 16bd2e137e56f842a9ff5e015425f9e08eeb97fd (patch) | |
| tree | 4a4b46fd3eeeb52fa964f8753515e8c0ca4a6781 /lib/std | |
| parent | 4458e423bf2d2cf485031d1f527e407bfc9113df (diff) | |
| download | zig-16bd2e137e56f842a9ff5e015425f9e08eeb97fd.tar.gz zig-16bd2e137e56f842a9ff5e015425f9e08eeb97fd.zip | |
compiler: fix most compilation errors from std.fs changes
Diffstat (limited to 'lib/std')
| -rw-r--r-- | lib/std/Build/Cache/Path.zig | 3 | ||||
| -rw-r--r-- | lib/std/Io/Dir.zig | 2 | ||||
| -rw-r--r-- | lib/std/crypto/Certificate/Bundle.zig | 3 | ||||
| -rw-r--r-- | lib/std/fs/test.zig | 2 | ||||
| -rw-r--r-- | lib/std/zig.zig | 2 | ||||
| -rw-r--r-- | lib/std/zig/ErrorBundle.zig | 4 | ||||
| -rw-r--r-- | lib/std/zig/LibCDirs.zig | 19 | ||||
| -rw-r--r-- | lib/std/zig/LibCInstallation.zig | 6 |
8 files changed, 23 insertions, 18 deletions
diff --git a/lib/std/Build/Cache/Path.zig b/lib/std/Build/Cache/Path.zig index 51f9e7aecd..3ef4dec658 100644 --- a/lib/std/Build/Cache/Path.zig +++ b/lib/std/Build/Cache/Path.zig @@ -106,6 +106,7 @@ pub fn statFile(p: Path, io: Io, sub_path: []const u8) !Io.Dir.Stat { pub fn atomicFile( p: Path, + io: Io, sub_path: []const u8, options: Io.Dir.AtomicFileOptions, buf: *[fs.max_path_bytes]u8, @@ -115,7 +116,7 @@ pub fn atomicFile( p.sub_path, sub_path, }) catch return error.NameTooLong; }; - return p.root_dir.handle.atomicFile(joined_path, options); + return p.root_dir.handle.atomicFile(io, joined_path, options); } pub fn access(p: Path, io: Io, sub_path: []const u8, flags: Io.Dir.AccessOptions) !void { diff --git a/lib/std/Io/Dir.zig b/lib/std/Io/Dir.zig index 5cd3b898d8..94c159d0bf 100644 --- a/lib/std/Io/Dir.zig +++ b/lib/std/Io/Dir.zig @@ -1645,7 +1645,7 @@ pub fn copyFile( .permissions = permissions, .write_buffer = &buffer, }); - defer atomic_file.deinit(io); + defer atomic_file.deinit(); _ = atomic_file.file_writer.interface.sendFileAll(&file_reader, .unlimited) catch |err| switch (err) { error.ReadFailed => return file_reader.err.?, diff --git a/lib/std/crypto/Certificate/Bundle.zig b/lib/std/crypto/Certificate/Bundle.zig index a4af82b2f2..385ef23c9c 100644 --- a/lib/std/crypto/Certificate/Bundle.zig +++ b/lib/std/crypto/Certificate/Bundle.zig @@ -202,7 +202,7 @@ pub const AddCertsFromDirError = AddCertsFromFilePathError; pub fn addCertsFromDir(cb: *Bundle, gpa: Allocator, io: Io, now: Io.Timestamp, iterable_dir: Io.Dir) AddCertsFromDirError!void { var it = iterable_dir.iterate(); - while (try it.next()) |entry| { + while (try it.next(io)) |entry| { switch (entry.kind) { .file, .sym_link => {}, else => continue, @@ -243,6 +243,7 @@ pub fn addCertsFromFilePath( pub const AddCertsFromFileError = Allocator.Error || Io.File.Reader.Error || + Io.File.Reader.SizeError || ParseCertError || std.base64.Error || error{ CertificateAuthorityBundleTooBig, MissingEndCertificateMarker, Streaming }; diff --git a/lib/std/fs/test.zig b/lib/std/fs/test.zig index fa3eaed3fa..53612e4f96 100644 --- a/lib/std/fs/test.zig +++ b/lib/std/fs/test.zig @@ -1598,7 +1598,7 @@ test "AtomicFile" { { var buffer: [100]u8 = undefined; - var af = try ctx.dir.atomicFile(test_out_file, .{ .write_buffer = &buffer }); + var af = try ctx.dir.atomicFile(io, test_out_file, .{ .write_buffer = &buffer }); defer af.deinit(); try af.file_writer.interface.writeAll(test_content); try af.finish(); diff --git a/lib/std/zig.zig b/lib/std/zig.zig index a094dee83f..6e89c75d91 100644 --- a/lib/std/zig.zig +++ b/lib/std/zig.zig @@ -648,7 +648,7 @@ pub fn printAstErrorsToStderr(gpa: Allocator, io: Io, tree: Ast, path: []const u var error_bundle = try wip_errors.toOwnedBundle(""); defer error_bundle.deinit(gpa); - error_bundle.renderToStderr(io, .{}, color); + return error_bundle.renderToStderr(io, .{}, color); } pub fn putAstErrorsIntoBundle( diff --git a/lib/std/zig/ErrorBundle.zig b/lib/std/zig/ErrorBundle.zig index 907256c2e4..556b1167a3 100644 --- a/lib/std/zig/ErrorBundle.zig +++ b/lib/std/zig/ErrorBundle.zig @@ -162,14 +162,14 @@ pub const RenderOptions = struct { include_log_text: bool = true, }; -pub const RenderToStderrError = Io.Cancelable || Io.File.Writer.Mode.SetColorError; +pub const RenderToStderrError = Io.Cancelable || Io.File.Writer.Error; pub fn renderToStderr(eb: ErrorBundle, io: Io, options: RenderOptions, color: std.zig.Color) RenderToStderrError!void { var buffer: [256]u8 = undefined; const stderr = try io.lockStderrWriter(&buffer); defer io.unlockStderrWriter(); renderToWriter(eb, options, &stderr.interface, color.getTtyConf(stderr.mode)) catch |err| switch (err) { - error.WriteFailed => return stderr.interface.err.?, + error.WriteFailed => return stderr.err.?, else => |e| return e, }; } diff --git a/lib/std/zig/LibCDirs.zig b/lib/std/zig/LibCDirs.zig index fa297cd53a..e05ccde589 100644 --- a/lib/std/zig/LibCDirs.zig +++ b/lib/std/zig/LibCDirs.zig @@ -1,3 +1,11 @@ +const LibCDirs = @This(); +const builtin = @import("builtin"); + +const std = @import("../std.zig"); +const Io = std.Io; +const LibCInstallation = std.zig.LibCInstallation; +const Allocator = std.mem.Allocator; + libc_include_dir_list: []const []const u8, libc_installation: ?*const LibCInstallation, libc_framework_dir_list: []const []const u8, @@ -14,6 +22,7 @@ pub const DarwinSdkLayout = enum { pub fn detect( arena: Allocator, + io: Io, zig_lib_dir: []const u8, target: *const std.Target, is_native_abi: bool, @@ -38,7 +47,7 @@ pub fn detect( // using the system libc installation. if (is_native_abi and !target.isMinGW()) { const libc = try arena.create(LibCInstallation); - libc.* = LibCInstallation.findNative(.{ .allocator = arena, .target = target }) catch |err| switch (err) { + libc.* = LibCInstallation.findNative(arena, io, .{ .target = target }) catch |err| switch (err) { error.CCompilerExitCode, error.CCompilerCrashed, error.CCompilerCannotFindHeaders, @@ -75,7 +84,7 @@ pub fn detect( if (use_system_abi) { const libc = try arena.create(LibCInstallation); - libc.* = try LibCInstallation.findNative(.{ .allocator = arena, .verbose = true, .target = target }); + libc.* = try LibCInstallation.findNative(arena, io, .{ .verbose = true, .target = target }); return detectFromInstallation(arena, target, libc); } @@ -265,9 +274,3 @@ fn libCGenericName(target: *const std.Target) [:0]const u8 { => unreachable, } } - -const LibCDirs = @This(); -const builtin = @import("builtin"); -const std = @import("../std.zig"); -const LibCInstallation = std.zig.LibCInstallation; -const Allocator = std.mem.Allocator; diff --git a/lib/std/zig/LibCInstallation.zig b/lib/std/zig/LibCInstallation.zig index 6051eecb94..c1fc8fccaa 100644 --- a/lib/std/zig/LibCInstallation.zig +++ b/lib/std/zig/LibCInstallation.zig @@ -204,7 +204,7 @@ pub fn findNative(gpa: Allocator, io: Io, args: FindNativeOptions) FindError!Lib try self.findNativeIncludeDirWindows(gpa, io, args, sdk); try self.findNativeCrtDirWindows(gpa, io, args.target, sdk); } else if (is_haiku) { - try self.findNativeIncludeDirPosix(args); + try self.findNativeIncludeDirPosix(gpa, io, args); try self.findNativeGccDirHaiku(gpa, io, args); self.crt_dir = try gpa.dupeZ(u8, "/system/develop/lib"); } else if (builtin.target.os.tag == .illumos) { @@ -213,7 +213,7 @@ pub fn findNative(gpa: Allocator, io: Io, args: FindNativeOptions) FindError!Lib self.sys_include_dir = try gpa.dupeZ(u8, "/usr/include"); self.crt_dir = try gpa.dupeZ(u8, "/usr/lib/64"); } else if (std.process.can_spawn) { - try self.findNativeIncludeDirPosix(args); + try self.findNativeIncludeDirPosix(gpa, io, args); switch (builtin.target.os.tag) { .freebsd, .netbsd, .openbsd, .dragonfly => self.crt_dir = try gpa.dupeZ(u8, "/usr/lib"), .linux => try self.findNativeCrtDirPosix(gpa, io, args), @@ -335,7 +335,7 @@ fn findNativeIncludeDirPosix(self: *LibCInstallation, gpa: Allocator, io: Io, ar defer search_dir.close(io); if (self.include_dir == null) { - if (search_dir.access(include_dir_example_file, .{})) |_| { + if (search_dir.access(io, include_dir_example_file, .{})) |_| { self.include_dir = try gpa.dupeZ(u8, search_path); } else |err| switch (err) { error.FileNotFound => {}, |
