authorgravatar for mail@isaacfreund.comIsaac Freund <mail@isaacfreund.com> 2021-02-17 00:03:39+01:00
committergravatar for mail@isaacfreund.comIsaac Freund <mail@isaacfreund.com> 2021-02-17 00:03:39+01:00
log4b226286e88d9b10f720c949d1241299af0d6c3f
tree89bbac6aec0d102f0dd2dd0609053b60ff01229c
parent895fb2bd6da5e1b69668dd6572df9d559ebf2407
signaturelock-open Commit is signed but in an unrecognized format.

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.

1 files changed, 1 insertions(+), 12 deletions(-)

lib/std/zig/render.zig+1-12
......@@ -1924,8 +1924,6 @@ const Space = enum {
19241924 /// Additionally consume the next token if it is a semicolon.
19251925 /// In either case, a newline will be inserted afterwards.
19261926 semicolon,
1927 /// Skips writing the possible line comment after the token.
1928 no_comment,
19291927};
19301928
19311929fn 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
19371935
19381936 try ais.writer().writeAll(lexeme);
19391937
1940 if (space == .no_comment) return;
1941
19421938 const comment = try renderComments(ais, tree, token_start + lexeme.len, token_starts[token_index + 1]);
19431939 switch (space) {
19441940 .none => {},
......@@ -1962,8 +1958,6 @@ fn renderToken(ais: *Ais, tree: ast.Tree, token_index: ast.TokenIndex, space: Sp
19621958 } else if (!comment) {
19631959 try ais.insertNewline();
19641960 },
1965
1966 .no_comment => unreachable,
19671961 }
19681962}
19691963
......@@ -2064,12 +2058,7 @@ fn renderDocComments(ais: *Ais, tree: ast.Tree, end_token: ast.TokenIndex) Error
20642058 try renderExtraNewlineToken(ais, tree, first_tok);
20652059
20662060 while (token_tags[tok] == .doc_comment) : (tok += 1) {
2067 if (first_tok < end_token) {
2068 try renderToken(ais, tree, tok, .newline);
2069 } else {
2070 try renderToken(ais, tree, tok, .no_comment);
2071 try ais.insertNewline();
2072 }
2061 try renderToken(ais, tree, tok, .newline);
20732062 }
20742063}
20752064