Commit 47c309c34a

Isaac Freund <isaac.freund@coil.com>
2021-12-07 19:34:00
AstGen: increase zig fmt off/on granularity
This enables automatic formatting for a significant amount of code that currently doesn't deviate from the standard zig fmt enforced style.
1 parent 75f3e7a
Changed files (1)
src/AstGen.zig
@@ -6739,7 +6739,6 @@ fn builtinCall(
         }
     }
 
-    // zig fmt: off
     switch (info.tag) {
         .import => {
             const node_tags = tree.nodes.items(.tag);
@@ -6768,7 +6767,7 @@ fn builtinCall(
                 astgen.extra.items[extra_index] = @enumToInt(param_ref);
                 extra_index += 1;
             }
-            const result = try gz.addExtendedMultiOpPayloadIndex(.compile_log,payload_index, params.len);
+            const result = try gz.addExtendedMultiOpPayloadIndex(.compile_log, payload_index, params.len);
             return rvalue(gz, rl, result, node);
         },
         .field => {
@@ -6784,11 +6783,14 @@ fn builtinCall(
             });
             return rvalue(gz, rl, result, node);
         },
+
+        // zig fmt: off
         .as         => return as(       gz, scope, rl, node, params[0], params[1]),
         .bit_cast   => return bitCast(  gz, scope, rl, node, params[0], params[1]),
         .TypeOf     => return typeOf(   gz, scope, rl, node, params),
         .union_init => return unionInit(gz, scope, rl, node, params),
         .c_import   => return cImport(  gz, scope,     node, params[0]),
+        // zig fmt: on
 
         .@"export" => {
             const node_tags = tree.nodes.items(.tag);
@@ -6858,9 +6860,7 @@ fn builtinCall(
                     const field_ident = dot_token + 1;
                     decl_name = try astgen.identAsString(field_ident);
                 },
-                else => return astgen.failNode(
-                    params[0], "symbol to export must identify a declaration", .{},
-                ),
+                else => return astgen.failNode(params[0], "symbol to export must identify a declaration", .{}),
             }
             const options = try comptimeExpr(gz, scope, .{ .ty = .export_options_type }, params[1]);
             _ = try gz.addPlNode(.@"export", node, Zir.Inst.Export{
@@ -6888,6 +6888,7 @@ fn builtinCall(
 
         .breakpoint => return simpleNoOpVoid(gz, rl, node, .breakpoint),
 
+        // zig fmt: off
         .This               => return rvalue(gz, rl, try gz.addNodeExtended(.this,               node), node),
         .return_address     => return rvalue(gz, rl, try gz.addNodeExtended(.ret_addr,           node), node),
         .src                => return rvalue(gz, rl, try gz.addNodeExtended(.builtin_src,        node), node),
@@ -6942,6 +6943,8 @@ fn builtinCall(
         .err_set_cast => return typeCast(gz, scope, rl, node, params[0], params[1], .err_set_cast),
         .ptr_cast     => return typeCast(gz, scope, rl, node, params[0], params[1], .ptr_cast),
         .truncate     => return typeCast(gz, scope, rl, node, params[0], params[1], .truncate),
+        // zig fmt: on
+
         .align_cast => {
             const dest_align = try comptimeExpr(gz, scope, align_rl, params[0]);
             const rhs = try expr(gz, scope, .none, params[1]);
@@ -6952,6 +6955,7 @@ fn builtinCall(
             return rvalue(gz, rl, result, node);
         },
 
+        // zig fmt: off
         .has_decl  => return hasDeclOrField(gz, scope, rl, node, params[0], params[1], .has_decl),
         .has_field => return hasDeclOrField(gz, scope, rl, node, params[0], params[1], .has_field),
 
@@ -6978,6 +6982,7 @@ fn builtinCall(
 
         .cmpxchg_strong => return cmpxchg(gz, scope, rl, node, params, .cmpxchg_strong),
         .cmpxchg_weak   => return cmpxchg(gz, scope, rl, node, params, .cmpxchg_weak),
+        // zig fmt: on
 
         .wasm_memory_size => {
             const operand = try expr(gz, scope, .{ .ty = .u32_type }, params[0]);
@@ -7222,7 +7227,6 @@ fn builtinCall(
             return rvalue(gz, rl, result, node);
         },
     }
-    // zig fmt: on
 }
 
 fn simpleNoOpVoid(