diff --git a/lib/std/zig/parser_test.zig b/lib/std/zig/parser_test.zig index 7b75aed28ecb0d46b632031b1de9421c8a3d4f22..c31ef9c64b4e85e4796213fc558effefa814e320 100644 --- a/lib/std/zig/parser_test.zig +++ b/lib/std/zig/parser_test.zig @@ -7,6 +7,16 @@ test "zig fmt: trailing comma in container declaration" { \\const X = struct { foo: i32 align(4) = 1, bar: i32 align(4) = 2 }; \\ ); + try testCanonical( + \\test "" { + \\ comptime { + \\ const X = struct { + \\ x: i32 + \\ }; + \\ } + \\} + \\ + ); try testTransform( \\const X = struct { \\ foo: i32, bar: i8 }; diff --git a/lib/std/zig/render.zig b/lib/std/zig/render.zig index 5fda700484174e570f9640411aee59e35d4cc792..7dd3d63b0d35a410c2b17e73f6e26e2cb997eb55 100644 --- a/lib/std/zig/render.zig +++ b/lib/std/zig/render.zig @@ -1224,6 +1224,8 @@ fn renderExpression( const space_after_decl: Space = if (it.peek() == null) .Newline else .Space; try renderContainerDecl(allocator, stream, tree, new_indent, start_col, decl.*, space_after_decl); } + + try stream.writeByteNTimes(' ', indent); } else { // All the declarations on the same line try renderToken(tree, stream, container_decl.lbrace_token, indent, start_col, .Space); // {