authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-06-27 17:28:59-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-06-27 17:30:29-07:00
log6d47b4f39e8cdd95ead71b1efdbf67a737174e97
tree4136cd37830bba4f946c8a121ba4e5ed2eba74ab
parent15a030ef3d2d68992835568f2fb9d5deab18f39f

Revert "Include package root dir in stage2 error messages"

This reverts commit 15a030ef3d2d68992835568f2fb9d5deab18f39f. ast-check started crashing after this commit. Needs more QA before merging.

2 files changed, 6 insertions(+), 10 deletions(-)

src/Compilation.zig+6-6
...@@ -403,10 +403,10 @@ pub const AllErrors = struct {...@@ -403,10 +403,10 @@ pub const AllErrors = struct {
403 const source = try module_note.src_loc.file_scope.getSource(module.gpa);403 const source = try module_note.src_loc.file_scope.getSource(module.gpa);
404 const byte_offset = try module_note.src_loc.byteOffset(module.gpa);404 const byte_offset = try module_note.src_loc.byteOffset(module.gpa);
405 const loc = std.zig.findLineColumn(source, byte_offset);405 const loc = std.zig.findLineColumn(source, byte_offset);
406 const file_path = try module_note.src_loc.file_scope.fullPath(&arena.allocator);406 const sub_file_path = module_note.src_loc.file_scope.sub_file_path;
407 note.* = .{407 note.* = .{
408 .src = .{408 .src = .{
409 .src_path = file_path,409 .src_path = try arena.allocator.dupe(u8, sub_file_path),
410 .msg = try arena.allocator.dupe(u8, module_note.msg),410 .msg = try arena.allocator.dupe(u8, module_note.msg),
411 .byte_offset = byte_offset,411 .byte_offset = byte_offset,
412 .line = @intCast(u32, loc.line),412 .line = @intCast(u32, loc.line),
...@@ -426,10 +426,10 @@ pub const AllErrors = struct {...@@ -426,10 +426,10 @@ pub const AllErrors = struct {
426 const source = try module_err_msg.src_loc.file_scope.getSource(module.gpa);426 const source = try module_err_msg.src_loc.file_scope.getSource(module.gpa);
427 const byte_offset = try module_err_msg.src_loc.byteOffset(module.gpa);427 const byte_offset = try module_err_msg.src_loc.byteOffset(module.gpa);
428 const loc = std.zig.findLineColumn(source, byte_offset);428 const loc = std.zig.findLineColumn(source, byte_offset);
429 const file_path = try module_err_msg.src_loc.file_scope.fullPath(&arena.allocator);429 const sub_file_path = module_err_msg.src_loc.file_scope.sub_file_path;
430 try errors.append(.{430 try errors.append(.{
431 .src = .{431 .src = .{
432 .src_path = file_path,432 .src_path = try arena.allocator.dupe(u8, sub_file_path),
433 .msg = try arena.allocator.dupe(u8, module_err_msg.msg),433 .msg = try arena.allocator.dupe(u8, module_err_msg.msg),
434 .byte_offset = byte_offset,434 .byte_offset = byte_offset,
435 .line = @intCast(u32, loc.line),435 .line = @intCast(u32, loc.line),
...@@ -480,7 +480,7 @@ pub const AllErrors = struct {...@@ -480,7 +480,7 @@ pub const AllErrors = struct {
480480
481 note.* = .{481 note.* = .{
482 .src = .{482 .src = .{
483 .src_path = try file.fullPath(arena),483 .src_path = try arena.dupe(u8, file.sub_file_path),
484 .msg = try arena.dupe(u8, msg),484 .msg = try arena.dupe(u8, msg),
485 .byte_offset = byte_offset,485 .byte_offset = byte_offset,
486 .line = @intCast(u32, loc.line),486 .line = @intCast(u32, loc.line),
...@@ -506,7 +506,7 @@ pub const AllErrors = struct {...@@ -506,7 +506,7 @@ pub const AllErrors = struct {
506506
507 try errors.append(.{507 try errors.append(.{
508 .src = .{508 .src = .{
509 .src_path = try file.fullPath(arena),509 .src_path = try arena.dupe(u8, file.sub_file_path),
510 .msg = try arena.dupe(u8, msg),510 .msg = try arena.dupe(u8, msg),
511 .byte_offset = byte_offset,511 .byte_offset = byte_offset,
512 .line = @intCast(u32, loc.line),512 .line = @intCast(u32, loc.line),
src/Module.zig-4
...@@ -1111,10 +1111,6 @@ pub const Scope = struct {...@@ -1111,10 +1111,6 @@ pub const Scope = struct {
1111 return buf.toOwnedSliceSentinel(0);1111 return buf.toOwnedSliceSentinel(0);
1112 }1112 }
11131113
1114 pub fn fullPath(file: File, ally: *Allocator) ![]u8 {
1115 return file.pkg.root_src_directory.join(ally, &[_][]const u8{file.sub_file_path});
1116 }
1117
1118 pub fn dumpSrc(file: *File, src: LazySrcLoc) void {1114 pub fn dumpSrc(file: *File, src: LazySrcLoc) void {
1119 const loc = std.zig.findLineColumn(file.source.bytes, src);1115 const loc = std.zig.findLineColumn(file.source.bytes, src);
1120 std.debug.print("{s}:{d}:{d}\n", .{ file.sub_file_path, loc.line + 1, loc.column + 1 });1116 std.debug.print("{s}:{d}:{d}\n", .{ file.sub_file_path, loc.line + 1, loc.column + 1 });