Update for -master
fn_proto.extern_export_token -> fn_proto.extern_export_inline_token And update the data by the way.
This commit is contained in:
parent
b33cb8fc0d
commit
df9560db51
@ -41,9 +41,9 @@ pub const builtins = [_]Builtin{
|
||||
.documentation =
|
||||
\\ This function returns the number of bytes that this type should be aligned to for the current target to match the C ABI. When the child type of a pointer has this alignment, the alignment can be omitted from the type.
|
||||
\\```zig
|
||||
\\const expect = @import("std").testing.expect;
|
||||
\\const expect = @import("std").debug.assert;
|
||||
\\comptime {
|
||||
\\ expect(*u32 == *align(@alignOf(u32)) u32);
|
||||
\\ assert(*u32 == *align(@alignOf(u32)) u32);
|
||||
\\}
|
||||
\\```
|
||||
\\ The result is a target-specific compile time constant. It is guaranteed to be less than or equal to @sizeOf(T).
|
||||
@ -85,15 +85,15 @@ pub const builtins = [_]Builtin{
|
||||
\\ var foo = Foo{ .bar = func };
|
||||
\\ var bytes: [64]u8 align(@alignOf(@Frame(func))) = undefined;
|
||||
\\ const f = @asyncCall(&bytes, {}, foo.bar, .{&data});
|
||||
\\ expect(data == 2);
|
||||
\\ try expect(data == 2);
|
||||
\\ resume f;
|
||||
\\ expect(data == 4);
|
||||
\\ try expect(data == 4);
|
||||
\\}
|
||||
\\
|
||||
\\fn func(y: *i32) void {
|
||||
\\ defer y.* += 2;
|
||||
\\ y.* += 1;
|
||||
\\ suspend;
|
||||
\\ suspend {}
|
||||
\\}
|
||||
\\```
|
||||
\\```zig
|
||||
@ -286,7 +286,7 @@ pub const builtins = [_]Builtin{
|
||||
\\const expect = @import("std").testing.expect;
|
||||
\\
|
||||
\\test "noinline function call" {
|
||||
\\ expect(@call(.{}, add, .{3, 9}) == 12);
|
||||
\\ try expect(@call(.{}, add, .{3, 9}) == 12);
|
||||
\\}
|
||||
\\
|
||||
\\fn add(a: i32, b: i32) i32 {
|
||||
@ -688,11 +688,11 @@ pub const builtins = [_]Builtin{
|
||||
},
|
||||
.{
|
||||
.name = "@export",
|
||||
.signature = "@export(target: anytype, comptime options: std.builtin.ExportOptions) void",
|
||||
.snippet = "@export(${1:target: anytype}, ${2:comptime options: std.builtin.ExportOptions})",
|
||||
.signature = "@export(identifier, comptime options: std.builtin.ExportOptions) void",
|
||||
.snippet = "@export(${1:identifier}, ${2:comptime options: std.builtin.ExportOptions})",
|
||||
.documentation =
|
||||
\\ Creates a symbol in the output object file.
|
||||
\\ This function can be called from a comptime block to conditionally export symbols. When target is a function with the C calling convention and options.linkage is Strong, this is equivalent to the export keyword used on a function:
|
||||
\\ This function can be called from a comptime block to conditionally export symbols. When identifier is a function with the C calling convention and options.linkage is Strong, this is equivalent to the export keyword used on a function:
|
||||
\\test.zig
|
||||
\\```zig
|
||||
\\comptime {
|
||||
@ -726,17 +726,29 @@ pub const builtins = [_]Builtin{
|
||||
\\```
|
||||
,
|
||||
.arguments = &.{
|
||||
"target: anytype",
|
||||
"identifier",
|
||||
"comptime options: std.builtin.ExportOptions",
|
||||
},
|
||||
},
|
||||
.{
|
||||
.name = "@extern",
|
||||
.signature = "@extern(T: type, comptime options: std.builtin.ExternOptions) *T",
|
||||
.snippet = "@extern(${1:T: type}, ${2:comptime options: std.builtin.ExternOptions})",
|
||||
.documentation =
|
||||
\\ Creates a reference to an external symbol in the output object file.
|
||||
,
|
||||
.arguments = &.{
|
||||
"T: type",
|
||||
"comptime options: std.builtin.ExternOptions",
|
||||
},
|
||||
},
|
||||
.{
|
||||
.name = "@fence",
|
||||
.signature = "@fence(order: AtomicOrder)",
|
||||
.snippet = "@fence(${1:order: AtomicOrder})",
|
||||
.documentation =
|
||||
\\ The fence function is used to introduce happens-before edges between operations.
|
||||
\\ AtomicOrder can be found with @import("builtin").AtomicOrder.
|
||||
\\ AtomicOrder can be found with @import("std").builtin.AtomicOrder.
|
||||
,
|
||||
.arguments = &.{
|
||||
"order: AtomicOrder",
|
||||
@ -766,17 +778,17 @@ pub const builtins = [_]Builtin{
|
||||
\\ @field(p, "x") = 4;
|
||||
\\ @field(p, "y") = @field(p, "x") + 1;
|
||||
\\
|
||||
\\ expect(@field(p, "x") == 4);
|
||||
\\ expect(@field(p, "y") == 5);
|
||||
\\ try expect(@field(p, "x") == 4);
|
||||
\\ try expect(@field(p, "y") == 5);
|
||||
\\}
|
||||
\\
|
||||
\\test "decl access by string" {
|
||||
\\ const expect = std.testing.expect;
|
||||
\\
|
||||
\\ expect(@field(Point, "z") == 1);
|
||||
\\ try expect(@field(Point, "z") == 1);
|
||||
\\
|
||||
\\ @field(Point, "z") = 2;
|
||||
\\ expect(@field(Point, "z") == 2);
|
||||
\\ try expect(@field(Point, "z") == 2);
|
||||
\\}
|
||||
\\```
|
||||
\\```zig
|
||||
@ -858,7 +870,7 @@ pub const builtins = [_]Builtin{
|
||||
\\}
|
||||
\\
|
||||
\\fn func() void {
|
||||
\\ suspend;
|
||||
\\ suspend {}
|
||||
\\}
|
||||
\\```
|
||||
\\```zig
|
||||
@ -913,16 +925,16 @@ pub const builtins = [_]Builtin{
|
||||
\\};
|
||||
\\
|
||||
\\test "@hasDecl" {
|
||||
\\ expect(@hasDecl(Foo, "blah"));
|
||||
\\ try expect(@hasDecl(Foo, "blah"));
|
||||
\\
|
||||
\\ // Even though `hi` is private, @hasDecl returns true because this test is
|
||||
\\ // in the same file scope as Foo. It would return false if Foo was declared
|
||||
\\ // in a different file.
|
||||
\\ expect(@hasDecl(Foo, "hi"));
|
||||
\\ try expect(@hasDecl(Foo, "hi"));
|
||||
\\
|
||||
\\ // @hasDecl is for declarations; not fields.
|
||||
\\ expect(!@hasDecl(Foo, "nope"));
|
||||
\\ expect(!@hasDecl(Foo, "nope1234"));
|
||||
\\ try expect(!@hasDecl(Foo, "nope"));
|
||||
\\ try expect(!@hasDecl(Foo, "nope1234"));
|
||||
\\}
|
||||
\\```
|
||||
\\```zig
|
||||
@ -1099,24 +1111,24 @@ pub const builtins = [_]Builtin{
|
||||
\\test.zig
|
||||
\\```zig
|
||||
\\const std = @import("std");
|
||||
\\const builtin = @import("builtin");
|
||||
\\const native_arch = @import("builtin").target.cpu.arch;
|
||||
\\const expect = std.testing.expect;
|
||||
\\
|
||||
\\test "@wasmMemoryGrow" {
|
||||
\\ if (builtin.arch != .wasm32) return error.SkipZigTest;
|
||||
\\ if (native_arch != .wasm32) return error.SkipZigTest;
|
||||
\\
|
||||
\\ var prev = @wasmMemorySize(0);
|
||||
\\ expect(prev == @wasmMemoryGrow(0, 1));
|
||||
\\ expect(prev + 1 == @wasmMemorySize(0));
|
||||
\\ try expect(prev == @wasmMemoryGrow(0, 1));
|
||||
\\ try expect(prev + 1 == @wasmMemorySize(0));
|
||||
\\}
|
||||
\\```
|
||||
\\```zig
|
||||
\\$ zig test test.zig
|
||||
\\Test [1/1] test "@wasmMemoryGrow"...
|
||||
\\Test [2/1]
|
||||
\\test "@wasmMemoryGrow"...SKIP
|
||||
\\test "@wasmMemoryGrow"... SKIP
|
||||
\\
|
||||
\\0 passed; 1 skipped.
|
||||
\\0 passed; 1 skipped; 0 failed.
|
||||
\\
|
||||
\\```
|
||||
,
|
||||
@ -1297,8 +1309,8 @@ pub const builtins = [_]Builtin{
|
||||
},
|
||||
.{
|
||||
.name = "@setFloatMode",
|
||||
.signature = "@setFloatMode(mode: @import(\"builtin\").FloatMode)",
|
||||
.snippet = "@setFloatMode(${1:mode: @import(\"builtin\").FloatMode})",
|
||||
.signature = "@setFloatMode(mode: @import(\"std\").builtin.FloatMode)",
|
||||
.snippet = "@setFloatMode(${1:mode: @import(\"std\").builtin.FloatMode})",
|
||||
.documentation =
|
||||
\\ Sets the floating point mode of the current scope. Possible values are:
|
||||
\\```zig
|
||||
@ -1309,7 +1321,7 @@ pub const builtins = [_]Builtin{
|
||||
\\```
|
||||
,
|
||||
.arguments = &.{
|
||||
"mode: @import(\"builtin\").FloatMode",
|
||||
"mode: @import(\"std\").builtin.FloatMode",
|
||||
},
|
||||
},
|
||||
.{
|
||||
@ -1343,11 +1355,11 @@ pub const builtins = [_]Builtin{
|
||||
\\}
|
||||
\\```
|
||||
\\```zig
|
||||
\\$ zig test test.zig-OReleaseFast
|
||||
\\$ zig test test.zig -OReleaseFast
|
||||
\\Test [1/1] test "@setRuntimeSafety"...
|
||||
\\thread 7231 panic: integer overflow
|
||||
\\thread 2249 panic: integer overflow
|
||||
\\error: the following test command crashed:
|
||||
\\docgen_tmp/zig-cache/o/bf9779abe0368bc4173421d2d186e9cc/test /home/vsts/work/1/s/build/release/bin/zig
|
||||
\\docgen_tmp/zig-cache/o/3614c34b7ba202963f2b48ba99496d46/test /home/vsts/work/1/s/build/release/bin/zig
|
||||
\\
|
||||
\\```
|
||||
\\Note: it is planned to replace @setRuntimeSafety with @optimizeFor
|
||||
@ -1443,8 +1455,8 @@ pub const builtins = [_]Builtin{
|
||||
\\test "vector @splat" {
|
||||
\\ const scalar: u32 = 5;
|
||||
\\ const result = @splat(4, scalar);
|
||||
\\ comptime expect(@TypeOf(result) == std.meta.Vector(4, u32));
|
||||
\\ expect(std.mem.eql(u32, &@as([4]u32, result), &[_]u32{ 5, 5, 5, 5 }));
|
||||
\\ comptime try expect(@TypeOf(result) == std.meta.Vector(4, u32));
|
||||
\\ try expect(std.mem.eql(u32, &@as([4]u32, result), &[_]u32{ 5, 5, 5, 5 }));
|
||||
\\}
|
||||
\\```
|
||||
\\```zig
|
||||
@ -1463,14 +1475,14 @@ pub const builtins = [_]Builtin{
|
||||
},
|
||||
.{
|
||||
.name = "@reduce",
|
||||
.signature = "@reduce(comptime op: builtin.ReduceOp, value: anytype) std.meta.Child(value)",
|
||||
.snippet = "@reduce(${1:comptime op: builtin.ReduceOp}, ${2:value: anytype})",
|
||||
.signature = "@reduce(comptime op: std.builtin.ReduceOp, value: anytype) std.meta.Child(value)",
|
||||
.snippet = "@reduce(${1:comptime op: std.builtin.ReduceOp}, ${2:value: anytype})",
|
||||
.documentation =
|
||||
\\ Transforms a vector into a scalar value by performing a sequential horizontal reduction of its elements using the specified operator op.
|
||||
\\ Not every operator is available for every vector element type:
|
||||
,
|
||||
.arguments = &.{
|
||||
"comptime op: builtin.ReduceOp",
|
||||
"comptime op: std.builtin.ReduceOp",
|
||||
"value: anytype",
|
||||
},
|
||||
},
|
||||
@ -1486,16 +1498,16 @@ pub const builtins = [_]Builtin{
|
||||
\\const expect = std.testing.expect;
|
||||
\\
|
||||
\\test "@src" {
|
||||
\\ doTheTest();
|
||||
\\ try doTheTest();
|
||||
\\}
|
||||
\\
|
||||
\\fn doTheTest() void {
|
||||
\\fn doTheTest() !void {
|
||||
\\ const src = @src();
|
||||
\\
|
||||
\\ expect(src.line == 9);
|
||||
\\ expect(src.column == 17);
|
||||
\\ expect(std.mem.endsWith(u8, src.fn_name, "doTheTest"));
|
||||
\\ expect(std.mem.endsWith(u8, src.file, "test.zig"));
|
||||
\\ try expect(src.line == 9);
|
||||
\\ try expect(src.column == 17);
|
||||
\\ try expect(std.mem.endsWith(u8, src.fn_name, "doTheTest"));
|
||||
\\ try expect(std.mem.endsWith(u8, src.file, "test.zig"));
|
||||
\\}
|
||||
\\```
|
||||
\\```zig
|
||||
@ -1704,7 +1716,7 @@ pub const builtins = [_]Builtin{
|
||||
\\test "@This()" {
|
||||
\\ var items = [_]i32{ 1, 2, 3, 4 };
|
||||
\\ const list = List(i32){ .items = items[0..] };
|
||||
\\ expect(list.length() == 4);
|
||||
\\ try expect(list.length() == 4);
|
||||
\\}
|
||||
\\
|
||||
\\fn List(comptime T: type) type {
|
||||
@ -1747,21 +1759,27 @@ pub const builtins = [_]Builtin{
|
||||
\\```zig
|
||||
\\$ zig test test.zig
|
||||
\\Test [1/1] test "integer cast panic"...
|
||||
\\thread 7274 panic: integer cast truncated bits
|
||||
\\/home/vsts/work/1/s/docgen_tmp/test.zig:3:17: 0x2065c5 in test "integer cast panic" (test)
|
||||
\\thread 2296 panic: integer cast truncated bits
|
||||
\\/home/vsts/work/1/s/docgen_tmp/test.zig:3:17: 0x206765 in test "integer cast panic" (test)
|
||||
\\ var b: u8 = @intCast(u8, a);
|
||||
\\ ^
|
||||
\\/home/vsts/work/1/s/build/release/lib/zig/std/special/test_runner.zig:69:28: 0x2302a8 in std.special.main (test)
|
||||
\\/home/vsts/work/1/s/build/release/lib/zig/std/special/test_runner.zig:76:28: 0x22cb5a in std.special.main (test)
|
||||
\\ } else test_fn.func();
|
||||
\\ ^
|
||||
\\/home/vsts/work/1/s/build/release/lib/zig/std/start.zig:345:37: 0x207db4 in std.start.posixCallMainAndExit (test)
|
||||
\\/home/vsts/work/1/s/build/release/lib/zig/std/start.zig:458:37: 0x2256da in std.start.callMain (test)
|
||||
\\ const result = root.main() catch |err| {
|
||||
\\ ^
|
||||
\\/home/vsts/work/1/s/build/release/lib/zig/std/start.zig:163:5: 0x207c52 in std.start._start (test)
|
||||
\\/home/vsts/work/1/s/build/release/lib/zig/std/start.zig:400:12: 0x2094fe in std.start.callMainWithArgs (test)
|
||||
\\ return @call(.{ .modifier = .always_inline }, callMain, .{});
|
||||
\\ ^
|
||||
\\/home/vsts/work/1/s/build/release/lib/zig/std/start.zig:318:17: 0x2084e5 in std.start.posixCallMainAndExit (test)
|
||||
\\ std.os.exit(@call(.{ .modifier = .always_inline }, callMainWithArgs, .{ argc, argv, envp }));
|
||||
\\ ^
|
||||
\\/home/vsts/work/1/s/build/release/lib/zig/std/start.zig:244:5: 0x208242 in std.start._start (test)
|
||||
\\ @call(.{ .modifier = .never_inline }, posixCallMainAndExit, .{});
|
||||
\\ ^
|
||||
\\error: the following test command crashed:
|
||||
\\docgen_tmp/zig-cache/o/789dbe08efb95c9a17f8c387b692b9c1/test /home/vsts/work/1/s/build/release/bin/zig
|
||||
\\docgen_tmp/zig-cache/o/b7cb2795577843c305414be65d066ae2/test /home/vsts/work/1/s/build/release/bin/zig
|
||||
\\
|
||||
\\```
|
||||
\\ However this is well defined and working code:
|
||||
@ -1773,7 +1791,7 @@ pub const builtins = [_]Builtin{
|
||||
\\test "integer truncation" {
|
||||
\\ var a: u16 = 0xabcd;
|
||||
\\ var b: u8 = @truncate(u8, a);
|
||||
\\ expect(b == 0xcd);
|
||||
\\ try expect(b == 0xcd);
|
||||
\\}
|
||||
\\```
|
||||
\\```zig
|
||||
@ -1792,19 +1810,19 @@ pub const builtins = [_]Builtin{
|
||||
},
|
||||
.{
|
||||
.name = "@Type",
|
||||
.signature = "@Type(comptime info: @import(\"builtin\").TypeInfo) type",
|
||||
.snippet = "@Type(${1:comptime info: @import(\"builtin\").TypeInfo})",
|
||||
.signature = "@Type(comptime info: std.builtin.TypeInfo) type",
|
||||
.snippet = "@Type(${1:comptime info: std.builtin.TypeInfo})",
|
||||
.documentation =
|
||||
\\ This function is the inverse of @typeInfo. It reifies type information into a type.
|
||||
\\ It is available for the following types:
|
||||
,
|
||||
.arguments = &.{
|
||||
"comptime info: @import(\"builtin\").TypeInfo",
|
||||
"comptime info: std.builtin.TypeInfo",
|
||||
},
|
||||
},
|
||||
.{
|
||||
.name = "@typeInfo",
|
||||
.signature = "@typeInfo(comptime T: type) @import(\"std\").builtin.TypeInfo",
|
||||
.signature = "@typeInfo(comptime T: type) std.builtin.TypeInfo",
|
||||
.snippet = "@typeInfo(${1:comptime T: type})",
|
||||
.documentation =
|
||||
\\ Provides type reflection.
|
||||
@ -1840,8 +1858,8 @@ pub const builtins = [_]Builtin{
|
||||
\\test "no runtime side effects" {
|
||||
\\ var data: i32 = 0;
|
||||
\\ const T = @TypeOf(foo(i32, &data));
|
||||
\\ comptime expect(T == i32);
|
||||
\\ expect(data == 0);
|
||||
\\ comptime try expect(T == i32);
|
||||
\\ try expect(data == 0);
|
||||
\\}
|
||||
\\
|
||||
\\fn foo(comptime T: type, ptr: *T) T {
|
||||
|
@ -243,7 +243,7 @@ fn publishDiagnostics(arena: *std.heap.ArenaAllocator, handle: DocumentStore.Han
|
||||
=> blk: {
|
||||
var buf: [1]std.zig.ast.Node.Index = undefined;
|
||||
const func = analysis.fnProto(tree, decl_idx, &buf).?;
|
||||
if (func.extern_export_token != null) break :blk;
|
||||
if (func.extern_export_inline_token != null) break :blk;
|
||||
|
||||
if (config.warn_style) {
|
||||
if (func.name_token) |name_token| {
|
||||
|
@ -455,7 +455,7 @@ fn writeNodeTokens(
|
||||
try writeDocComments(builder, tree, docs);
|
||||
|
||||
try writeToken(builder, fn_proto.visib_token, .keyword);
|
||||
try writeToken(builder, fn_proto.extern_export_token, .keyword);
|
||||
try writeToken(builder, fn_proto.extern_export_inline_token, .keyword);
|
||||
try writeToken(builder, fn_proto.lib_name, .string);
|
||||
try writeToken(builder, fn_proto.ast.fn_token, .keyword);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user