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 {...@@ -1924,8 +1924,6 @@ const Space = enum {
1924 /// Additionally consume the next token if it is a semicolon.1924 /// Additionally consume the next token if it is a semicolon.
1925 /// In either case, a newline will be inserted afterwards.1925 /// In either case, a newline will be inserted afterwards.
1926 semicolon,1926 semicolon,
1927 /// Skips writing the possible line comment after the token.
1928 no_comment,
1929};1927};
19301928
1931fn renderToken(ais: *Ais, tree: ast.Tree, token_index: ast.TokenIndex, space: Space) Error!void {1929fn 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...@@ -1937,8 +1935,6 @@ fn renderToken(ais: *Ais, tree: ast.Tree, token_index: ast.TokenIndex, space: Sp
19371935
1938 try ais.writer().writeAll(lexeme);1936 try ais.writer().writeAll(lexeme);
19391937
1940 if (space == .no_comment) return;
1941
1942 const comment = try renderComments(ais, tree, token_start + lexeme.len, token_starts[token_index + 1]);1938 const comment = try renderComments(ais, tree, token_start + lexeme.len, token_starts[token_index + 1]);
1943 switch (space) {1939 switch (space) {
1944 .none => {},1940 .none => {},
...@@ -1962,8 +1958,6 @@ fn renderToken(ais: *Ais, tree: ast.Tree, token_index: ast.TokenIndex, space: Sp...@@ -1962,8 +1958,6 @@ fn renderToken(ais: *Ais, tree: ast.Tree, token_index: ast.TokenIndex, space: Sp
1962 } else if (!comment) {1958 } else if (!comment) {
1963 try ais.insertNewline();1959 try ais.insertNewline();
1964 },1960 },
1965
1966 .no_comment => unreachable,
1967 }1961 }
1968}1962}
19691963
...@@ -2064,12 +2058,7 @@ fn renderDocComments(ais: *Ais, tree: ast.Tree, end_token: ast.TokenIndex) Error...@@ -2064,12 +2058,7 @@ fn renderDocComments(ais: *Ais, tree: ast.Tree, end_token: ast.TokenIndex) Error
2064 try renderExtraNewlineToken(ais, tree, first_tok);2058 try renderExtraNewlineToken(ais, tree, first_tok);
20652059
2066 while (token_tags[tok] == .doc_comment) : (tok += 1) {2060 while (token_tags[tok] == .doc_comment) : (tok += 1) {
2067 if (first_tok < end_token) {2061 try renderToken(ais, tree, tok, .newline);
2068 try renderToken(ais, tree, tok, .newline);
2069 } else {
2070 try renderToken(ais, tree, tok, .no_comment);
2071 try ais.insertNewline();
2072 }
2073 }2062 }
2074}2063}
20752064