diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2020-03-30 14:23:22 -0400 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2020-03-30 14:23:22 -0400 |
| commit | 9e7ae062492d4b41564832d37408336e36165e67 (patch) | |
| tree | b6b898deb26a63f264ee43e00ecfe883a1e8db99 /doc | |
| parent | b980568c810fda4c014da42be8e5108b4cbadb7c (diff) | |
| download | zig-9e7ae062492d4b41564832d37408336e36165e67.tar.gz zig-9e7ae062492d4b41564832d37408336e36165e67.zip | |
std lib API deprecations for the upcoming 0.6.0 release
See #3811
Diffstat (limited to 'doc')
| -rw-r--r-- | doc/docgen.zig | 69 | ||||
| -rw-r--r-- | doc/langref.html.in | 4 |
2 files changed, 46 insertions, 27 deletions
diff --git a/doc/docgen.zig b/doc/docgen.zig index 32ad0cdc5d..be62cab076 100644 --- a/doc/docgen.zig +++ b/doc/docgen.zig @@ -1048,7 +1048,7 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: var allocator, &[_][]const u8{ tmp_dir_name, name_plus_ext }, ); - try io.writeFile(tmp_source_file_name, trimmed_raw_source); + try fs.cwd().writeFile(tmp_source_file_name, trimmed_raw_source); switch (code.id) { Code.Id.Exe => |expected_outcome| code_block: { @@ -1106,18 +1106,17 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: var } } if (expected_outcome == .BuildFail) { - const result = try ChildProcess.exec( - allocator, - build_args.toSliceConst(), - null, - &env_map, - max_doc_file_size, - ); + const result = try ChildProcess.exec(.{ + .allocator = allocator, + .argv = build_args.span(), + .env_map = &env_map, + .max_output_bytes = max_doc_file_size, + }); switch (result.term) { .Exited => |exit_code| { if (exit_code == 0) { warn("{}\nThe following command incorrectly succeeded:\n", .{result.stderr}); - for (build_args.toSliceConst()) |arg| + for (build_args.span()) |arg| warn("{} ", .{arg}) else warn("\n", .{}); @@ -1126,7 +1125,7 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: var }, else => { warn("{}\nThe following command crashed:\n", .{result.stderr}); - for (build_args.toSliceConst()) |arg| + for (build_args.span()) |arg| warn("{} ", .{arg}) else warn("\n", .{}); @@ -1138,7 +1137,7 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: var try out.print("\n{}</code></pre>\n", .{colored_stderr}); break :code_block; } - const exec_result = exec(allocator, &env_map, build_args.toSliceConst()) catch + const exec_result = exec(allocator, &env_map, build_args.span()) catch return parseError(tokenizer, code.source_token, "example failed to compile", .{}); if (code.target_str) |triple| { @@ -1167,7 +1166,12 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: var var exited_with_signal = false; const result = if (expected_outcome == ExpectedOutcome.Fail) blk: { - const result = try ChildProcess.exec(allocator, run_args, null, &env_map, max_doc_file_size); + const result = try ChildProcess.exec(.{ + .allocator = allocator, + .argv = run_args, + .env_map = &env_map, + .max_output_bytes = max_doc_file_size, + }); switch (result.term) { .Exited => |exit_code| { if (exit_code == 0) { @@ -1234,7 +1238,7 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: var try test_args.appendSlice(&[_][]const u8{ "-target", triple }); try out.print(" -target {}", .{triple}); } - const result = exec(allocator, &env_map, test_args.toSliceConst()) catch return parseError(tokenizer, code.source_token, "test failed", .{}); + const result = exec(allocator, &env_map, test_args.span()) catch return parseError(tokenizer, code.source_token, "test failed", .{}); const escaped_stderr = try escapeHtml(allocator, result.stderr); const escaped_stdout = try escapeHtml(allocator, result.stdout); try out.print("\n{}{}</code></pre>\n", .{ escaped_stderr, escaped_stdout }); @@ -1268,12 +1272,17 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: var try out.print(" --release-small", .{}); }, } - const result = try ChildProcess.exec(allocator, test_args.toSliceConst(), null, &env_map, max_doc_file_size); + const result = try ChildProcess.exec(.{ + .allocator = allocator, + .argv = test_args.span(), + .env_map = &env_map, + .max_output_bytes = max_doc_file_size, + }); switch (result.term) { .Exited => |exit_code| { if (exit_code == 0) { warn("{}\nThe following command incorrectly succeeded:\n", .{result.stderr}); - for (test_args.toSliceConst()) |arg| + for (test_args.span()) |arg| warn("{} ", .{arg}) else warn("\n", .{}); @@ -1282,7 +1291,7 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: var }, else => { warn("{}\nThe following command crashed:\n", .{result.stderr}); - for (test_args.toSliceConst()) |arg| + for (test_args.span()) |arg| warn("{} ", .{arg}) else warn("\n", .{}); @@ -1326,12 +1335,17 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: var }, } - const result = try ChildProcess.exec(allocator, test_args.toSliceConst(), null, &env_map, max_doc_file_size); + const result = try ChildProcess.exec(.{ + .allocator = allocator, + .argv = test_args.span(), + .env_map = &env_map, + .max_output_bytes = max_doc_file_size, + }); switch (result.term) { .Exited => |exit_code| { if (exit_code == 0) { warn("{}\nThe following command incorrectly succeeded:\n", .{result.stderr}); - for (test_args.toSliceConst()) |arg| + for (test_args.span()) |arg| warn("{} ", .{arg}) else warn("\n", .{}); @@ -1340,7 +1354,7 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: var }, else => { warn("{}\nThe following command crashed:\n", .{result.stderr}); - for (test_args.toSliceConst()) |arg| + for (test_args.span()) |arg| warn("{} ", .{arg}) else warn("\n", .{}); @@ -1418,12 +1432,17 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: var } if (maybe_error_match) |error_match| { - const result = try ChildProcess.exec(allocator, build_args.toSliceConst(), null, &env_map, max_doc_file_size); + const result = try ChildProcess.exec(.{ + .allocator = allocator, + .argv = build_args.span(), + .env_map = &env_map, + .max_output_bytes = max_doc_file_size, + }); switch (result.term) { .Exited => |exit_code| { if (exit_code == 0) { warn("{}\nThe following command incorrectly succeeded:\n", .{result.stderr}); - for (build_args.toSliceConst()) |arg| + for (build_args.span()) |arg| warn("{} ", .{arg}) else warn("\n", .{}); @@ -1432,7 +1451,7 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: var }, else => { warn("{}\nThe following command crashed:\n", .{result.stderr}); - for (build_args.toSliceConst()) |arg| + for (build_args.span()) |arg| warn("{} ", .{arg}) else warn("\n", .{}); @@ -1447,7 +1466,7 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: var const colored_stderr = try termColor(allocator, escaped_stderr); try out.print("\n{}", .{colored_stderr}); } else { - _ = exec(allocator, &env_map, build_args.toSliceConst()) catch return parseError(tokenizer, code.source_token, "example failed to compile", .{}); + _ = exec(allocator, &env_map, build_args.span()) catch return parseError(tokenizer, code.source_token, "example failed to compile", .{}); } if (!code.is_inline) { try out.print("</code></pre>\n", .{}); @@ -1484,7 +1503,7 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: var try test_args.appendSlice(&[_][]const u8{ "-target", triple }); try out.print(" -target {}", .{triple}); } - const result = exec(allocator, &env_map, test_args.toSliceConst()) catch return parseError(tokenizer, code.source_token, "test failed", .{}); + const result = exec(allocator, &env_map, test_args.span()) catch return parseError(tokenizer, code.source_token, "test failed", .{}); const escaped_stderr = try escapeHtml(allocator, result.stderr); const escaped_stdout = try escapeHtml(allocator, result.stdout); try out.print("\n{}{}</code></pre>\n", .{ escaped_stderr, escaped_stdout }); @@ -1497,7 +1516,7 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: var } fn exec(allocator: *mem.Allocator, env_map: *std.BufMap, args: []const []const u8) !ChildProcess.ExecResult { - const result = try ChildProcess.exec2(.{ + const result = try ChildProcess.exec(.{ .allocator = allocator, .argv = args, .env_map = env_map, diff --git a/doc/langref.html.in b/doc/langref.html.in index f98b9d674f..3d38d67e00 100644 --- a/doc/langref.html.in +++ b/doc/langref.html.in @@ -4953,7 +4953,7 @@ const mem = std.mem; test "cast *[1][*]const u8 to [*]const ?[*]const u8" { const window_name = [1][*]const u8{"window name"}; const x: [*]const ?[*]const u8 = &window_name; - assert(mem.eql(u8, std.mem.toSliceConst(u8, @ptrCast([*:0]const u8, x[0].?)), "window name")); + assert(mem.eql(u8, std.mem.spanZ(@ptrCast([*:0]const u8, x[0].?)), "window name")); } {#code_end#} {#header_close#} @@ -9310,7 +9310,7 @@ test "string literal to constant slice" { </p> <p> Sometimes the lifetime of a pointer may be more complicated. For example, when using - {#syntax#}std.ArrayList(T).toSlice(){#endsyntax#}, the returned slice has a lifetime that remains + {#syntax#}std.ArrayList(T).span(){#endsyntax#}, the returned slice has a lifetime that remains valid until the next time the list is resized, such as by appending new elements. </p> <p> |
