feature. See also
. The project being documented here (as the example) is the Zig library itself.
AstGen.appendErrorNodeNotes
fn appendErrorNodeNotes(
astgen: *AstGen,
node: Ast.Node.Index,
comptime format: []const u8,
args: anytype,
notes: []const u32,
) Allocator.Error!void
File
Code
fn appendErrorNodeNotes(
astgen: *AstGen,
node: Ast.Node.Index,
comptime format: []const u8,
args: anytype,
notes: []const u32,
) Allocator.Error!void {
@branchHint(.cold);
const gpa = astgen.gpa;
const string_bytes = &astgen.string_bytes;
const msg: Zir.NullTerminatedString = @fromBackingInt(@intCast(string_bytes.items.len));
try string_bytes.print(gpa, format ++ "\x00", args);
const notes_index: u32 = if (notes.len != 0) blk: {
const notes_start = astgen.extra.items.len;
try astgen.extra.ensureTotalCapacity(gpa, notes_start + 1 + notes.len);
astgen.extra.appendAssumeCapacity(@intCast(notes.len));
astgen.extra.appendSliceAssumeCapacity(notes);
break :blk @intCast(notes_start);
} else 0;
try astgen.compile_errors.append(gpa, .{
.msg = msg,
.node = node.toOptional(),
.token = .none,
.byte_offset = 0,
.notes = notes_index,
});
}