mirror of
https://github.com/ziglang/zig.git
synced 2026-02-12 20:37:54 +00:00
zig fmt: comments in field decls
This commit is contained in:
parent
4cc1008c2d
commit
61a726c290
@ -3525,6 +3525,7 @@ pub const Parser = struct {
|
||||
},
|
||||
ast.Node.Id.StructField => {
|
||||
const field = @fieldParentPtr(ast.Node.StructField, "base", decl);
|
||||
try self.renderComments(stream, &field.base, indent);
|
||||
if (field.visib_token) |visib_token| {
|
||||
try stream.print("{} ", self.tokenizer.getTokenSlice(visib_token));
|
||||
}
|
||||
@ -3534,6 +3535,7 @@ pub const Parser = struct {
|
||||
},
|
||||
ast.Node.Id.UnionTag => {
|
||||
const tag = @fieldParentPtr(ast.Node.UnionTag, "base", decl);
|
||||
try self.renderComments(stream, &tag.base, indent);
|
||||
try stream.print("{}", self.tokenizer.getTokenSlice(tag.name_token));
|
||||
|
||||
try stack.append(RenderState { .Text = "," });
|
||||
@ -3550,6 +3552,7 @@ pub const Parser = struct {
|
||||
},
|
||||
ast.Node.Id.EnumTag => {
|
||||
const tag = @fieldParentPtr(ast.Node.EnumTag, "base", decl);
|
||||
try self.renderComments(stream, &tag.base, indent);
|
||||
try stream.print("{}", self.tokenizer.getTokenSlice(tag.name_token));
|
||||
|
||||
try stack.append(RenderState { .Text = "," });
|
||||
|
||||
@ -1,5 +1,16 @@
|
||||
test "zig fmt: doc comments before struct field" {
|
||||
try testCanonical(
|
||||
\\pub const Allocator = struct {
|
||||
\\ /// Allocate byte_count bytes and return them in a slice, with the
|
||||
\\ /// slice's pointer aligned at least to alignment bytes.
|
||||
\\ allocFn: fn() void,
|
||||
\\};
|
||||
\\
|
||||
);
|
||||
}
|
||||
|
||||
test "zig fmt: error set declaration" {
|
||||
try testCanonical(
|
||||
try testCanonical(
|
||||
\\const E = error{
|
||||
\\ A,
|
||||
\\ B,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user