std.debug.Trace: follow the struct default field guidance

This commit is contained in:
Andrew Kelley 2024-05-24 10:34:29 -07:00
parent a486392ee4
commit 1cf1cb6ae0
2 changed files with 10 additions and 4 deletions

View File

@ -2759,13 +2759,19 @@ pub const Trace = ConfigurableTrace(2, 4, builtin.mode == .Debug);
pub fn ConfigurableTrace(comptime size: usize, comptime stack_frame_count: usize, comptime is_enabled: bool) type {
return struct {
addrs: [actual_size][stack_frame_count]usize = undefined,
notes: [actual_size][]const u8 = undefined,
index: Index = 0,
addrs: [actual_size][stack_frame_count]usize,
notes: [actual_size][]const u8,
index: Index,
const actual_size = if (enabled) size else 0;
const Index = if (enabled) usize else u0;
pub const init: @This() = .{
.addrs = undefined,
.notes = undefined,
.index = 0,
};
pub const enabled = is_enabled;
pub const add = if (enabled) addNoInline else addNoOp;

View File

@ -718,7 +718,7 @@ pub const LazySrcLoc = union(enum) {
/// where in semantic analysis the value got set.
pub const TracedOffset = struct {
x: i32,
trace: std.debug.Trace = .{},
trace: std.debug.Trace = std.debug.Trace.init,
const want_tracing = false;
};