zig fmt: remove c_void -> anyopaque rewrite

TODO comments said to remove this
This commit is contained in:
yujiri8 2022-12-12 09:46:28 +00:00 committed by GitHub
parent 8a27df5355
commit d36cd49f0b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 1 additions and 33 deletions

View File

@ -106,29 +106,6 @@ test "zig fmt: rewrite callconv(.Inline) to the inline keyword" {
);
}
// TODO Remove this after zig 0.10.0 is released.
test "zig fmt: rewrite c_void to anyopaque" {
try testTransform(
\\const Foo = struct {
\\ c_void: *c_void,
\\};
\\
\\fn foo(a: ?*c_void) !*c_void {
\\ return a orelse unreachable;
\\}
\\
,
\\const Foo = struct {
\\ c_void: *anyopaque,
\\};
\\
\\fn foo(a: ?*anyopaque) !*anyopaque {
\\ return a orelse unreachable;
\\}
\\
);
}
test "zig fmt: simple top level comptime block" {
try testCanonical(
\\// line comment

View File

@ -207,18 +207,9 @@ fn renderExpression(gpa: Allocator, ais: *Ais, tree: Ast, node: Ast.Node.Index,
const node_tags = tree.nodes.items(.tag);
const datas = tree.nodes.items(.data);
switch (node_tags[node]) {
// TODO remove this c_void -> anyopaque rewrite after the 0.10.0 release.
// Also get rid of renderSpace() as it will no longer be necessary.
.identifier => {
const token_index = main_tokens[node];
const lexeme = tokenSliceForRender(tree, token_index);
if (mem.eql(u8, lexeme, "c_void")) {
try ais.writer().writeAll("anyopaque");
return renderSpace(ais, tree, token_index, lexeme.len, space);
} else {
return renderIdentifier(ais, tree, token_index, space, .preserve_when_shadowing);
}
return renderIdentifier(ais, tree, token_index, space, .preserve_when_shadowing);
},
.number_literal,