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 {...@@ -305,12 +305,10 @@ pub fn unlockStderr() void {
305/// Alternatively, use the higher-level `std.log` or `Io.lockStderr` to305/// Alternatively, use the higher-level `std.log` or `Io.lockStderr` to
306/// integrate with the application's chosen `Io` implementation.306/// integrate with the application's chosen `Io` implementation.
307pub fn print(comptime fmt: []const u8, args: anytype) void {307pub fn print(comptime fmt: []const u8, args: anytype) void {
308 nosuspend {308 var buffer: [64]u8 = undefined;
309 var buffer: [64]u8 = undefined;309 const stderr = lockStderr(&buffer);
310 const stderr = lockStderr(&buffer);310 defer unlockStderr();
311 defer unlockStderr();311 stderr.file_writer.interface.print(fmt, args) catch return;
312 stderr.file_writer.interface.print(fmt, args) catch return;
313 }
314}312}
315313
316/// Marked `inline` to propagate a comptime-known error to callers.314/// Marked `inline` to propagate a comptime-known error to callers.
...@@ -1150,40 +1148,38 @@ fn printLineInfo(...@@ -1150,40 +1148,38 @@ fn printLineInfo(
1150 symbol_name: []const u8,1148 symbol_name: []const u8,
1151 compile_unit_name: []const u8,1149 compile_unit_name: []const u8,
1152) Writer.Error!void {1150) Writer.Error!void {
1153 nosuspend {1151 const writer = t.writer;
1154 const writer = t.writer;1152 t.setColor(.bold) catch {};
1155 t.setColor(.bold) catch {};
11561153
1157 if (source_location) |*sl| {1154 if (source_location) |*sl| {
1158 try writer.print("{s}:{d}:{d}", .{ sl.file_name, sl.line, sl.column });1155 try writer.print("{s}:{d}:{d}", .{ sl.file_name, sl.line, sl.column });
1159 } else {1156 } else {
1160 try writer.writeAll("???:?:?");1157 try writer.writeAll("???:?:?");
1161 }1158 }
11621159
1163 t.setColor(.reset) catch {};1160 t.setColor(.reset) catch {};
1164 try writer.writeAll(": ");1161 try writer.writeAll(": ");
1165 t.setColor(.dim) catch {};1162 t.setColor(.dim) catch {};
1166 try writer.print("0x{x} in {s} ({s})", .{ address, symbol_name, compile_unit_name });1163 try writer.print("0x{x} in {s} ({s})", .{ address, symbol_name, compile_unit_name });
1167 t.setColor(.reset) catch {};1164 t.setColor(.reset) catch {};
1168 try writer.writeAll("\n");1165 try writer.writeAll("\n");
11691166
1170 // Show the matching source code line if possible1167 // Show the matching source code line if possible
1171 if (source_location) |sl| {1168 if (source_location) |sl| {
1172 if (printLineFromFile(io, writer, sl)) {1169 if (printLineFromFile(io, writer, sl)) {
1173 if (sl.column > 0) {1170 if (sl.column > 0) {
1174 // The caret already takes one char1171 // The caret already takes one char
1175 const space_needed = @as(usize, @intCast(sl.column - 1));1172 const space_needed = @as(usize, @intCast(sl.column - 1));
11761173
1177 try writer.splatByteAll(' ', space_needed);1174 try writer.splatByteAll(' ', space_needed);
1178 t.setColor(.green) catch {};1175 t.setColor(.green) catch {};
1179 try writer.writeAll("^");1176 try writer.writeAll("^");
1180 t.setColor(.reset) catch {};1177 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.
1186 }1178 }
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.
1187 }1183 }
1188 }1184 }
1189}1185}