Commit 80b719d967

Isaac Freund <ifreund@ifreund.xyz>
2021-02-10 13:02:37
zig fmt: fix typo in firstToken() for pointer types
1 parent 58db3d2
Changed files (2)
lib/std/zig/ast.zig
@@ -408,10 +408,10 @@ pub const Tree = struct {
                 const main_token = main_tokens[n];
                 return switch (token_tags[main_token]) {
                     .Asterisk => switch (token_tags[main_token - 1]) {
-                        .LBrace => main_token - 1,
+                        .LBracket => main_token - 1,
                         else => main_token,
                     },
-                    .LBrace => main_token,
+                    .LBracket => main_token,
                     else => unreachable,
                 } - end_offset;
             },
lib/std/zig/parser_test.zig
@@ -423,16 +423,16 @@ test "zig fmt: sentinel slice with modifiers" {
     );
 }
 
-//test "zig fmt: anon literal in array" {
-//    try testCanonical(
-//        \\var arr: [2]Foo = .{
-//        \\    .{ .a = 2 },
-//        \\    .{ .b = 3 },
-//        \\};
-//        \\
-//    );
-//}
-//
+test "zig fmt: anon literal in array" {
+    try testCanonical(
+        \\var arr: [2]Foo = .{
+        \\    .{ .a = 2 },
+        \\    .{ .b = 3 },
+        \\};
+        \\
+    );
+}
+
 //test "zig fmt: alignment in anonymous literal" {
 //    try testTransform(
 //        \\const a = .{
@@ -751,12 +751,12 @@ test "zig fmt: tagged union with enum values" {
     );
 }
 
-//test "zig fmt: allowzero pointer" {
-//    try testCanonical(
-//        \\const T = [*]allowzero const u8;
-//        \\
-//    );
-//}
+test "zig fmt: allowzero pointer" {
+    try testCanonical(
+        \\const T = [*]allowzero const u8;
+        \\
+    );
+}
 
 test "zig fmt: enum literal" {
     try testCanonical(
@@ -806,13 +806,13 @@ test "zig fmt: character literal larger than u8" {
 //        \\
 //    );
 //}
-//
-//test "zig fmt: C pointers" {
-//    try testCanonical(
-//        \\const Ptr = [*c]i32;
-//        \\
-//    );
-//}
+
+test "zig fmt: C pointers" {
+    try testCanonical(
+        \\const Ptr = [*c]i32;
+        \\
+    );
+}
 
 test "zig fmt: threadlocal" {
     try testCanonical(