update docs/tests for async/extern fn removal
parent
6745a6f6f6
commit
84a0a9688c
|
@ -6713,7 +6713,7 @@ const assert = std.debug.assert;
|
|||
test "async fn pointer in a struct field" {
|
||||
var data: i32 = 1;
|
||||
const Foo = struct {
|
||||
bar: async fn (*i32) void,
|
||||
bar: fn (*i32) callconv(.Async) void,
|
||||
};
|
||||
var foo = Foo{ .bar = func };
|
||||
var bytes: [64]u8 align(@alignOf(@Frame(func))) = undefined;
|
||||
|
@ -6723,7 +6723,7 @@ test "async fn pointer in a struct field" {
|
|||
assert(data == 4);
|
||||
}
|
||||
|
||||
async fn func(y: *i32) void {
|
||||
fn func(y: *i32) void {
|
||||
defer y.* += 2;
|
||||
y.* += 1;
|
||||
suspend;
|
||||
|
|
|
@ -2910,6 +2910,7 @@ test "zig fmt: noasync to nosuspend" {
|
|||
\\pub fn main() void {
|
||||
\\ nosuspend call();
|
||||
\\}
|
||||
\\
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -802,7 +802,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
|
|||
});
|
||||
|
||||
cases.add("exported async function",
|
||||
\\export async fn foo() void {}
|
||||
\\export fn foo() callconv(.Async) void {}
|
||||
, &[_][]const u8{
|
||||
"tmp.zig:1:1: error: exported function cannot be async",
|
||||
});
|
||||
|
@ -1281,11 +1281,11 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
|
|||
|
||||
cases.add("bad alignment in @asyncCall",
|
||||
\\export fn entry() void {
|
||||
\\ var ptr: async fn () void = func;
|
||||
\\ var ptr: fn () callconv(.Async) void = func;
|
||||
\\ var bytes: [64]u8 = undefined;
|
||||
\\ _ = @asyncCall(&bytes, {}, ptr);
|
||||
\\}
|
||||
\\async fn func() void {}
|
||||
\\fn func() callconv(.Async) void {}
|
||||
, &[_][]const u8{
|
||||
"tmp.zig:4:21: error: expected type '[]align(16) u8', found '*[64]u8'",
|
||||
});
|
||||
|
@ -1431,7 +1431,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
|
|||
\\export fn entry() void {
|
||||
\\ _ = async amain();
|
||||
\\}
|
||||
\\async fn amain() void {
|
||||
\\fn amain() callconv(.Async) void {
|
||||
\\ other();
|
||||
\\}
|
||||
\\fn other() void {
|
||||
|
@ -1447,7 +1447,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
|
|||
\\export fn entry() void {
|
||||
\\ _ = async amain();
|
||||
\\}
|
||||
\\async fn amain() void {
|
||||
\\fn amain() callconv(.Async) void {
|
||||
\\ var x: [@sizeOf(@Frame(amain))]u8 = undefined;
|
||||
\\}
|
||||
, &[_][]const u8{
|
||||
|
@ -1474,7 +1474,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
|
|||
\\ var ptr = afunc;
|
||||
\\ _ = ptr();
|
||||
\\}
|
||||
\\async fn afunc() void {}
|
||||
\\fn afunc() callconv(.Async) void {}
|
||||
, &[_][]const u8{
|
||||
"tmp.zig:6:12: error: function is not comptime-known; @asyncCall required",
|
||||
});
|
||||
|
@ -1485,7 +1485,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
|
|||
\\ _ = async ptr();
|
||||
\\}
|
||||
\\
|
||||
\\async fn afunc() void { }
|
||||
\\fn afunc() callconv(.Async) void { }
|
||||
, &[_][]const u8{
|
||||
"tmp.zig:3:15: error: function is not comptime-known; @asyncCall required",
|
||||
});
|
||||
|
@ -3074,7 +3074,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
|
|||
\\export fn entry() void {
|
||||
\\ _ = async foo();
|
||||
\\}
|
||||
\\async fn foo() void {
|
||||
\\fn foo() void {
|
||||
\\ suspend {
|
||||
\\ suspend {
|
||||
\\ }
|
||||
|
@ -3122,7 +3122,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
|
|||
\\export fn entry() void {
|
||||
\\ _ = async amain();
|
||||
\\}
|
||||
\\async fn amain() void {
|
||||
\\fn amain() callconv(.Async) void {
|
||||
\\ return error.ShouldBeCompileError;
|
||||
\\}
|
||||
, &[_][]const u8{
|
||||
|
@ -3592,7 +3592,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
|
|||
});
|
||||
|
||||
cases.add("attempt to use 0 bit type in extern fn",
|
||||
\\extern fn foo(ptr: extern fn(*void) void) void;
|
||||
\\extern fn foo(ptr: fn(*void) callconv(.C) void) void;
|
||||
\\
|
||||
\\export fn entry() void {
|
||||
\\ foo(bar);
|
||||
|
@ -3603,7 +3603,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
|
|||
\\ bar(&{});
|
||||
\\}
|
||||
, &[_][]const u8{
|
||||
"tmp.zig:1:30: error: parameter of type '*void' has 0 bits; not allowed in function with calling convention 'C'",
|
||||
"tmp.zig:1:23: error: parameter of type '*void' has 0 bits; not allowed in function with calling convention 'C'",
|
||||
"tmp.zig:7:11: error: parameter of type '*void' has 0 bits; not allowed in function with calling convention 'C'",
|
||||
});
|
||||
|
||||
|
|
|
@ -282,7 +282,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {
|
|||
\\ var ptr = other;
|
||||
\\ var frame = @asyncCall(&bytes, {}, ptr);
|
||||
\\}
|
||||
\\async fn other() void {
|
||||
\\fn other() callconv(.Async) void {
|
||||
\\ suspend;
|
||||
\\}
|
||||
);
|
||||
|
@ -874,16 +874,16 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {
|
|||
\\ return &failing_frame;
|
||||
\\}
|
||||
\\
|
||||
\\async fn failing() anyerror!void {
|
||||
\\fn failing() anyerror!void {
|
||||
\\ suspend;
|
||||
\\ return second();
|
||||
\\}
|
||||
\\
|
||||
\\async fn second() anyerror!void {
|
||||
\\fn second() callconv(.Async) anyerror!void {
|
||||
\\ return error.Fail;
|
||||
\\}
|
||||
\\
|
||||
\\async fn printTrace(p: anyframe->anyerror!void) void {
|
||||
\\fn printTrace(p: anyframe->anyerror!void) void {
|
||||
\\ (await p) catch unreachable;
|
||||
\\}
|
||||
);
|
||||
|
|
|
@ -282,7 +282,7 @@ pub fn addCases(cases: *tests.StackTracesContext) void {
|
|||
\\source.zig:10:8: [address] in main (test)
|
||||
\\ foo();
|
||||
\\ ^
|
||||
\\start.zig:250:29: [address] in std.start.posixCallMainAndExit (test)
|
||||
\\start.zig:249:29: [address] in std.start.posixCallMainAndExit (test)
|
||||
\\ return root.main();
|
||||
\\ ^
|
||||
\\start.zig:123:5: [address] in std.start._start (test)
|
||||
|
|
Loading…
Reference in New Issue