Disentangle from error.CurrentWorkingDirectoryUnlinked

This error is actually only ever directly returned from `std.posix.getcwd` (and only on POSIX systems, so never on Windows). Its inclusion in almost all of the error sets its currently found in is a leftover from when `std.fs.path.resolve` called `std.process.getCwdAlloc` (https://github.com/ziglang/zig/issues/13613).
This commit is contained in:
Ryan Liptak 2026-01-26 23:55:17 -08:00 committed by Ryan Liptak
parent 3729a53eec
commit 29b7214027
6 changed files with 5 additions and 12 deletions

View file

@ -521,6 +521,7 @@ pub fn getppid() pid_t {
pub const GetCwdError = error{
NameTooLong,
/// Not possible on Windows.
CurrentWorkingDirectoryUnlinked,
} || UnexpectedError;

View file

@ -73,7 +73,10 @@ pub fn getCwd(out_buffer: []u8) GetCwdError![]u8 {
}
// Same as GetCwdError, minus error.NameTooLong + Allocator.Error
pub const GetCwdAllocError = Allocator.Error || error{CurrentWorkingDirectoryUnlinked} || posix.UnexpectedError;
pub const GetCwdAllocError = Allocator.Error || error{
/// Not possible on Windows.
CurrentWorkingDirectoryUnlinked,
} || posix.UnexpectedError;
/// Caller must free the returned memory.
/// On Windows, the result is encoded as [WTF-8](https://wtf-8.codeberg.page/).
@ -342,8 +345,6 @@ pub const SpawnError = error{
/// Windows-only. `cwd` or `argv` was provided and it was invalid WTF-8.
/// https://wtf-8.codeberg.page/
InvalidWtf8,
/// Windows-only. `cwd` was provided, but the path did not exist when spawning the child process.
CurrentWorkingDirectoryUnlinked,
/// Windows-only. NUL (U+0000), LF (U+000A), CR (U+000D) are not allowed
/// within arguments when executing a `.bat`/`.cmd` script.
/// - NUL/LF signifiies end of arguments, so anything afterwards

View file

@ -504,7 +504,6 @@ pub fn resolveTargetQuery(io: Io, query: Target.Query) DetectError!Target {
if (builtin.os.tag == .linux and result.isBionicLibC() and query.os_tag == null and query.android_api_level == null) {
result.os.version_range.linux.android = detectAndroidApiLevel(io) catch |err| return switch (err) {
error.InvalidWtf8,
error.CurrentWorkingDirectoryUnlinked,
error.InvalidBatchScriptArg,
=> unreachable, // Windows-only
error.ApiLevelQueryFailed => |e| e,

View file

@ -1851,7 +1851,6 @@ fn addModuleTableToCacheHash(
) error{
OutOfMemory,
Unexpected,
CurrentWorkingDirectoryUnlinked,
}!void {
assert(zcu.module_roots.count() != 0); // module_roots is populated
@ -1919,7 +1918,6 @@ pub const CreateError = error{
OutOfMemory,
Canceled,
Unexpected,
CurrentWorkingDirectoryUnlinked,
/// An error has been stored to `diag`.
CreateFail,
};
@ -2906,7 +2904,6 @@ pub const UpdateError = error{
OutOfMemory,
Canceled,
Unexpected,
CurrentWorkingDirectoryUnlinked,
};
/// Detect changes to source files, perform semantic analysis, and update the output files.

View file

@ -13604,10 +13604,6 @@ fn zirEmbedFile(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A
error.ImportOutsideModulePath => {
return sema.fail(block, operand_src, "embed of file outside package path: '{s}'", .{name});
},
error.CurrentWorkingDirectoryUnlinked => {
// TODO: this should be some kind of retryable failure, in case the cwd is put back
return sema.fail(block, operand_src, "unable to resolve '{s}': working directory has been unlinked", .{name});
},
error.OutOfMemory => |e| return e,
error.Canceled => |e| return e,
};

View file

@ -2388,7 +2388,6 @@ pub fn embedFile(
OutOfMemory,
Canceled,
ImportOutsideModulePath,
CurrentWorkingDirectoryUnlinked,
}!Zcu.EmbedFile.Index {
const zcu = pt.zcu;
const gpa = zcu.gpa;