From 84a0a9688caea0f7cfe19bac07d5b5d46a06d470 Mon Sep 17 00:00:00 2001 From: Tadeo Kondrak Date: Mon, 4 May 2020 10:50:11 -0600 Subject: [PATCH] update docs/tests for async/extern fn removal --- doc/langref.html.in | 4 ++-- lib/std/zig/parser_test.zig | 1 + test/compile_errors.zig | 22 +++++++++++----------- test/runtime_safety.zig | 8 ++++---- test/stack_traces.zig | 2 +- 5 files changed, 19 insertions(+), 18 deletions(-) diff --git a/doc/langref.html.in b/doc/langref.html.in index b2e1f6e6f6..91665604f7 100644 --- a/doc/langref.html.in +++ b/doc/langref.html.in @@ -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; diff --git a/lib/std/zig/parser_test.zig b/lib/std/zig/parser_test.zig index 7ab3e86b1a..b98e8c69c3 100644 --- a/lib/std/zig/parser_test.zig +++ b/lib/std/zig/parser_test.zig @@ -2910,6 +2910,7 @@ test "zig fmt: noasync to nosuspend" { \\pub fn main() void { \\ nosuspend call(); \\} + \\ ); } diff --git a/test/compile_errors.zig b/test/compile_errors.zig index 19ec55d9e6..a79c8825a1 100644 --- a/test/compile_errors.zig +++ b/test/compile_errors.zig @@ -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'", }); diff --git a/test/runtime_safety.zig b/test/runtime_safety.zig index 6837efe2d2..2e50c3a84c 100644 --- a/test/runtime_safety.zig +++ b/test/runtime_safety.zig @@ -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; \\} ); diff --git a/test/stack_traces.zig b/test/stack_traces.zig index 2f7201e71d..616136b9ee 100644 --- a/test/stack_traces.zig +++ b/test/stack_traces.zig @@ -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)