From 4b226286e88d9b10f720c949d1241299af0d6c3f Mon Sep 17 00:00:00 2001 From: Isaac Freund Date: Wed, 17 Feb 2021 00:03:39 +0100 Subject: [PATCH] zig fmt: get rid of Space.no_comment Using this in its current state would be a bug as it could cause line comments to be deleted or a `// zig fmt: (on|off)` directive to be missed. Removing it doesn't currently cause any test failures, if a reason for its continued existence is discovered in the future another solution will have to be found. --- lib/std/zig/render.zig | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/lib/std/zig/render.zig b/lib/std/zig/render.zig index a520a2d18b..3b5765507b 100644 --- a/lib/std/zig/render.zig +++ b/lib/std/zig/render.zig @@ -1924,8 +1924,6 @@ const Space = enum { /// Additionally consume the next token if it is a semicolon. /// In either case, a newline will be inserted afterwards. semicolon, - /// Skips writing the possible line comment after the token. - no_comment, }; fn renderToken(ais: *Ais, tree: ast.Tree, token_index: ast.TokenIndex, space: Space) Error!void { @@ -1937,8 +1935,6 @@ fn renderToken(ais: *Ais, tree: ast.Tree, token_index: ast.TokenIndex, space: Sp try ais.writer().writeAll(lexeme); - if (space == .no_comment) return; - const comment = try renderComments(ais, tree, token_start + lexeme.len, token_starts[token_index + 1]); switch (space) { .none => {}, @@ -1962,8 +1958,6 @@ fn renderToken(ais: *Ais, tree: ast.Tree, token_index: ast.TokenIndex, space: Sp } else if (!comment) { try ais.insertNewline(); }, - - .no_comment => unreachable, } } @@ -2064,12 +2058,7 @@ fn renderDocComments(ais: *Ais, tree: ast.Tree, end_token: ast.TokenIndex) Error try renderExtraNewlineToken(ais, tree, first_tok); while (token_tags[tok] == .doc_comment) : (tok += 1) { - if (first_tok < end_token) { - try renderToken(ais, tree, tok, .newline); - } else { - try renderToken(ais, tree, tok, .no_comment); - try ais.insertNewline(); - } + try renderToken(ais, tree, tok, .newline); } }