diff options
| author | r00ster91 <r00ster91@proton.me> | 2023-07-04 10:34:31 -0400 |
|---|---|---|
| committer | Veikka Tuominen <git@vexu.eu> | 2023-09-19 15:15:05 +0300 |
| commit | ee4ced96833470f9432e6a5dc5b31534457280c0 (patch) | |
| tree | 8d35dc654895f029e23ce710367b839814ed5cd9 /lib/std | |
| parent | 3e79315d19c7dfe5f9b90185d8030209ef8dd829 (diff) | |
| download | zig-ee4ced96833470f9432e6a5dc5b31534457280c0.tar.gz zig-ee4ced96833470f9432e6a5dc5b31534457280c0.zip | |
write function types consistently with a space before `fn` keyword
Currently, the compiler (like @typeName) writes it `fn(...) Type` but
zig fmt writes it `fn (...) Type` (notice the space after `fn`).
This inconsistency is now resolved and function types are consistently
written the zig fmt way. Before this there were more `fn (...) Type`
occurrences than `fn(...) Type` already.
Diffstat (limited to 'lib/std')
| -rw-r--r-- | lib/std/atomic/Atomic.zig | 2 | ||||
| -rw-r--r-- | lib/std/enums.zig | 8 | ||||
| -rw-r--r-- | lib/std/fmt.zig | 4 | ||||
| -rw-r--r-- | lib/std/meta.zig | 6 | ||||
| -rw-r--r-- | lib/std/treap.zig | 2 | ||||
| -rw-r--r-- | lib/std/zig/Ast.zig | 8 | ||||
| -rw-r--r-- | lib/std/zig/parser_test.zig | 4 |
7 files changed, 17 insertions, 17 deletions
diff --git a/lib/std/atomic/Atomic.zig b/lib/std/atomic/Atomic.zig index b9e1b18f77..3cb7c8e60a 100644 --- a/lib/std/atomic/Atomic.zig +++ b/lib/std/atomic/Atomic.zig @@ -21,7 +21,7 @@ pub fn Atomic(comptime T: type) type { /// ``` /// const RefCount = struct { /// count: Atomic(usize), - /// dropFn: *const fn(*RefCount) void, + /// dropFn: *const fn (*RefCount) void, /// /// fn ref(self: *RefCount) void { /// _ = self.count.fetchAdd(1, .Monotonic); // no ordering necessary, just updating a counter diff --git a/lib/std/enums.zig b/lib/std/enums.zig index 3aa5a4fa79..8cfba1f802 100644 --- a/lib/std/enums.zig +++ b/lib/std/enums.zig @@ -1269,10 +1269,10 @@ pub fn ensureIndexer(comptime T: type) void { if (@TypeOf(T.Key) != type) @compileError("Indexer.Key must be a type."); if (!@hasDecl(T, "count")) @compileError("Indexer must have decl count: usize."); if (@TypeOf(T.count) != usize) @compileError("Indexer.count must be a usize."); - if (!@hasDecl(T, "indexOf")) @compileError("Indexer.indexOf must be a fn(Key)usize."); - if (@TypeOf(T.indexOf) != fn (T.Key) usize) @compileError("Indexer must have decl indexOf: fn(Key)usize."); - if (!@hasDecl(T, "keyForIndex")) @compileError("Indexer must have decl keyForIndex: fn(usize)Key."); - if (@TypeOf(T.keyForIndex) != fn (usize) T.Key) @compileError("Indexer.keyForIndex must be a fn(usize)Key."); + if (!@hasDecl(T, "indexOf")) @compileError("Indexer.indexOf must be a fn (Key) usize."); + if (@TypeOf(T.indexOf) != fn (T.Key) usize) @compileError("Indexer must have decl indexOf: fn (Key) usize."); + if (!@hasDecl(T, "keyForIndex")) @compileError("Indexer must have decl keyForIndex: fn (usize) Key."); + if (@TypeOf(T.keyForIndex) != fn (usize) T.Key) @compileError("Indexer.keyForIndex must be a fn (usize) Key."); } } diff --git a/lib/std/fmt.zig b/lib/std/fmt.zig index 551e96c975..2f041aeb95 100644 --- a/lib/std/fmt.zig +++ b/lib/std/fmt.zig @@ -2255,11 +2255,11 @@ test "pointer" { const FnPtr = *align(1) const fn () void; { const value = @as(FnPtr, @ptrFromInt(0xdeadbeef)); - try expectFmt("pointer: fn() void@deadbeef\n", "pointer: {}\n", .{value}); + try expectFmt("pointer: fn () void@deadbeef\n", "pointer: {}\n", .{value}); } { const value = @as(FnPtr, @ptrFromInt(0xdeadbeef)); - try expectFmt("pointer: fn() void@deadbeef\n", "pointer: {}\n", .{value}); + try expectFmt("pointer: fn () void@deadbeef\n", "pointer: {}\n", .{value}); } } diff --git a/lib/std/meta.zig b/lib/std/meta.zig index b10ecd2731..c8ef19c017 100644 --- a/lib/std/meta.zig +++ b/lib/std/meta.zig @@ -969,9 +969,9 @@ test "std.meta.Float" { /// correspond to the argument types. /// /// Examples: -/// - `ArgsTuple(fn() void)` ⇒ `tuple { }` -/// - `ArgsTuple(fn(a: u32) u32)` ⇒ `tuple { u32 }` -/// - `ArgsTuple(fn(a: u32, b: f16) noreturn)` ⇒ `tuple { u32, f16 }` +/// - `ArgsTuple(fn () void)` ⇒ `tuple { }` +/// - `ArgsTuple(fn (a: u32) u32)` ⇒ `tuple { u32 }` +/// - `ArgsTuple(fn (a: u32, b: f16) noreturn)` ⇒ `tuple { u32, f16 }` pub fn ArgsTuple(comptime Function: type) type { const info = @typeInfo(Function); if (info != .Fn) diff --git a/lib/std/treap.zig b/lib/std/treap.zig index eabcfd0518..1c4541f96f 100644 --- a/lib/std/treap.zig +++ b/lib/std/treap.zig @@ -7,7 +7,7 @@ pub fn Treap(comptime Key: type, comptime compareFn: anytype) type { return struct { const Self = @This(); - // Allow for compareFn to be fn(anytype, anytype) anytype + // Allow for compareFn to be fn (anytype, anytype) anytype // which allows the convenient use of std.math.order. fn compare(a: Key, b: Key) Order { return compareFn(a, b); diff --git a/lib/std/zig/Ast.zig b/lib/std/zig/Ast.zig index 04ea0b0b84..85fa4b422c 100644 --- a/lib/std/zig/Ast.zig +++ b/lib/std/zig/Ast.zig @@ -3255,23 +3255,23 @@ pub const Node = struct { @"break", /// `return lhs`. lhs can be omitted. rhs is unused. @"return", - /// `fn(a: lhs) rhs`. lhs can be omitted. + /// `fn (a: lhs) rhs`. lhs can be omitted. /// anytype and ... parameters are omitted from the AST tree. /// main_token is the `fn` keyword. /// extern function declarations use this tag. fn_proto_simple, - /// `fn(a: b, c: d) rhs`. `sub_range_list[lhs]`. + /// `fn (a: b, c: d) rhs`. `sub_range_list[lhs]`. /// anytype and ... parameters are omitted from the AST tree. /// main_token is the `fn` keyword. /// extern function declarations use this tag. fn_proto_multi, - /// `fn(a: b) rhs addrspace(e) linksection(f) callconv(g)`. `FnProtoOne[lhs]`. + /// `fn (a: b) rhs addrspace(e) linksection(f) callconv(g)`. `FnProtoOne[lhs]`. /// zero or one parameters. /// anytype and ... parameters are omitted from the AST tree. /// main_token is the `fn` keyword. /// extern function declarations use this tag. fn_proto_one, - /// `fn(a: b, c: d) rhs addrspace(e) linksection(f) callconv(g)`. `FnProto[lhs]`. + /// `fn (a: b, c: d) rhs addrspace(e) linksection(f) callconv(g)`. `FnProto[lhs]`. /// anytype and ... parameters are omitted from the AST tree. /// main_token is the `fn` keyword. /// extern function declarations use this tag. diff --git a/lib/std/zig/parser_test.zig b/lib/std/zig/parser_test.zig index 68adf6aecd..cbdb83e304 100644 --- a/lib/std/zig/parser_test.zig +++ b/lib/std/zig/parser_test.zig @@ -5251,8 +5251,8 @@ test "zig fmt: make single-line if no trailing comma, fmt: off" { \\ } \\} \\ - \\const fn_no_comma = fn(i32, i32)void; - \\const fn_trailing_comma = fn(i32, i32,)void; + \\const fn_no_comma = fn (i32, i32) void; + \\const fn_trailing_comma = fn (i32, i32,) void; \\ \\fn fn_calls() void { \\ fn add(x: i32, y: i32,) i32 { x + y }; |
