Skip to content

Commit fc2c188

Browse files
authored
Merge pull request #24362 (remove async, await, usingnamespace)
remove `async` and `await` keywords; remove `usingnamespace`
2 parents 9e49652 + 4ba0e7d commit fc2c188

File tree

84 files changed

+90
-3860
lines changed

Some content is hidden

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

84 files changed

+90
-3860
lines changed

build.zig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -460,8 +460,8 @@ pub fn build(b: *std.Build) !void {
460460
.skip_linux = skip_linux,
461461
.skip_llvm = skip_llvm,
462462
.skip_libc = skip_libc,
463-
// 2923515904 was observed on an x86_64-linux-gnu host.
464-
.max_rss = 3100000000,
463+
// 3888779264 was observed on an x86_64-linux-gnu host.
464+
.max_rss = 4000000000,
465465
}));
466466

467467
test_modules_step.dependOn(tests.addModuleTests(b, .{

doc/langref.html.in

Lines changed: 8 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -3842,37 +3842,6 @@ void do_a_thing(struct Foo *foo) {
38423842
{#header_close#}
38433843
{#header_close#}
38443844

3845-
{#header_open|usingnamespace#}
3846-
<p>
3847-
{#syntax#}usingnamespace{#endsyntax#} is a declaration that mixes all the public
3848-
declarations of the operand, which must be a {#link|struct#}, {#link|union#}, {#link|enum#},
3849-
or {#link|opaque#}, into the namespace:
3850-
</p>
3851-
{#code|test_usingnamespace.zig#}
3852-
3853-
<p>
3854-
{#syntax#}usingnamespace{#endsyntax#} has an important use case when organizing the public
3855-
API of a file or package. For example, one might have <code class="file">c.zig</code> with all of the
3856-
{#link|C imports|Import from C Header File#}:
3857-
</p>
3858-
{#syntax_block|zig|c.zig#}
3859-
pub usingnamespace @cImport({
3860-
@cInclude("epoxy/gl.h");
3861-
@cInclude("GLFW/glfw3.h");
3862-
@cDefine("STBI_ONLY_PNG", "");
3863-
@cDefine("STBI_NO_STDIO", "");
3864-
@cInclude("stb_image.h");
3865-
});
3866-
{#end_syntax_block#}
3867-
<p>
3868-
The above example demonstrates using {#syntax#}pub{#endsyntax#} to qualify the
3869-
{#syntax#}usingnamespace{#endsyntax#} additionally makes the imported declarations
3870-
{#syntax#}pub{#endsyntax#}. This can be used to forward declarations, giving precise control
3871-
over what declarations a given file exposes.
3872-
</p>
3873-
{#header_close#}
3874-
3875-
38763845
{#header_open|comptime#}
38773846
<p>
38783847
Zig places importance on the concept of whether an expression is known at compile-time.
@@ -4279,16 +4248,9 @@ pub fn print(self: *Writer, arg0: []const u8, arg1: i32) !void {
42794248
{#header_close#}
42804249

42814250
{#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>
4251+
<p>Async functions regressed with the release of 0.11.0. The current plan is to
4252+
reintroduce them as a lower level primitive that powers I/O implementations.</p>
4253+
<p>Tracking issue: <a href="https://github.com/ziglang/zig/issues/23446">Proposal: stackless coroutines as low-level primitives</a></p>
42924254
{#header_close#}
42934255

42944256
{#header_open|Builtin Functions|2col#}
@@ -6552,7 +6514,7 @@ fn cmpxchgWeakButNotAtomic(comptime T: type, ptr: *T, expected_value: T, new_val
65526514
</p>
65536515
<ul>
65546516
<li>If a call to {#syntax#}@import{#endsyntax#} is analyzed, the file being imported is analyzed.</li>
6555-
<li>If a type (including a file) is analyzed, all {#syntax#}comptime{#endsyntax#}, {#syntax#}usingnamespace{#endsyntax#}, and {#syntax#}export{#endsyntax#} declarations within it are analyzed.</li>
6517+
<li>If a type (including a file) is analyzed, all {#syntax#}comptime{#endsyntax#} and {#syntax#}export{#endsyntax#} declarations within it are analyzed.</li>
65566518
<li>If a type (including a file) is analyzed, and the compilation is for a {#link|test|Zig Test#}, and the module the type is within is the root module of the compilation, then all {#syntax#}test{#endsyntax#} declarations within it are also analyzed.</li>
65576519
<li>If a reference to a named declaration (i.e. a usage of it) is analyzed, the declaration being referenced is analyzed. Declarations are order-independent, so this reference may be above or below the declaration being referenced, or even in another file entirely.</li>
65586520
</ul>
@@ -7372,29 +7334,6 @@ fn readU32Be() u32 {}
73727334
</ul>
73737335
</td>
73747336
</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>
73987337
<tr>
73997338
<th scope="row">
74007339
<pre>{#syntax#}break{#endsyntax#}</pre>
@@ -7812,18 +7751,6 @@ fn readU32Be() u32 {}
78127751
</ul>
78137752
</td>
78147753
</tr>
7815-
<tr>
7816-
<th scope="row">
7817-
<pre>{#syntax#}usingnamespace{#endsyntax#}</pre>
7818-
</th>
7819-
<td>
7820-
{#syntax#}usingnamespace{#endsyntax#} is a top-level declaration that imports all the public declarations of the operand,
7821-
which must be a struct, union, or enum, into the current scope.
7822-
<ul>
7823-
<li>See also {#link|usingnamespace#}</li>
7824-
</ul>
7825-
</td>
7826-
</tr>
78277754
<tr>
78287755
<th scope="row">
78297756
<pre>{#syntax#}var{#endsyntax#}</pre>
@@ -7893,7 +7820,6 @@ ComptimeDecl <- KEYWORD_comptime Block
78937820
Decl
78947821
<- (KEYWORD_export / KEYWORD_extern STRINGLITERALSINGLE? / KEYWORD_inline / KEYWORD_noinline)? FnProto (SEMICOLON / Block)
78957822
/ (KEYWORD_export / KEYWORD_extern STRINGLITERALSINGLE?)? KEYWORD_threadlocal? GlobalVarDecl
7896-
/ KEYWORD_usingnamespace Expr SEMICOLON
78977823

78987824
FnProto <- KEYWORD_fn IDENTIFIER? LPAREN ParamDeclList RPAREN ByteAlign? AddrSpace? LinkSection? CallConv? EXCLAMATIONMARK? TypeExpr
78997825

@@ -8006,8 +7932,7 @@ TypeExpr <- PrefixTypeOp* ErrorUnionExpr
80067932
ErrorUnionExpr <- SuffixExpr (EXCLAMATIONMARK TypeExpr)?
80077933

80087934
SuffixExpr
8009-
<- KEYWORD_async PrimaryTypeExpr SuffixOp* FnCallArguments
8010-
/ PrimaryTypeExpr (SuffixOp / FnCallArguments)*
7935+
<- PrimaryTypeExpr (SuffixOp / FnCallArguments)*
80117936

80127937
PrimaryTypeExpr
80137938
<- BUILTINIDENTIFIER FnCallArguments
@@ -8183,7 +8108,6 @@ PrefixOp
81838108
/ MINUSPERCENT
81848109
/ AMPERSAND
81858110
/ KEYWORD_try
8186-
/ KEYWORD_await
81878111

81888112
PrefixTypeOp
81898113
<- QUESTIONMARK
@@ -8404,8 +8328,6 @@ KEYWORD_and <- 'and' end_of_word
84048328
KEYWORD_anyframe <- 'anyframe' end_of_word
84058329
KEYWORD_anytype <- 'anytype' end_of_word
84068330
KEYWORD_asm <- 'asm' end_of_word
8407-
KEYWORD_async <- 'async' end_of_word
8408-
KEYWORD_await <- 'await' end_of_word
84098331
KEYWORD_break <- 'break' end_of_word
84108332
KEYWORD_callconv <- 'callconv' end_of_word
84118333
KEYWORD_catch <- 'catch' end_of_word
@@ -8442,14 +8364,13 @@ KEYWORD_threadlocal <- 'threadlocal' end_of_word
84428364
KEYWORD_try <- 'try' end_of_word
84438365
KEYWORD_union <- 'union' end_of_word
84448366
KEYWORD_unreachable <- 'unreachable' end_of_word
8445-
KEYWORD_usingnamespace <- 'usingnamespace' end_of_word
84468367
KEYWORD_var <- 'var' end_of_word
84478368
KEYWORD_volatile <- 'volatile' end_of_word
84488369
KEYWORD_while <- 'while' end_of_word
84498370

84508371
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
8372+
/ KEYWORD_anyframe / KEYWORD_anytype / KEYWORD_asm
8373+
/ KEYWORD_break / KEYWORD_callconv / KEYWORD_catch
84538374
/ KEYWORD_comptime / KEYWORD_const / KEYWORD_continue / KEYWORD_defer
84548375
/ KEYWORD_else / KEYWORD_enum / KEYWORD_errdefer / KEYWORD_error / KEYWORD_export
84558376
/ KEYWORD_extern / KEYWORD_fn / KEYWORD_for / KEYWORD_if
@@ -8458,7 +8379,7 @@ keyword <- KEYWORD_addrspace / KEYWORD_align / KEYWORD_allowzero / KEYWORD_and
84588379
/ KEYWORD_pub / KEYWORD_resume / KEYWORD_return / KEYWORD_linksection
84598380
/ KEYWORD_struct / KEYWORD_suspend / KEYWORD_switch / KEYWORD_test
84608381
/ KEYWORD_threadlocal / KEYWORD_try / KEYWORD_union / KEYWORD_unreachable
8461-
/ KEYWORD_usingnamespace / KEYWORD_var / KEYWORD_volatile / KEYWORD_while
8382+
/ KEYWORD_var / KEYWORD_volatile / KEYWORD_while
84628383
{#end_syntax_block#}
84638384
{#header_close#}
84648385
{#header_open|Zen#}

doc/langref/test_usingnamespace.zig

Lines changed: 0 additions & 8 deletions
This file was deleted.

lib/compiler/reduce/Walk.zig

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -160,12 +160,6 @@ fn walkMember(w: *Walk, decl: Ast.Node.Index) Error!void {
160160
try walkExpression(w, decl);
161161
},
162162

163-
.@"usingnamespace" => {
164-
try w.transformations.append(.{ .delete_node = decl });
165-
const expr = ast.nodeData(decl).node;
166-
try walkExpression(w, expr);
167-
},
168-
169163
.global_var_decl,
170164
.local_var_decl,
171165
.simple_var_decl,
@@ -335,7 +329,6 @@ fn walkExpression(w: *Walk, node: Ast.Node.Index) Error!void {
335329
.address_of,
336330
.@"try",
337331
.@"resume",
338-
.@"await",
339332
.deref,
340333
=> {
341334
return walkExpression(w, ast.nodeData(node).node);
@@ -379,12 +372,8 @@ fn walkExpression(w: *Walk, node: Ast.Node.Index) Error!void {
379372

380373
.call_one,
381374
.call_one_comma,
382-
.async_call_one,
383-
.async_call_one_comma,
384375
.call,
385376
.call_comma,
386-
.async_call,
387-
.async_call_comma,
388377
=> {
389378
var buf: [1]Ast.Node.Index = undefined;
390379
return walkCall(w, ast.fullCall(&buf, node).?);
@@ -525,7 +514,6 @@ fn walkExpression(w: *Walk, node: Ast.Node.Index) Error!void {
525514
.local_var_decl => unreachable,
526515
.simple_var_decl => unreachable,
527516
.aligned_var_decl => unreachable,
528-
.@"usingnamespace" => unreachable,
529517
.test_decl => unreachable,
530518
.asm_output => unreachable,
531519
.asm_input => unreachable,

lib/docs/wasm/Walk.zig

Lines changed: 0 additions & 11 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).?);
@@ -571,7 +567,6 @@ fn struct_decl(
571567
},
572568

573569
.@"comptime",
574-
.@"usingnamespace",
575570
=> try w.expr(&namespace.base, parent_decl, ast.nodeData(member).node),
576571

577572
.test_decl => try w.expr(&namespace.base, parent_decl, ast.nodeData(member).opt_token_and_node[1]),
@@ -643,7 +638,6 @@ fn expr(w: *Walk, scope: *Scope, parent_decl: Decl.Index, node: Ast.Node.Index)
643638
const ast = w.file.get_ast();
644639
switch (ast.nodeTag(node)) {
645640
.root => unreachable, // Top-level declaration.
646-
.@"usingnamespace" => unreachable, // Top-level declaration.
647641
.test_decl => unreachable, // Top-level declaration.
648642
.container_field_init => unreachable, // Top-level declaration.
649643
.container_field_align => unreachable, // Top-level declaration.
@@ -743,7 +737,6 @@ fn expr(w: *Walk, scope: *Scope, parent_decl: Decl.Index, node: Ast.Node.Index)
743737
.@"comptime",
744738
.@"nosuspend",
745739
.@"suspend",
746-
.@"await",
747740
.@"resume",
748741
.@"try",
749742
=> try expr(w, scope, parent_decl, ast.nodeData(node).node),
@@ -806,12 +799,8 @@ fn expr(w: *Walk, scope: *Scope, parent_decl: Decl.Index, node: Ast.Node.Index)
806799

807800
.call_one,
808801
.call_one_comma,
809-
.async_call_one,
810-
.async_call_one_comma,
811802
.call,
812803
.call_comma,
813-
.async_call,
814-
.async_call_comma,
815804
=> {
816805
var buf: [1]Ast.Node.Index = undefined;
817806
const full = ast.fullCall(&buf, node).?;

lib/docs/wasm/html_render.zig

Lines changed: 0 additions & 3 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,
@@ -139,7 +137,6 @@ pub fn fileSourceHtml(
139137
.keyword_try,
140138
.keyword_union,
141139
.keyword_unreachable,
142-
.keyword_usingnamespace,
143140
.keyword_var,
144141
.keyword_volatile,
145142
.keyword_allowzero,

lib/std/Build/Module.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -572,7 +572,7 @@ pub fn appendZigProcessFlags(
572572
try zig_args.append(switch (unwind_tables) {
573573
.none => "-fno-unwind-tables",
574574
.sync => "-funwind-tables",
575-
.@"async" => "-fasync-unwind-tables",
575+
.async => "-fasync-unwind-tables",
576576
});
577577
}
578578

lib/std/Target.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1691,7 +1691,7 @@ pub const Cpu = struct {
16911691
pub fn fromCallingConvention(cc: std.builtin.CallingConvention.Tag) []const Arch {
16921692
return switch (cc) {
16931693
.auto,
1694-
.@"async",
1694+
.async,
16951695
.naked,
16961696
.@"inline",
16971697
=> unreachable,

lib/std/builtin.zig

Lines changed: 3 additions & 14 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`.
@@ -248,7 +246,7 @@ pub const CallingConvention = union(enum(u8)) {
248246
/// The calling convention of a function that can be called with `async` syntax. An `async` call
249247
/// of a runtime-known function must target a function with this calling convention.
250248
/// Comptime-known functions with other calling conventions may be coerced to this one.
251-
@"async",
249+
async,
252250

253251
/// Functions with this calling convention have no prologue or epilogue, making the function
254252
/// uncallable in regular Zig code. This can be useful when integrating with assembly.
@@ -851,7 +849,7 @@ pub const LinkMode = enum {
851849
pub const UnwindTables = enum {
852850
none,
853851
sync,
854-
@"async",
852+
async,
855853
};
856854

857855
/// This data structure is used by the Zig language code generation and
@@ -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,

0 commit comments

Comments
 (0)