Skip to content

Commit 40d11cc

Browse files
committed
remove async and await keywords
Also remove `@frameSize`, closing #3654. While the other machinery might remain depending on #23446, it is settled that there will not be `async`/ `await` keywords in the language.
1 parent 31e46be commit 40d11cc

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+24
-2913
lines changed

doc/langref.html.in

Lines changed: 6 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -4279,16 +4279,9 @@ pub fn print(self: *Writer, arg0: []const u8, arg1: i32) !void {
42794279
{#header_close#}
42804280

42814281
{#header_open|Async Functions#}
4282-
<p>Async functions regressed with the release of 0.11.0. Their future in
4283-
the Zig language is unclear due to multiple unsolved problems:</p>
4284-
<ul>
4285-
<li>LLVM's lack of ability to optimize them.</li>
4286-
<li>Third-party debuggers' lack of ability to debug them.</li>
4287-
<li><a href="https://github.com/ziglang/zig/issues/5913">The cancellation problem</a>.</li>
4288-
<li>Async function pointers preventing the stack size from being known.</li>
4289-
</ul>
4290-
<p>These problems are surmountable, but it will take time. The Zig team
4291-
is currently focused on other priorities.</p>
4282+
<p>Async functions regressed with the release of 0.11.0. The current plan is to
4283+
reintroduce them as a lower level primitive that powers I/O implementations.</p>
4284+
<p>Tracking issue: <a href="https://github.com/ziglang/zig/issues/23446">Proposal: stackless coroutines as low-level primitives</a></p>
42924285
{#header_close#}
42934286

42944287
{#header_open|Builtin Functions|2col#}
@@ -7372,29 +7365,6 @@ fn readU32Be() u32 {}
73727365
</ul>
73737366
</td>
73747367
</tr>
7375-
<tr>
7376-
<th scope="row">
7377-
<pre>{#syntax#}async{#endsyntax#}</pre>
7378-
</th>
7379-
<td>
7380-
{#syntax#}async{#endsyntax#} can be used before a function call to get a pointer to the function's frame when it suspends.
7381-
<ul>
7382-
<li>See also {#link|Async Functions#}</li>
7383-
</ul>
7384-
</td>
7385-
</tr>
7386-
<tr>
7387-
<th scope="row">
7388-
<pre>{#syntax#}await{#endsyntax#}</pre>
7389-
</th>
7390-
<td>
7391-
{#syntax#}await{#endsyntax#} can be used to suspend the current function until the frame provided after the {#syntax#}await{#endsyntax#} completes.
7392-
{#syntax#}await{#endsyntax#} copies the value returned from the target function's frame to the caller.
7393-
<ul>
7394-
<li>See also {#link|Async Functions#}</li>
7395-
</ul>
7396-
</td>
7397-
</tr>
73987368
<tr>
73997369
<th scope="row">
74007370
<pre>{#syntax#}break{#endsyntax#}</pre>
@@ -8006,8 +7976,7 @@ TypeExpr <- PrefixTypeOp* ErrorUnionExpr
80067976
ErrorUnionExpr <- SuffixExpr (EXCLAMATIONMARK TypeExpr)?
80077977

80087978
SuffixExpr
8009-
<- KEYWORD_async PrimaryTypeExpr SuffixOp* FnCallArguments
8010-
/ PrimaryTypeExpr (SuffixOp / FnCallArguments)*
7979+
<- PrimaryTypeExpr (SuffixOp / FnCallArguments)*
80117980

80127981
PrimaryTypeExpr
80137982
<- BUILTINIDENTIFIER FnCallArguments
@@ -8183,7 +8152,6 @@ PrefixOp
81838152
/ MINUSPERCENT
81848153
/ AMPERSAND
81858154
/ KEYWORD_try
8186-
/ KEYWORD_await
81878155

81888156
PrefixTypeOp
81898157
<- QUESTIONMARK
@@ -8404,8 +8372,6 @@ KEYWORD_and <- 'and' end_of_word
84048372
KEYWORD_anyframe <- 'anyframe' end_of_word
84058373
KEYWORD_anytype <- 'anytype' end_of_word
84068374
KEYWORD_asm <- 'asm' end_of_word
8407-
KEYWORD_async <- 'async' end_of_word
8408-
KEYWORD_await <- 'await' end_of_word
84098375
KEYWORD_break <- 'break' end_of_word
84108376
KEYWORD_callconv <- 'callconv' end_of_word
84118377
KEYWORD_catch <- 'catch' end_of_word
@@ -8448,8 +8414,8 @@ KEYWORD_volatile <- 'volatile' end_of_word
84488414
KEYWORD_while <- 'while' end_of_word
84498415

84508416
keyword <- KEYWORD_addrspace / KEYWORD_align / KEYWORD_allowzero / KEYWORD_and
8451-
/ KEYWORD_anyframe / KEYWORD_anytype / KEYWORD_asm / KEYWORD_async
8452-
/ KEYWORD_await / KEYWORD_break / KEYWORD_callconv / KEYWORD_catch
8417+
/ KEYWORD_anyframe / KEYWORD_anytype / KEYWORD_asm
8418+
/ KEYWORD_break / KEYWORD_callconv / KEYWORD_catch
84538419
/ KEYWORD_comptime / KEYWORD_const / KEYWORD_continue / KEYWORD_defer
84548420
/ KEYWORD_else / KEYWORD_enum / KEYWORD_errdefer / KEYWORD_error / KEYWORD_export
84558421
/ KEYWORD_extern / KEYWORD_fn / KEYWORD_for / KEYWORD_if

lib/compiler/reduce/Walk.zig

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,6 @@ fn walkExpression(w: *Walk, node: Ast.Node.Index) Error!void {
335335
.address_of,
336336
.@"try",
337337
.@"resume",
338-
.@"await",
339338
.deref,
340339
=> {
341340
return walkExpression(w, ast.nodeData(node).node);
@@ -379,12 +378,8 @@ fn walkExpression(w: *Walk, node: Ast.Node.Index) Error!void {
379378

380379
.call_one,
381380
.call_one_comma,
382-
.async_call_one,
383-
.async_call_one_comma,
384381
.call,
385382
.call_comma,
386-
.async_call,
387-
.async_call_comma,
388383
=> {
389384
var buf: [1]Ast.Node.Index = undefined;
390385
return walkCall(w, ast.fullCall(&buf, node).?);

lib/docs/wasm/Walk.zig

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -238,12 +238,8 @@ pub const File = struct {
238238

239239
.call_one,
240240
.call_one_comma,
241-
.async_call_one,
242-
.async_call_one_comma,
243241
.call,
244242
.call_comma,
245-
.async_call,
246-
.async_call_comma,
247243
=> {
248244
var buf: [1]Ast.Node.Index = undefined;
249245
return categorize_call(file_index, node, ast.fullCall(&buf, node).?);
@@ -743,7 +739,6 @@ fn expr(w: *Walk, scope: *Scope, parent_decl: Decl.Index, node: Ast.Node.Index)
743739
.@"comptime",
744740
.@"nosuspend",
745741
.@"suspend",
746-
.@"await",
747742
.@"resume",
748743
.@"try",
749744
=> try expr(w, scope, parent_decl, ast.nodeData(node).node),
@@ -806,12 +801,8 @@ fn expr(w: *Walk, scope: *Scope, parent_decl: Decl.Index, node: Ast.Node.Index)
806801

807802
.call_one,
808803
.call_one_comma,
809-
.async_call_one,
810-
.async_call_one_comma,
811804
.call,
812805
.call_comma,
813-
.async_call,
814-
.async_call_comma,
815806
=> {
816807
var buf: [1]Ast.Node.Index = undefined;
817808
const full = ast.fullCall(&buf, node).?;

lib/docs/wasm/html_render.zig

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,6 @@ pub fn fileSourceHtml(
101101
.keyword_align,
102102
.keyword_and,
103103
.keyword_asm,
104-
.keyword_async,
105-
.keyword_await,
106104
.keyword_break,
107105
.keyword_catch,
108106
.keyword_comptime,

lib/std/builtin.zig

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -199,8 +199,6 @@ pub const CallingConvention = union(enum(u8)) {
199199
pub const C: CallingConvention = .c;
200200
/// Deprecated; use `.naked`.
201201
pub const Naked: CallingConvention = .naked;
202-
/// Deprecated; use `.@"async"`.
203-
pub const Async: CallingConvention = .@"async";
204202
/// Deprecated; use `.@"inline"`.
205203
pub const Inline: CallingConvention = .@"inline";
206204
/// Deprecated; use `.x86_64_interrupt`, `.x86_interrupt`, or `.avr_interrupt`.
@@ -866,32 +864,23 @@ pub const WasiExecModel = enum {
866864
pub const CallModifier = enum {
867865
/// Equivalent to function call syntax.
868866
auto,
869-
870-
/// Equivalent to async keyword used with function call syntax.
871-
async_kw,
872-
873867
/// Prevents tail call optimization. This guarantees that the return
874868
/// address will point to the callsite, as opposed to the callsite's
875869
/// callsite. If the call is otherwise required to be tail-called
876870
/// or inlined, a compile error is emitted instead.
877871
never_tail,
878-
879872
/// Guarantees that the call will not be inlined. If the call is
880873
/// otherwise required to be inlined, a compile error is emitted instead.
881874
never_inline,
882-
883875
/// Asserts that the function call will not suspend. This allows a
884876
/// non-async function to call an async function.
885-
no_async,
886-
877+
no_suspend,
887878
/// Guarantees that the call will be generated with tail call optimization.
888879
/// If this is not possible, a compile error is emitted instead.
889880
always_tail,
890-
891881
/// Guarantees that the call will be inlined at the callsite.
892882
/// If this is not possible, a compile error is emitted instead.
893883
always_inline,
894-
895884
/// Evaluates the call at compile-time. If the call cannot be completed at
896885
/// compile-time, a compile error is emitted instead.
897886
compile_time,

lib/std/zig/Ast.zig

Lines changed: 7 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -606,7 +606,6 @@ pub fn firstToken(tree: Ast, node: Node.Index) TokenIndex {
606606
.negation_wrap,
607607
.address_of,
608608
.@"try",
609-
.@"await",
610609
.optional_type,
611610
.@"switch",
612611
.switch_comma,
@@ -763,20 +762,6 @@ pub fn firstToken(tree: Ast, node: Node.Index) TokenIndex {
763762
return main_token - end_offset;
764763
},
765764

766-
.async_call_one,
767-
.async_call_one_comma,
768-
=> {
769-
end_offset += 1; // async token
770-
n = tree.nodeData(n).node_and_opt_node[0];
771-
},
772-
773-
.async_call,
774-
.async_call_comma,
775-
=> {
776-
end_offset += 1; // async token
777-
n = tree.nodeData(n).node_and_extra[0];
778-
},
779-
780765
.container_field_init,
781766
.container_field_align,
782767
.container_field,
@@ -903,7 +888,6 @@ pub fn lastToken(tree: Ast, node: Node.Index) TokenIndex {
903888
.negation_wrap,
904889
.address_of,
905890
.@"try",
906-
.@"await",
907891
.optional_type,
908892
.@"suspend",
909893
.@"resume",
@@ -1022,7 +1006,7 @@ pub fn lastToken(tree: Ast, node: Node.Index) TokenIndex {
10221006
};
10231007
},
10241008

1025-
.call, .async_call => {
1009+
.call => {
10261010
_, const extra_index = tree.nodeData(n).node_and_extra;
10271011
const params = tree.extraData(extra_index, Node.SubRange);
10281012
assert(params.start != params.end);
@@ -1041,7 +1025,6 @@ pub fn lastToken(tree: Ast, node: Node.Index) TokenIndex {
10411025
}
10421026
},
10431027
.call_comma,
1044-
.async_call_comma,
10451028
.tagged_union_enum_tag_trailing,
10461029
=> {
10471030
_, const extra_index = tree.nodeData(n).node_and_extra;
@@ -1122,7 +1105,6 @@ pub fn lastToken(tree: Ast, node: Node.Index) TokenIndex {
11221105
n = @enumFromInt(tree.extra_data[@intFromEnum(range.end) - 1]); // last member
11231106
},
11241107
.call_one,
1125-
.async_call_one,
11261108
=> {
11271109
_, const first_param = tree.nodeData(n).node_and_opt_node;
11281110
end_offset += 1; // for the rparen
@@ -1271,7 +1253,6 @@ pub fn lastToken(tree: Ast, node: Node.Index) TokenIndex {
12711253
n = first_element;
12721254
},
12731255
.call_one_comma,
1274-
.async_call_one_comma,
12751256
.struct_init_one_comma,
12761257
=> {
12771258
_, const first_field = tree.nodeData(n).node_and_opt_node;
@@ -1988,21 +1969,21 @@ pub fn forFull(tree: Ast, node: Node.Index) full.For {
19881969
pub fn callOne(tree: Ast, buffer: *[1]Node.Index, node: Node.Index) full.Call {
19891970
const fn_expr, const first_param = tree.nodeData(node).node_and_opt_node;
19901971
const params = loadOptionalNodesIntoBuffer(1, buffer, .{first_param});
1991-
return tree.fullCallComponents(.{
1972+
return .{ .ast = .{
19921973
.lparen = tree.nodeMainToken(node),
19931974
.fn_expr = fn_expr,
19941975
.params = params,
1995-
});
1976+
} };
19961977
}
19971978

19981979
pub fn callFull(tree: Ast, node: Node.Index) full.Call {
19991980
const fn_expr, const extra_index = tree.nodeData(node).node_and_extra;
20001981
const params = tree.extraDataSlice(tree.extraData(extra_index, Node.SubRange), Node.Index);
2001-
return tree.fullCallComponents(.{
1982+
return .{ .ast = .{
20021983
.lparen = tree.nodeMainToken(node),
20031984
.fn_expr = fn_expr,
20041985
.params = params,
2005-
});
1986+
} };
20061987
}
20071988

20081989
fn fullVarDeclComponents(tree: Ast, info: full.VarDecl.Components) full.VarDecl {
@@ -2336,18 +2317,6 @@ fn fullForComponents(tree: Ast, info: full.For.Components) full.For {
23362317
return result;
23372318
}
23382319

2339-
fn fullCallComponents(tree: Ast, info: full.Call.Components) full.Call {
2340-
var result: full.Call = .{
2341-
.ast = info,
2342-
.async_token = null,
2343-
};
2344-
const first_token = tree.firstToken(info.fn_expr);
2345-
if (tree.isTokenPrecededByTags(first_token, &.{.keyword_async})) {
2346-
result.async_token = first_token - 1;
2347-
}
2348-
return result;
2349-
}
2350-
23512320
pub fn fullVarDecl(tree: Ast, node: Node.Index) ?full.VarDecl {
23522321
return switch (tree.nodeTag(node)) {
23532322
.global_var_decl => tree.globalVarDecl(node),
@@ -2488,8 +2457,8 @@ pub fn fullAsm(tree: Ast, node: Node.Index) ?full.Asm {
24882457

24892458
pub fn fullCall(tree: Ast, buffer: *[1]Ast.Node.Index, node: Node.Index) ?full.Call {
24902459
return switch (tree.nodeTag(node)) {
2491-
.call, .call_comma, .async_call, .async_call_comma => tree.callFull(node),
2492-
.call_one, .call_one_comma, .async_call_one, .async_call_one_comma => tree.callOne(buffer, node),
2460+
.call, .call_comma => tree.callFull(node),
2461+
.call_one, .call_one_comma => tree.callOne(buffer, node),
24932462
else => null,
24942463
};
24952464
}
@@ -2882,7 +2851,6 @@ pub const full = struct {
28822851

28832852
pub const Call = struct {
28842853
ast: Components,
2885-
async_token: ?TokenIndex,
28862854

28872855
pub const Components = struct {
28882856
lparen: TokenIndex,
@@ -3301,8 +3269,6 @@ pub const Node = struct {
33013269
address_of,
33023270
/// `try expr`. The `main_token` field is the `try` token.
33033271
@"try",
3304-
/// `await expr`. The `main_token` field is the `await` token.
3305-
@"await",
33063272
/// `?expr`. The `main_token` field is the `?` token.
33073273
optional_type,
33083274
/// `[lhs]rhs`. The `main_token` field is the `[` token.
@@ -3498,17 +3464,6 @@ pub const Node = struct {
34983464
/// Same as `call_one` except there is known to be a trailing comma
34993465
/// before the final rparen.
35003466
call_one_comma,
3501-
/// `async a(b)`, `async a()`.
3502-
///
3503-
/// The `data` field is a `.node_and_opt_node`:
3504-
/// 1. a `Node.Index` to the function expression.
3505-
/// 2. a `Node.OptionalIndex` to the first argument, if any.
3506-
///
3507-
/// The `main_token` field is the `(` token.
3508-
async_call_one,
3509-
/// Same as `async_call_one` except there is known to be a trailing
3510-
/// comma before the final rparen.
3511-
async_call_one_comma,
35123467
/// `a(b, c, d)`.
35133468
///
35143469
/// The `data` field is a `.node_and_extra`:
@@ -3521,18 +3476,6 @@ pub const Node = struct {
35213476
/// Same as `call` except there is known to be a trailing comma before
35223477
/// the final rparen.
35233478
call_comma,
3524-
/// `async a(b, c, d)`.
3525-
///
3526-
/// The `data` field is a `.node_and_extra`:
3527-
/// 1. a `Node.Index` to the function expression.
3528-
/// 2. a `ExtraIndex` to a `SubRange` that stores a `Node.Index` for
3529-
/// each argument.
3530-
///
3531-
/// The `main_token` field is the `(` token.
3532-
async_call,
3533-
/// Same as `async_call` except there is known to be a trailing comma
3534-
/// before the final rparen.
3535-
async_call_comma,
35363479
/// `switch(a) {}`.
35373480
///
35383481
/// The `data` field is a `.node_and_extra`:

0 commit comments

Comments
 (0)