authorgravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2020-03-10 20:02:22+02:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-03-10 15:27:11-04:00
log1ad831a0ef22f354d4e1dd5073456a0683249846
treeaade0aaeb2654992a24b92d66224cd1bd0065d93
parent90c232bbe8e53c09df14536def54b33d92ddd3c5

fix zig fmt on noasync block


2 files changed, 41 insertions(+), 26 deletions(-)

lib/std/zig/ast.zig+30-26
...@@ -500,68 +500,72 @@ pub const Node = struct {...@@ -500,68 +500,72 @@ pub const Node = struct {
500 var n = base;500 var n = base;
501 while (true) {501 while (true) {
502 switch (n.id) {502 switch (n.id) {
503 Id.Root,503 .Root,
504 Id.ContainerField,504 .ContainerField,
505 Id.ParamDecl,505 .ParamDecl,
506 Id.Block,506 .Block,
507 Id.Payload,507 .Payload,
508 Id.PointerPayload,508 .PointerPayload,
509 Id.PointerIndexPayload,509 .PointerIndexPayload,
510 Id.Switch,510 .Switch,
511 Id.SwitchCase,511 .SwitchCase,
512 Id.SwitchElse,512 .SwitchElse,
513 Id.FieldInitializer,513 .FieldInitializer,
514 Id.DocComment,514 .DocComment,
515 Id.TestDecl,515 .TestDecl,
516 => return false,516 => return false,
517 Id.While => {517 .While => {
518 const while_node = @fieldParentPtr(While, "base", n);518 const while_node = @fieldParentPtr(While, "base", n);
519 if (while_node.@"else") |@"else"| {519 if (while_node.@"else") |@"else"| {
520 n = &@"else".base;520 n = &@"else".base;
521 continue;521 continue;
522 }522 }
523523
524 return while_node.body.id != Id.Block;524 return while_node.body.id != .Block;
525 },525 },
526 Id.For => {526 .For => {
527 const for_node = @fieldParentPtr(For, "base", n);527 const for_node = @fieldParentPtr(For, "base", n);
528 if (for_node.@"else") |@"else"| {528 if (for_node.@"else") |@"else"| {
529 n = &@"else".base;529 n = &@"else".base;
530 continue;530 continue;
531 }531 }
532532
533 return for_node.body.id != Id.Block;533 return for_node.body.id != .Block;
534 },534 },
535 Id.If => {535 .If => {
536 const if_node = @fieldParentPtr(If, "base", n);536 const if_node = @fieldParentPtr(If, "base", n);
537 if (if_node.@"else") |@"else"| {537 if (if_node.@"else") |@"else"| {
538 n = &@"else".base;538 n = &@"else".base;
539 continue;539 continue;
540 }540 }
541541
542 return if_node.body.id != Id.Block;542 return if_node.body.id != .Block;
543 },543 },
544 Id.Else => {544 .Else => {
545 const else_node = @fieldParentPtr(Else, "base", n);545 const else_node = @fieldParentPtr(Else, "base", n);
546 n = else_node.body;546 n = else_node.body;
547 continue;547 continue;
548 },548 },
549 Id.Defer => {549 .Defer => {
550 const defer_node = @fieldParentPtr(Defer, "base", n);550 const defer_node = @fieldParentPtr(Defer, "base", n);
551 return defer_node.expr.id != Id.Block;551 return defer_node.expr.id != .Block;
552 },552 },
553 Id.Comptime => {553 .Comptime => {
554 const comptime_node = @fieldParentPtr(Comptime, "base", n);554 const comptime_node = @fieldParentPtr(Comptime, "base", n);
555 return comptime_node.expr.id != Id.Block;555 return comptime_node.expr.id != .Block;
556 },556 },
557 Id.Suspend => {557 .Suspend => {
558 const suspend_node = @fieldParentPtr(Suspend, "base", n);558 const suspend_node = @fieldParentPtr(Suspend, "base", n);
559 if (suspend_node.body) |body| {559 if (suspend_node.body) |body| {
560 return body.id != Id.Block;560 return body.id != .Block;
561 }561 }
562562
563 return true;563 return true;
564 },564 },
565 .Noasync => {
566 const noasync_node = @fieldParentPtr(Noasync, "base", n);
567 return noasync_node.expr.id != .Block;
568 },
565 else => return true,569 else => return true,
566 }570 }
567 }571 }
lib/std/zig/parser_test.zig+11
...@@ -1,3 +1,14 @@...@@ -1,3 +1,14 @@
1test "zig fmt: noasync block" {
2 try testCanonical(
3 \\pub fn main() anyerror!void {
4 \\ noasync {
5 \\ var foo: Foo = .{ .bar = 42 };
6 \\ }
7 \\}
8 \\
9 );
10}
11
1test "zig fmt: noasync await" {12test "zig fmt: noasync await" {
2 try testCanonical(13 try testCanonical(
3 \\fn foo() void {14 \\fn foo() void {