From 53854608c3885203c8e676508c9df34201f70e5d Mon Sep 17 00:00:00 2001 From: ippsav Date: Mon, 11 Nov 2024 16:04:09 +0100 Subject: [PATCH] allow noreturn in Pool.zig --- lib/std/Thread/Pool.zig | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/lib/std/Thread/Pool.zig b/lib/std/Thread/Pool.zig index 10c29c0c0820..4dd75133731d 100644 --- a/lib/std/Thread/Pool.zig +++ b/lib/std/Thread/Pool.zig @@ -323,23 +323,26 @@ pub fn getIdCount(pool: *Pool) usize { } inline fn callFn(comptime f: anytype, args: anytype) void { - const bad_fn_ret = "expected return type of runFn to be 'void', or '!void'"; + const bad_fn_ret = "expected return type of runFn to be 'void', '!void', noreturn, or !noreturn"; switch (@typeInfo(@typeInfo(@TypeOf(f)).@"fn".return_type.?)) { - .void => { + .void, .noreturn => { @call(.auto, f, args); }, .error_union => |info| { - if (info.payload != void) { - @compileError(bad_fn_ret); + switch (info.payload) { + void, noreturn => { + @call(.auto, f, args) catch |err| { + std.debug.print("error: {s}\n", .{@errorName(err)}); + if (@errorReturnTrace()) |trace| { + std.debug.dumpStackTrace(trace.*); + } + }; + }, + else => { + @compileError(bad_fn_ret); + }, } - - @call(.auto, f, args) catch |err| { - std.debug.print("error: {s}\n", .{@errorName(err)}); - if (@errorReturnTrace()) |trace| { - std.debug.dumpStackTrace(trace.*); - } - }; }, else => { @compileError(bad_fn_ret);