Skip to content

Commit 5f3e4a7

Browse files
committed
dep-hash: fix file path in error messages
1 parent e2d6bcd commit 5f3e4a7

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

lib/compiler/dep-hash.zig

+4-10
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ fn loadManifest(
397397
color: std.zig.Color,
398398
required: bool,
399399
) !struct { std.zig.Manifest, std.zig.Ast } {
400-
var buf: [std.fs.max_path_bytes]u8 = undefined;
400+
var buf: [2 * std.fs.max_path_bytes]u8 = undefined;
401401
var fba: std.heap.FixedBufferAllocator = .init(&buf);
402402
const joined_path = root.join(fba.allocator(), std.zig.Manifest.basename) catch
403403
return error.NameTooLong;
@@ -412,18 +412,15 @@ fn loadManifest(
412412
if (!required) {
413413
if (err == error.FileNotFound) return error.FileNotFound;
414414
}
415-
fatal("unable to load package manifest '{s}': {s}", .{
416-
try root.joinString(allocator, joined_path.sub_path),
417-
@errorName(err),
418-
});
415+
fatal("unable to load package manifest '{}': {s}", .{ root, @errorName(err) });
419416
};
420417
errdefer allocator.free(manifest_bytes);
421418

422419
var ast = try std.zig.Ast.parse(allocator, manifest_bytes, .zon);
423420
errdefer ast.deinit(allocator);
424421

425422
if (ast.errors.len > 0) {
426-
const file_path = try root.joinString(allocator, joined_path.sub_path);
423+
const file_path = try root.toString(fba.allocator());
427424
try std.zig.printAstErrorsToStderr(allocator, ast, file_path, color);
428425
std.process.exit(1);
429426
}
@@ -440,10 +437,7 @@ fn loadManifest(
440437
try wip_errors.init(allocator);
441438
defer wip_errors.deinit();
442439

443-
const src_path = try wip_errors.addString(try root.joinString(
444-
allocator,
445-
joined_path.sub_path,
446-
));
440+
const src_path = try wip_errors.addString(try root.toString(fba.allocator()));
447441
try manifest.copyErrorsIntoBundle(ast, src_path, &wip_errors);
448442

449443
var eb = try wip_errors.toOwnedBundle("");

0 commit comments

Comments
 (0)