mirror of
https://github.com/ziglang/zig.git
synced 2025-01-18 16:01:50 +00:00
Include package root dir in stage2 error messages
This commit is contained in:
parent
f398ac3ee4
commit
15a030ef3d
@ -403,10 +403,10 @@ pub const AllErrors = struct {
|
||||
const source = try module_note.src_loc.file_scope.getSource(module.gpa);
|
||||
const byte_offset = try module_note.src_loc.byteOffset(module.gpa);
|
||||
const loc = std.zig.findLineColumn(source, byte_offset);
|
||||
const sub_file_path = module_note.src_loc.file_scope.sub_file_path;
|
||||
const file_path = try module_note.src_loc.file_scope.fullPath(&arena.allocator);
|
||||
note.* = .{
|
||||
.src = .{
|
||||
.src_path = try arena.allocator.dupe(u8, sub_file_path),
|
||||
.src_path = file_path,
|
||||
.msg = try arena.allocator.dupe(u8, module_note.msg),
|
||||
.byte_offset = byte_offset,
|
||||
.line = @intCast(u32, loc.line),
|
||||
@ -426,10 +426,10 @@ pub const AllErrors = struct {
|
||||
const source = try module_err_msg.src_loc.file_scope.getSource(module.gpa);
|
||||
const byte_offset = try module_err_msg.src_loc.byteOffset(module.gpa);
|
||||
const loc = std.zig.findLineColumn(source, byte_offset);
|
||||
const sub_file_path = module_err_msg.src_loc.file_scope.sub_file_path;
|
||||
const file_path = try module_err_msg.src_loc.file_scope.fullPath(&arena.allocator);
|
||||
try errors.append(.{
|
||||
.src = .{
|
||||
.src_path = try arena.allocator.dupe(u8, sub_file_path),
|
||||
.src_path = file_path,
|
||||
.msg = try arena.allocator.dupe(u8, module_err_msg.msg),
|
||||
.byte_offset = byte_offset,
|
||||
.line = @intCast(u32, loc.line),
|
||||
@ -480,7 +480,7 @@ pub const AllErrors = struct {
|
||||
|
||||
note.* = .{
|
||||
.src = .{
|
||||
.src_path = try arena.dupe(u8, file.sub_file_path),
|
||||
.src_path = try file.fullPath(arena),
|
||||
.msg = try arena.dupe(u8, msg),
|
||||
.byte_offset = byte_offset,
|
||||
.line = @intCast(u32, loc.line),
|
||||
@ -506,7 +506,7 @@ pub const AllErrors = struct {
|
||||
|
||||
try errors.append(.{
|
||||
.src = .{
|
||||
.src_path = try arena.dupe(u8, file.sub_file_path),
|
||||
.src_path = try file.fullPath(arena),
|
||||
.msg = try arena.dupe(u8, msg),
|
||||
.byte_offset = byte_offset,
|
||||
.line = @intCast(u32, loc.line),
|
||||
|
@ -1111,6 +1111,10 @@ pub const Scope = struct {
|
||||
return buf.toOwnedSliceSentinel(0);
|
||||
}
|
||||
|
||||
pub fn fullPath(file: File, ally: *Allocator) ![]u8 {
|
||||
return file.pkg.root_src_directory.join(ally, &[_][]const u8{file.sub_file_path});
|
||||
}
|
||||
|
||||
pub fn dumpSrc(file: *File, src: LazySrcLoc) void {
|
||||
const loc = std.zig.findLineColumn(file.source.bytes, src);
|
||||
std.debug.print("{s}:{d}:{d}\n", .{ file.sub_file_path, loc.line + 1, loc.column + 1 });
|
||||
|
Loading…
Reference in New Issue
Block a user