| author | |
| committer | |
| log | bb2929ba083d3c5d86cae1d83cba0abd43ffa3d5 |
| tree | a3cc33668cc0aa4bc6f5584dc59d111c61611611 |
| parent | 8974cee5a1f67db42a83a0907d8b9e842b979072 |
| signature |
Fixes: https://github.com/ziglang/zig/issues/11802
3 files changed, 46 insertions(+), 2 deletions(-)
lib/std/os/linux.zig-1| ... | ... | @@ -4683,7 +4683,6 @@ pub const prctl_mm_map = extern struct { |
| 4683 | 4683 | }; |
| 4684 | 4684 | |
| 4685 | 4685 | pub const NETLINK = struct { |
| 4686 | ||
| 4687 | 4686 | /// Routing/device hook |
| 4688 | 4687 | pub const ROUTE = 0; |
| 4689 | 4688 |
lib/std/zig/parser_test.zig+35| ... | ... | @@ -4154,6 +4154,41 @@ test "zig fmt: container doc comments" { |
| 4154 | 4154 | ); |
| 4155 | 4155 | } |
| 4156 | 4156 | |
| 4157 | test "zig fmt: remove newlines surrounding doc comment" { | |
| 4158 | try testTransform( | |
| 4159 | \\ | |
| 4160 | \\ | |
| 4161 | \\ | |
| 4162 | \\/// doc comment | |
| 4163 | \\ | |
| 4164 | \\fn foo() void {} | |
| 4165 | \\ | |
| 4166 | , | |
| 4167 | \\/// doc comment | |
| 4168 | \\fn foo() void {} | |
| 4169 | \\ | |
| 4170 | ); | |
| 4171 | } | |
| 4172 | ||
| 4173 | test "zig fmt: remove newlines surrounding doc comment within container decl" { | |
| 4174 | try testTransform( | |
| 4175 | \\const Foo = struct { | |
| 4176 | \\ | |
| 4177 | \\ | |
| 4178 | \\ /// doc comment | |
| 4179 | \\ | |
| 4180 | \\ fn foo() void {} | |
| 4181 | \\}; | |
| 4182 | \\ | |
| 4183 | , | |
| 4184 | \\const Foo = struct { | |
| 4185 | \\ /// doc comment | |
| 4186 | \\ fn foo() void {} | |
| 4187 | \\}; | |
| 4188 | \\ | |
| 4189 | ); | |
| 4190 | } | |
| 4191 | ||
| 4157 | 4192 | test "zig fmt: anytype struct field" { |
| 4158 | 4193 | try testError( |
| 4159 | 4194 | \\pub const Pointer = struct { |
lib/std/zig/render.zig+11-1| ... | ... | @@ -2482,7 +2482,17 @@ fn renderDocComments(ais: *Ais, tree: Ast, end_token: Ast.TokenIndex) Error!void |
| 2482 | 2482 | } |
| 2483 | 2483 | const first_tok = tok; |
| 2484 | 2484 | if (first_tok == end_token) return; |
| 2485 | try renderExtraNewlineToken(ais, tree, first_tok); | |
| 2485 | ||
| 2486 | if (first_tok != 0) { | |
| 2487 | const prev_token_tag = token_tags[first_tok - 1]; | |
| 2488 | ||
| 2489 | // Prevent accidental use of `renderDocComments` for a function argument doc comment | |
| 2490 | assert(prev_token_tag != .l_paren); | |
| 2491 | ||
| 2492 | if (prev_token_tag != .l_brace) { | |
| 2493 | try renderExtraNewlineToken(ais, tree, first_tok); | |
| 2494 | } | |
| 2495 | } | |
| 2486 | 2496 | |
| 2487 | 2497 | while (token_tags[tok] == .doc_comment) : (tok += 1) { |
| 2488 | 2498 | try renderToken(ais, tree, tok, .newline); |