Skip to content

Commit ae0a219

Browse files
committed
stop accepting deprecated use keyword
closes #2591
1 parent cd5c9c8 commit ae0a219

File tree

5 files changed

+13
-27
lines changed

5 files changed

+13
-27
lines changed

lib/std/zig/parser_test.zig

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,3 @@
1-
// TODO remove `use` keyword eventually: https://github.com/ziglang/zig/issues/2591
2-
test "zig fmt: change use to usingnamespace" {
3-
try testTransform(
4-
\\use @import("std");
5-
,
6-
\\usingnamespace @import("std");
7-
\\
8-
);
9-
}
10-
111
test "zig fmt: async function" {
122
try testCanonical(
133
\\pub const Server = struct {

lib/std/zig/render.zig

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -226,9 +226,7 @@ fn renderTopLevelDecl(allocator: *mem.Allocator, stream: var, tree: *ast.Tree, i
226226
if (use_decl.visib_token) |visib_token| {
227227
try renderToken(tree, stream, visib_token, indent, start_col, Space.Space); // pub
228228
}
229-
// TODO after depracating use, go back to this:
230-
//try renderToken(tree, stream, use_decl.use_token, indent, start_col, Space.Space); // usingnamespace
231-
try stream.write("usingnamespace ");
229+
try renderToken(tree, stream, use_decl.use_token, indent, start_col, Space.Space); // usingnamespace
232230
try renderExpression(allocator, stream, tree, indent, start_col, use_decl.expr, Space.None);
233231
try renderToken(tree, stream, use_decl.semicolon_token, indent, start_col, Space.Newline); // ;
234232
},

lib/std/zig/tokenizer.zig

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ pub const Token = struct {
5959
Keyword{ .bytes = "undefined", .id = Id.Keyword_undefined },
6060
Keyword{ .bytes = "union", .id = Id.Keyword_union },
6161
Keyword{ .bytes = "unreachable", .id = Id.Keyword_unreachable },
62-
Keyword{ .bytes = "use", .id = Id.Keyword_usingnamespace },
6362
Keyword{ .bytes = "usingnamespace", .id = Id.Keyword_usingnamespace },
6463
Keyword{ .bytes = "var", .id = Id.Keyword_var },
6564
Keyword{ .bytes = "volatile", .id = Id.Keyword_volatile },

src/tokenizer.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,6 @@ static const struct ZigKeyword zig_keywords[] = {
153153
{"undefined", TokenIdKeywordUndefined},
154154
{"union", TokenIdKeywordUnion},
155155
{"unreachable", TokenIdKeywordUnreachable},
156-
{"use", TokenIdKeywordUsingNamespace},
157156
{"usingnamespace", TokenIdKeywordUsingNamespace},
158157
{"var", TokenIdKeywordVar},
159158
{"volatile", TokenIdKeywordVolatile},

test/compare_output.zig

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {
1414

1515
cases.addCase(x: {
1616
var tc = cases.create("multiple files with private function",
17-
\\use @import("std").io;
18-
\\use @import("foo.zig");
17+
\\usingnamespace @import("std").io;
18+
\\usingnamespace @import("foo.zig");
1919
\\
2020
\\pub fn main() void {
2121
\\ privateFunction();
@@ -29,7 +29,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {
2929
, "OK 1\nOK 2\n");
3030

3131
tc.addSourceFile("foo.zig",
32-
\\use @import("std").io;
32+
\\usingnamespace @import("std").io;
3333
\\
3434
\\// purposefully conflicting function with main.zig
3535
\\// but it's private so it should be OK
@@ -48,8 +48,8 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {
4848

4949
cases.addCase(x: {
5050
var tc = cases.create("import segregation",
51-
\\use @import("foo.zig");
52-
\\use @import("bar.zig");
51+
\\usingnamespace @import("foo.zig");
52+
\\usingnamespace @import("bar.zig");
5353
\\
5454
\\pub fn main() void {
5555
\\ foo_function();
@@ -58,16 +58,16 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {
5858
, "OK\nOK\n");
5959

6060
tc.addSourceFile("foo.zig",
61-
\\use @import("std").io;
61+
\\usingnamespace @import("std").io;
6262
\\pub fn foo_function() void {
6363
\\ const stdout = &(getStdOut() catch unreachable).outStream().stream;
6464
\\ stdout.print("OK\n") catch unreachable;
6565
\\}
6666
);
6767

6868
tc.addSourceFile("bar.zig",
69-
\\use @import("other.zig");
70-
\\use @import("std").io;
69+
\\usingnamespace @import("other.zig");
70+
\\usingnamespace @import("std").io;
7171
\\
7272
\\pub fn bar_function() void {
7373
\\ if (foo_function()) {
@@ -88,16 +88,16 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {
8888
});
8989

9090
cases.addCase(x: {
91-
var tc = cases.create("two files use import each other",
92-
\\use @import("a.zig");
91+
var tc = cases.create("two files usingnamespace import each other",
92+
\\usingnamespace @import("a.zig");
9393
\\
9494
\\pub fn main() void {
9595
\\ ok();
9696
\\}
9797
, "OK\n");
9898

9999
tc.addSourceFile("a.zig",
100-
\\use @import("b.zig");
100+
\\usingnamespace @import("b.zig");
101101
\\const io = @import("std").io;
102102
\\
103103
\\pub const a_text = "OK\n";
@@ -109,7 +109,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {
109109
);
110110

111111
tc.addSourceFile("b.zig",
112-
\\use @import("a.zig");
112+
\\usingnamespace @import("a.zig");
113113
\\
114114
\\pub const b_text = a_text;
115115
);

0 commit comments

Comments
 (0)