Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -460,8 +460,8 @@ pub fn build(b: *std.Build) !void {
.skip_linux = skip_linux,
.skip_llvm = skip_llvm,
.skip_libc = skip_libc,
// 2923515904 was observed on an x86_64-linux-gnu host.
.max_rss = 3100000000,
// 3888779264 was observed on an x86_64-linux-gnu host.
.max_rss = 4000000000,
}));

test_modules_step.dependOn(tests.addModuleTests(b, .{
Expand Down
95 changes: 8 additions & 87 deletions doc/langref.html.in
Original file line number Diff line number Diff line change
Expand Up @@ -3842,37 +3842,6 @@ void do_a_thing(struct Foo *foo) {
{#header_close#}
{#header_close#}

{#header_open|usingnamespace#}
<p>
{#syntax#}usingnamespace{#endsyntax#} is a declaration that mixes all the public
declarations of the operand, which must be a {#link|struct#}, {#link|union#}, {#link|enum#},
or {#link|opaque#}, into the namespace:
</p>
{#code|test_usingnamespace.zig#}

<p>
{#syntax#}usingnamespace{#endsyntax#} has an important use case when organizing the public
API of a file or package. For example, one might have <code class="file">c.zig</code> with all of the
{#link|C imports|Import from C Header File#}:
</p>
{#syntax_block|zig|c.zig#}
pub usingnamespace @cImport({
@cInclude("epoxy/gl.h");
@cInclude("GLFW/glfw3.h");
@cDefine("STBI_ONLY_PNG", "");
@cDefine("STBI_NO_STDIO", "");
@cInclude("stb_image.h");
});
{#end_syntax_block#}
<p>
The above example demonstrates using {#syntax#}pub{#endsyntax#} to qualify the
{#syntax#}usingnamespace{#endsyntax#} additionally makes the imported declarations
{#syntax#}pub{#endsyntax#}. This can be used to forward declarations, giving precise control
over what declarations a given file exposes.
</p>
{#header_close#}


{#header_open|comptime#}
<p>
Zig places importance on the concept of whether an expression is known at compile-time.
Expand Down Expand Up @@ -4279,16 +4248,9 @@ pub fn print(self: *Writer, arg0: []const u8, arg1: i32) !void {
{#header_close#}

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

{#header_open|Builtin Functions|2col#}
Expand Down Expand Up @@ -6552,7 +6514,7 @@ fn cmpxchgWeakButNotAtomic(comptime T: type, ptr: *T, expected_value: T, new_val
</p>
<ul>
<li>If a call to {#syntax#}@import{#endsyntax#} is analyzed, the file being imported is analyzed.</li>
<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>
<li>If a type (including a file) is analyzed, all {#syntax#}comptime{#endsyntax#} and {#syntax#}export{#endsyntax#} declarations within it are analyzed.</li>
<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>
<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>
</ul>
Expand Down Expand Up @@ -7372,29 +7334,6 @@ fn readU32Be() u32 {}
</ul>
</td>
</tr>
<tr>
<th scope="row">
<pre>{#syntax#}async{#endsyntax#}</pre>
</th>
<td>
{#syntax#}async{#endsyntax#} can be used before a function call to get a pointer to the function's frame when it suspends.
<ul>
<li>See also {#link|Async Functions#}</li>
</ul>
</td>
</tr>
<tr>
<th scope="row">
<pre>{#syntax#}await{#endsyntax#}</pre>
</th>
<td>
{#syntax#}await{#endsyntax#} can be used to suspend the current function until the frame provided after the {#syntax#}await{#endsyntax#} completes.
{#syntax#}await{#endsyntax#} copies the value returned from the target function's frame to the caller.
<ul>
<li>See also {#link|Async Functions#}</li>
</ul>
</td>
</tr>
<tr>
<th scope="row">
<pre>{#syntax#}break{#endsyntax#}</pre>
Expand Down Expand Up @@ -7812,18 +7751,6 @@ fn readU32Be() u32 {}
</ul>
</td>
</tr>
<tr>
<th scope="row">
<pre>{#syntax#}usingnamespace{#endsyntax#}</pre>
</th>
<td>
{#syntax#}usingnamespace{#endsyntax#} is a top-level declaration that imports all the public declarations of the operand,
which must be a struct, union, or enum, into the current scope.
<ul>
<li>See also {#link|usingnamespace#}</li>
</ul>
</td>
</tr>
<tr>
<th scope="row">
<pre>{#syntax#}var{#endsyntax#}</pre>
Expand Down Expand Up @@ -7893,7 +7820,6 @@ ComptimeDecl <- KEYWORD_comptime Block
Decl
<- (KEYWORD_export / KEYWORD_extern STRINGLITERALSINGLE? / KEYWORD_inline / KEYWORD_noinline)? FnProto (SEMICOLON / Block)
/ (KEYWORD_export / KEYWORD_extern STRINGLITERALSINGLE?)? KEYWORD_threadlocal? GlobalVarDecl
/ KEYWORD_usingnamespace Expr SEMICOLON

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

Expand Down Expand Up @@ -8006,8 +7932,7 @@ TypeExpr <- PrefixTypeOp* ErrorUnionExpr
ErrorUnionExpr <- SuffixExpr (EXCLAMATIONMARK TypeExpr)?

SuffixExpr
<- KEYWORD_async PrimaryTypeExpr SuffixOp* FnCallArguments
/ PrimaryTypeExpr (SuffixOp / FnCallArguments)*
<- PrimaryTypeExpr (SuffixOp / FnCallArguments)*

PrimaryTypeExpr
<- BUILTINIDENTIFIER FnCallArguments
Expand Down Expand Up @@ -8183,7 +8108,6 @@ PrefixOp
/ MINUSPERCENT
/ AMPERSAND
/ KEYWORD_try
/ KEYWORD_await

PrefixTypeOp
<- QUESTIONMARK
Expand Down Expand Up @@ -8404,8 +8328,6 @@ KEYWORD_and <- 'and' end_of_word
KEYWORD_anyframe <- 'anyframe' end_of_word
KEYWORD_anytype <- 'anytype' end_of_word
KEYWORD_asm <- 'asm' end_of_word
KEYWORD_async <- 'async' end_of_word
KEYWORD_await <- 'await' end_of_word
KEYWORD_break <- 'break' end_of_word
KEYWORD_callconv <- 'callconv' end_of_word
KEYWORD_catch <- 'catch' end_of_word
Expand Down Expand Up @@ -8442,14 +8364,13 @@ KEYWORD_threadlocal <- 'threadlocal' end_of_word
KEYWORD_try <- 'try' end_of_word
KEYWORD_union <- 'union' end_of_word
KEYWORD_unreachable <- 'unreachable' end_of_word
KEYWORD_usingnamespace <- 'usingnamespace' end_of_word
KEYWORD_var <- 'var' end_of_word
KEYWORD_volatile <- 'volatile' end_of_word
KEYWORD_while <- 'while' end_of_word

keyword <- KEYWORD_addrspace / KEYWORD_align / KEYWORD_allowzero / KEYWORD_and
/ KEYWORD_anyframe / KEYWORD_anytype / KEYWORD_asm / KEYWORD_async
/ KEYWORD_await / KEYWORD_break / KEYWORD_callconv / KEYWORD_catch
/ KEYWORD_anyframe / KEYWORD_anytype / KEYWORD_asm
/ KEYWORD_break / KEYWORD_callconv / KEYWORD_catch
/ KEYWORD_comptime / KEYWORD_const / KEYWORD_continue / KEYWORD_defer
/ KEYWORD_else / KEYWORD_enum / KEYWORD_errdefer / KEYWORD_error / KEYWORD_export
/ KEYWORD_extern / KEYWORD_fn / KEYWORD_for / KEYWORD_if
Expand All @@ -8458,7 +8379,7 @@ keyword <- KEYWORD_addrspace / KEYWORD_align / KEYWORD_allowzero / KEYWORD_and
/ KEYWORD_pub / KEYWORD_resume / KEYWORD_return / KEYWORD_linksection
/ KEYWORD_struct / KEYWORD_suspend / KEYWORD_switch / KEYWORD_test
/ KEYWORD_threadlocal / KEYWORD_try / KEYWORD_union / KEYWORD_unreachable
/ KEYWORD_usingnamespace / KEYWORD_var / KEYWORD_volatile / KEYWORD_while
/ KEYWORD_var / KEYWORD_volatile / KEYWORD_while
{#end_syntax_block#}
{#header_close#}
{#header_open|Zen#}
Expand Down
8 changes: 0 additions & 8 deletions doc/langref/test_usingnamespace.zig

This file was deleted.

12 changes: 0 additions & 12 deletions lib/compiler/reduce/Walk.zig
Original file line number Diff line number Diff line change
Expand Up @@ -160,12 +160,6 @@ fn walkMember(w: *Walk, decl: Ast.Node.Index) Error!void {
try walkExpression(w, decl);
},

.@"usingnamespace" => {
try w.transformations.append(.{ .delete_node = decl });
const expr = ast.nodeData(decl).node;
try walkExpression(w, expr);
},

.global_var_decl,
.local_var_decl,
.simple_var_decl,
Expand Down Expand Up @@ -335,7 +329,6 @@ fn walkExpression(w: *Walk, node: Ast.Node.Index) Error!void {
.address_of,
.@"try",
.@"resume",
.@"await",
.deref,
=> {
return walkExpression(w, ast.nodeData(node).node);
Expand Down Expand Up @@ -379,12 +372,8 @@ fn walkExpression(w: *Walk, node: Ast.Node.Index) Error!void {

.call_one,
.call_one_comma,
.async_call_one,
.async_call_one_comma,
.call,
.call_comma,
.async_call,
.async_call_comma,
=> {
var buf: [1]Ast.Node.Index = undefined;
return walkCall(w, ast.fullCall(&buf, node).?);
Expand Down Expand Up @@ -525,7 +514,6 @@ fn walkExpression(w: *Walk, node: Ast.Node.Index) Error!void {
.local_var_decl => unreachable,
.simple_var_decl => unreachable,
.aligned_var_decl => unreachable,
.@"usingnamespace" => unreachable,
.test_decl => unreachable,
.asm_output => unreachable,
.asm_input => unreachable,
Expand Down
11 changes: 0 additions & 11 deletions lib/docs/wasm/Walk.zig
Original file line number Diff line number Diff line change
Expand Up @@ -238,12 +238,8 @@ pub const File = struct {

.call_one,
.call_one_comma,
.async_call_one,
.async_call_one_comma,
.call,
.call_comma,
.async_call,
.async_call_comma,
=> {
var buf: [1]Ast.Node.Index = undefined;
return categorize_call(file_index, node, ast.fullCall(&buf, node).?);
Expand Down Expand Up @@ -571,7 +567,6 @@ fn struct_decl(
},

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

.test_decl => try w.expr(&namespace.base, parent_decl, ast.nodeData(member).opt_token_and_node[1]),
Expand Down Expand Up @@ -643,7 +638,6 @@ fn expr(w: *Walk, scope: *Scope, parent_decl: Decl.Index, node: Ast.Node.Index)
const ast = w.file.get_ast();
switch (ast.nodeTag(node)) {
.root => unreachable, // Top-level declaration.
.@"usingnamespace" => unreachable, // Top-level declaration.
.test_decl => unreachable, // Top-level declaration.
.container_field_init => unreachable, // Top-level declaration.
.container_field_align => unreachable, // Top-level declaration.
Expand Down Expand Up @@ -743,7 +737,6 @@ fn expr(w: *Walk, scope: *Scope, parent_decl: Decl.Index, node: Ast.Node.Index)
.@"comptime",
.@"nosuspend",
.@"suspend",
.@"await",
.@"resume",
.@"try",
=> try expr(w, scope, parent_decl, ast.nodeData(node).node),
Expand Down Expand Up @@ -806,12 +799,8 @@ fn expr(w: *Walk, scope: *Scope, parent_decl: Decl.Index, node: Ast.Node.Index)

.call_one,
.call_one_comma,
.async_call_one,
.async_call_one_comma,
.call,
.call_comma,
.async_call,
.async_call_comma,
=> {
var buf: [1]Ast.Node.Index = undefined;
const full = ast.fullCall(&buf, node).?;
Expand Down
3 changes: 0 additions & 3 deletions lib/docs/wasm/html_render.zig
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,6 @@ pub fn fileSourceHtml(
.keyword_align,
.keyword_and,
.keyword_asm,
.keyword_async,
.keyword_await,
.keyword_break,
.keyword_catch,
.keyword_comptime,
Expand Down Expand Up @@ -139,7 +137,6 @@ pub fn fileSourceHtml(
.keyword_try,
.keyword_union,
.keyword_unreachable,
.keyword_usingnamespace,
.keyword_var,
.keyword_volatile,
.keyword_allowzero,
Expand Down
2 changes: 1 addition & 1 deletion lib/std/Build/Module.zig
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,7 @@ pub fn appendZigProcessFlags(
try zig_args.append(switch (unwind_tables) {
.none => "-fno-unwind-tables",
.sync => "-funwind-tables",
.@"async" => "-fasync-unwind-tables",
.async => "-fasync-unwind-tables",
});
}

Expand Down
2 changes: 1 addition & 1 deletion lib/std/Target.zig
Original file line number Diff line number Diff line change
Expand Up @@ -1691,7 +1691,7 @@ pub const Cpu = struct {
pub fn fromCallingConvention(cc: std.builtin.CallingConvention.Tag) []const Arch {
return switch (cc) {
.auto,
.@"async",
.async,
.naked,
.@"inline",
=> unreachable,
Expand Down
17 changes: 3 additions & 14 deletions lib/std/builtin.zig
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,6 @@ pub const CallingConvention = union(enum(u8)) {
pub const C: CallingConvention = .c;
/// Deprecated; use `.naked`.
pub const Naked: CallingConvention = .naked;
/// Deprecated; use `.@"async"`.
pub const Async: CallingConvention = .@"async";
/// Deprecated; use `.@"inline"`.
pub const Inline: CallingConvention = .@"inline";
/// Deprecated; use `.x86_64_interrupt`, `.x86_interrupt`, or `.avr_interrupt`.
Expand Down Expand Up @@ -248,7 +246,7 @@ pub const CallingConvention = union(enum(u8)) {
/// The calling convention of a function that can be called with `async` syntax. An `async` call
/// of a runtime-known function must target a function with this calling convention.
/// Comptime-known functions with other calling conventions may be coerced to this one.
@"async",
async,
Comment on lines 246 to +249
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since you're doing a zig1.wasm update anyway, maybe worth taking the opportunity to remove this?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That very likely will need to stay no matter how #23446 is resolved.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That proposal says:

An async function must have callconv(.auto).

That's what made me think that CallingConvention.async would go away, since this is explicitly unlike inline and callconv(.@"inline") which are both allowed and equivalent. cc @mlugg

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I doubt that proposal will be accepted as-is.


/// Functions with this calling convention have no prologue or epilogue, making the function
/// uncallable in regular Zig code. This can be useful when integrating with assembly.
Expand Down Expand Up @@ -851,7 +849,7 @@ pub const LinkMode = enum {
pub const UnwindTables = enum {
none,
sync,
@"async",
async,
};

/// This data structure is used by the Zig language code generation and
Expand All @@ -866,32 +864,23 @@ pub const WasiExecModel = enum {
pub const CallModifier = enum {
/// Equivalent to function call syntax.
auto,

/// Equivalent to async keyword used with function call syntax.
async_kw,

/// Prevents tail call optimization. This guarantees that the return
/// address will point to the callsite, as opposed to the callsite's
/// callsite. If the call is otherwise required to be tail-called
/// or inlined, a compile error is emitted instead.
never_tail,

/// Guarantees that the call will not be inlined. If the call is
/// otherwise required to be inlined, a compile error is emitted instead.
never_inline,

/// Asserts that the function call will not suspend. This allows a
/// non-async function to call an async function.
no_async,

no_suspend,
/// Guarantees that the call will be generated with tail call optimization.
/// If this is not possible, a compile error is emitted instead.
always_tail,

/// Guarantees that the call will be inlined at the callsite.
/// If this is not possible, a compile error is emitted instead.
always_inline,

/// Evaluates the call at compile-time. If the call cannot be completed at
/// compile-time, a compile error is emitted instead.
compile_time,
Expand Down
Loading