authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-11-11 11:52:50-05:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-11-11 13:02:39-05:00
logae0a219d1f5495acc4d82421fa24d84186c2a40d
tree10d73e06d67c23cb03bd975bf97d1bfc7aa29a53
parentcd5c9c8998f1669059cee3d915831ee539dea2b6
signaturelock-open Commit is signed but in an unrecognized format.

stop accepting deprecated `use` keyword

closes #2591

5 files changed, 13 insertions(+), 27 deletions(-)

lib/std/zig/parser_test.zig-10
......@@ -1,13 +1,3 @@
1// TODO remove `use` keyword eventually: https://github.com/ziglang/zig/issues/2591
2test "zig fmt: change use to usingnamespace" {
3 try testTransform(
4 \\use @import("std");
5 ,
6 \\usingnamespace @import("std");
7 \\
8 );
9}
10
111test "zig fmt: async function" {
122 try testCanonical(
133 \\pub const Server = struct {
lib/std/zig/render.zig+1-3
......@@ -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-1
......@@ -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-1
......@@ -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+12-12
......@@ -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,7 +58,7 @@ 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;
......@@ -66,8 +66,8 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {
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,8 +88,8 @@ 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();
......@@ -97,7 +97,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {
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 );