authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2025-12-22 15:14:59-08:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2025-12-23 22:15:12-08:00
log0992f1204e6e1ebf4437d98647f4336aa1c5c95e
tree2aaf0fde5aff840377ff09dd16170b5cb1c1958a
parent78c4fcfcd89e80ef70cf4cbb13f5100c84432496

std.debug: delete nosuspend blocks

now that the application can choose an Io implementation these might actually suspend.

1 files changed, 33 insertions(+), 37 deletions(-)

lib/std/debug.zig+33-37
......@@ -305,12 +305,10 @@ pub fn unlockStderr() void {
305305/// Alternatively, use the higher-level `std.log` or `Io.lockStderr` to
306306/// integrate with the application's chosen `Io` implementation.
307307pub fn print(comptime fmt: []const u8, args: anytype) void {
308 nosuspend {
309 var buffer: [64]u8 = undefined;
310 const stderr = lockStderr(&buffer);
311 defer unlockStderr();
312 stderr.file_writer.interface.print(fmt, args) catch return;
313 }
308 var buffer: [64]u8 = undefined;
309 const stderr = lockStderr(&buffer);
310 defer unlockStderr();
311 stderr.file_writer.interface.print(fmt, args) catch return;
314312}
315313
316314/// Marked `inline` to propagate a comptime-known error to callers.
......@@ -1150,40 +1148,38 @@ fn printLineInfo(
11501148 symbol_name: []const u8,
11511149 compile_unit_name: []const u8,
11521150) Writer.Error!void {
1153 nosuspend {
1154 const writer = t.writer;
1155 t.setColor(.bold) catch {};
1151 const writer = t.writer;
1152 t.setColor(.bold) catch {};
11561153
1157 if (source_location) |*sl| {
1158 try writer.print("{s}:{d}:{d}", .{ sl.file_name, sl.line, sl.column });
1159 } else {
1160 try writer.writeAll("???:?:?");
1161 }
1154 if (source_location) |*sl| {
1155 try writer.print("{s}:{d}:{d}", .{ sl.file_name, sl.line, sl.column });
1156 } else {
1157 try writer.writeAll("???:?:?");
1158 }
11621159
1163 t.setColor(.reset) catch {};
1164 try writer.writeAll(": ");
1165 t.setColor(.dim) catch {};
1166 try writer.print("0x{x} in {s} ({s})", .{ address, symbol_name, compile_unit_name });
1167 t.setColor(.reset) catch {};
1168 try writer.writeAll("\n");
1169
1170 // Show the matching source code line if possible
1171 if (source_location) |sl| {
1172 if (printLineFromFile(io, writer, sl)) {
1173 if (sl.column > 0) {
1174 // The caret already takes one char
1175 const space_needed = @as(usize, @intCast(sl.column - 1));
1176
1177 try writer.splatByteAll(' ', space_needed);
1178 t.setColor(.green) catch {};
1179 try writer.writeAll("^");
1180 t.setColor(.reset) catch {};
1181 }
1182 try writer.writeAll("\n");
1183 } else |_| {
1184 // Ignore all errors; it's a better UX to just print the source location without the
1185 // corresponding line number. The user can always open the source file themselves.
1160 t.setColor(.reset) catch {};
1161 try writer.writeAll(": ");
1162 t.setColor(.dim) catch {};
1163 try writer.print("0x{x} in {s} ({s})", .{ address, symbol_name, compile_unit_name });
1164 t.setColor(.reset) catch {};
1165 try writer.writeAll("\n");
1166
1167 // Show the matching source code line if possible
1168 if (source_location) |sl| {
1169 if (printLineFromFile(io, writer, sl)) {
1170 if (sl.column > 0) {
1171 // The caret already takes one char
1172 const space_needed = @as(usize, @intCast(sl.column - 1));
1173
1174 try writer.splatByteAll(' ', space_needed);
1175 t.setColor(.green) catch {};
1176 try writer.writeAll("^");
1177 t.setColor(.reset) catch {};
11861178 }
1179 try writer.writeAll("\n");
1180 } else |_| {
1181 // Ignore all errors; it's a better UX to just print the source location without the
1182 // corresponding line number. The user can always open the source file themselves.
11871183 }
11881184 }
11891185}