authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2026-09-03 15:04:36-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2026-09-04 17:42:21-07:00
log0342d5890d80f81178e2f725092b34157825f7a7
treec67119e81cad3fba43e24c49c5fab4933e5cd65b
parentfc1d90e2a1fdc92c020c3d1d6af6a3f768d8a9d2

std.Build.Cache: make IsDirectoryAmbiguous an assertion not error


1 files changed, 10 insertions(+), 18 deletions(-)

lib/std/Build/Cache.zig+10-18
......@@ -508,13 +508,6 @@ pub const Manifest = struct {
508508 metadata_only: bool = false,
509509 };
510510
511 pub const AddInputPathError = error{
512 /// The same file path has been added to the cache manifest both as a
513 /// directory and as a normal file, making the intended caching
514 /// behavior ambiguous.
515 IsDirectoryAmbiguous,
516 } || Allocator.Error;
517
518511 /// Add a file or directory path as a dependency of process being cached.
519512 /// When `hit` is called, the contents will be checked to ensure
520513 /// that it matches the contents from previous times.
......@@ -530,7 +523,7 @@ pub const Manifest = struct {
530523 ///
531524 /// See also:
532525 /// * `addPathPost`
533 pub fn addInputPath(m: *Manifest, path: Path, options: AddInputPathOptions) AddInputPathError!InputPath.Index {
526 pub fn addInputPath(m: *Manifest, path: Path, options: AddInputPathOptions) Allocator.Error!InputPath.Index {
534527 const gpa = m.cache.gpa;
535528 try m.files.ensureUnusedCapacity(gpa, 1);
536529 try m.input_paths.ensureUnusedCapacity(gpa, 1);
......@@ -573,8 +566,10 @@ pub const Manifest = struct {
573566 existing_header.inode = stat.inode;
574567 existing_header.mtime = stat.mtime;
575568 }
576 if (existing_header.flags.is_directory != options.is_directory)
577 return error.IsDirectoryAmbiguous;
569 // If it trips, the same file path has been added to the cache
570 // manifest both as a directory and as a normal file, making the
571 // intended caching behavior ambiguous.
572 assert(existing_header.flags.is_directory == options.is_directory);
578573 if (!options.metadata_only)
579574 existing_header.flags.metadata_only = false;
580575 } else {
......@@ -1078,12 +1073,7 @@ pub const Manifest = struct {
10781073 metadata_only: bool = false,
10791074 };
10801075
1081 pub const AddPathPostError = error{
1082 /// The same file path has been added to the cache manifest both as a
1083 /// directory and as a normal file, making the intended caching
1084 /// behavior ambiguous.
1085 IsDirectoryAmbiguous,
1086 } || Io.Cancelable || Allocator.Error;
1076 pub const AddPathPostError = Io.Cancelable || Allocator.Error;
10871077
10881078 /// Add a file as a dependency of process being cached, after cache miss
10891079 /// occurs.
......@@ -1126,8 +1116,10 @@ pub const Manifest = struct {
11261116 m.contents.shrinkRetainingCapacity(prev_contents_len);
11271117 const existing_off = gop.key_ptr.*;
11281118 const header = existing_off.get(m);
1129 if (header.flags.is_directory != is_directory)
1130 return error.IsDirectoryAmbiguous;
1119 // If it trips, the same file path has been added to the cache
1120 // manifest both as a directory and as a normal file, making the
1121 // intended caching behavior ambiguous.
1122 assert(header.flags.is_directory == is_directory);
11311123 if (!options.metadata_only)
11321124 header.flags.metadata_only = false;
11331125 break :h header;