authorgravatar for yujiri@disroot.orgyujiri8 <yujiri@disroot.org> 2022-12-12 09:46:28+00:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2022-12-12 10:46:28+01:00
logd36cd49f0b3a35645c9b371344ea436725fb6c69
tree303033d51d04142db830adb3737fbc191916dde2
parent8a27df5355a1d97bdc483df093c4d69489b99e42
signaturebadge-question-mark Signed by PGP key 4AEE18F83AFDEB23

zig fmt: remove c_void -> anyopaque rewrite

TODO comments said to remove this

2 files changed, 1 insertions(+), 33 deletions(-)

lib/std/zig/parser_test.zig-23
...@@ -106,29 +106,6 @@ test "zig fmt: rewrite callconv(.Inline) to the inline keyword" {...@@ -106,29 +106,6 @@ test "zig fmt: rewrite callconv(.Inline) to the inline keyword" {
106 );106 );
107}107}
108108
109// TODO Remove this after zig 0.10.0 is released.
110test "zig fmt: rewrite c_void to anyopaque" {
111 try testTransform(
112 \\const Foo = struct {
113 \\ c_void: *c_void,
114 \\};
115 \\
116 \\fn foo(a: ?*c_void) !*c_void {
117 \\ return a orelse unreachable;
118 \\}
119 \\
120 ,
121 \\const Foo = struct {
122 \\ c_void: *anyopaque,
123 \\};
124 \\
125 \\fn foo(a: ?*anyopaque) !*anyopaque {
126 \\ return a orelse unreachable;
127 \\}
128 \\
129 );
130}
131
132test "zig fmt: simple top level comptime block" {109test "zig fmt: simple top level comptime block" {
133 try testCanonical(110 try testCanonical(
134 \\// line comment111 \\// line comment
lib/std/zig/render.zig+1-10
...@@ -207,18 +207,9 @@ fn renderExpression(gpa: Allocator, ais: *Ais, tree: Ast, node: Ast.Node.Index,...@@ -207,18 +207,9 @@ fn renderExpression(gpa: Allocator, ais: *Ais, tree: Ast, node: Ast.Node.Index,
207 const node_tags = tree.nodes.items(.tag);207 const node_tags = tree.nodes.items(.tag);
208 const datas = tree.nodes.items(.data);208 const datas = tree.nodes.items(.data);
209 switch (node_tags[node]) {209 switch (node_tags[node]) {
210 // TODO remove this c_void -> anyopaque rewrite after the 0.10.0 release.
211 // Also get rid of renderSpace() as it will no longer be necessary.
212 .identifier => {210 .identifier => {
213 const token_index = main_tokens[node];211 const token_index = main_tokens[node];
214212 return renderIdentifier(ais, tree, token_index, space, .preserve_when_shadowing);
215 const lexeme = tokenSliceForRender(tree, token_index);
216 if (mem.eql(u8, lexeme, "c_void")) {
217 try ais.writer().writeAll("anyopaque");
218 return renderSpace(ais, tree, token_index, lexeme.len, space);
219 } else {
220 return renderIdentifier(ais, tree, token_index, space, .preserve_when_shadowing);
221 }
222 },213 },
223214
224 .number_literal,215 .number_literal,