std.debug.Trace: improve API

Now `std.debug.Trace` is a concrete type with pre-chosen defaults.
`std.debug.ConfigurableTrace` can be used for more advanced cases.
This commit is contained in:
Andrew Kelley
2022-06-08 12:55:24 -07:00
parent 83f300218f
commit af909f6c93
2 changed files with 33 additions and 10 deletions

View File

@@ -2529,11 +2529,9 @@ pub const SrcLoc = struct {
/// where in semantic analysis the value got set.
const TracedOffset = struct {
x: i32,
trace: Trace = trace_init,
trace: std.debug.Trace = .{},
const want_tracing = builtin.mode == .Debug;
const trace_init = if (want_tracing) std.debug.Trace(1, 3){} else {};
const Trace = @TypeOf(trace_init);
const want_tracing = std.debug.Trace.enabled;
};
/// Resolving a source location into a byte offset may require doing work