authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-05-24 10:34:29-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-05-27 20:56:48-07:00
log1cf1cb6ae00561b81b4e0863cff43c3fdd28a4a0
tree9c2fa692a69fb9785f2981b8d4e449607152c909
parenta486392ee4bfe6f2577aafa9c1d50a176b0de0ea

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


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

lib/std/debug.zig+9-3
...@@ -2759,13 +2759,19 @@ pub const Trace = ConfigurableTrace(2, 4, builtin.mode == .Debug);...@@ -2759,13 +2759,19 @@ pub const Trace = ConfigurableTrace(2, 4, builtin.mode == .Debug);
27592759
2760pub fn ConfigurableTrace(comptime size: usize, comptime stack_frame_count: usize, comptime is_enabled: bool) type {2760pub fn ConfigurableTrace(comptime size: usize, comptime stack_frame_count: usize, comptime is_enabled: bool) type {
2761 return struct {2761 return struct {
2762 addrs: [actual_size][stack_frame_count]usize = undefined,2762 addrs: [actual_size][stack_frame_count]usize,
2763 notes: [actual_size][]const u8 = undefined,2763 notes: [actual_size][]const u8,
2764 index: Index = 0,2764 index: Index,
27652765
2766 const actual_size = if (enabled) size else 0;2766 const actual_size = if (enabled) size else 0;
2767 const Index = if (enabled) usize else u0;2767 const Index = if (enabled) usize else u0;
27682768
2769 pub const init: @This() = .{
2770 .addrs = undefined,
2771 .notes = undefined,
2772 .index = 0,
2773 };
2774
2769 pub const enabled = is_enabled;2775 pub const enabled = is_enabled;
27702776
2771 pub const add = if (enabled) addNoInline else addNoOp;2777 pub const add = if (enabled) addNoInline else addNoOp;
lib/std/zig.zig+1-1
...@@ -718,7 +718,7 @@ pub const LazySrcLoc = union(enum) {...@@ -718,7 +718,7 @@ pub const LazySrcLoc = union(enum) {
718 /// where in semantic analysis the value got set.718 /// where in semantic analysis the value got set.
719 pub const TracedOffset = struct {719 pub const TracedOffset = struct {
720 x: i32,720 x: i32,
721 trace: std.debug.Trace = .{},721 trace: std.debug.Trace = std.debug.Trace.init,
722722
723 const want_tracing = false;723 const want_tracing = false;
724 };724 };