Commit 9e7ae06249

Andrew Kelley <andrew@ziglang.org>
2020-03-30 20:23:22
std lib API deprecations for the upcoming 0.6.0 release
See #3811
1 parent b980568
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,
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>
lib/std/atomic/queue.zig
@@ -227,7 +227,7 @@ fn startPuts(ctx: *Context) u8 {
     var r = std.rand.DefaultPrng.init(0xdeadbeef);
     while (put_count != 0) : (put_count -= 1) {
         std.time.sleep(1); // let the os scheduler be our fuzz
-        const x = @bitCast(i32, r.random.scalar(u32));
+        const x = @bitCast(i32, r.random.int(u32));
         const node = ctx.allocator.create(Queue(i32).Node) catch unreachable;
         node.* = .{
             .prev = undefined,
lib/std/atomic/stack.zig
@@ -150,7 +150,7 @@ fn startPuts(ctx: *Context) u8 {
     var r = std.rand.DefaultPrng.init(0xdeadbeef);
     while (put_count != 0) : (put_count -= 1) {
         std.time.sleep(1); // let the os scheduler be our fuzz
-        const x = @bitCast(i32, r.random.scalar(u32));
+        const x = @bitCast(i32, r.random.int(u32));
         const node = ctx.allocator.create(Stack(i32).Node) catch unreachable;
         node.* = Stack(i32).Node{
             .next = undefined,
lib/std/build/emit_raw.zig
@@ -72,7 +72,7 @@ const BinaryElfOutput = struct {
                 newSegment.binaryOffset = 0;
                 newSegment.firstSection = null;
 
-                for (self.sections.toSlice()) |section| {
+                for (self.sections.span()) |section| {
                     if (sectionWithinSegment(section, phdr)) {
                         if (section.segment) |sectionSegment| {
                             if (sectionSegment.elfOffset > newSegment.elfOffset) {
@@ -92,7 +92,7 @@ const BinaryElfOutput = struct {
             }
         }
 
-        sort.sort(*BinaryElfSegment, self.segments.toSlice(), segmentSortCompare);
+        sort.sort(*BinaryElfSegment, self.segments.span(), segmentSortCompare);
 
         if (self.segments.len > 0) {
             const firstSegment = self.segments.at(0);
@@ -105,19 +105,19 @@ const BinaryElfOutput = struct {
 
                 const basePhysicalAddress = firstSegment.physicalAddress;
 
-                for (self.segments.toSlice()) |segment| {
+                for (self.segments.span()) |segment| {
                     segment.binaryOffset = segment.physicalAddress - basePhysicalAddress;
                 }
             }
         }
 
-        for (self.sections.toSlice()) |section| {
+        for (self.sections.span()) |section| {
             if (section.segment) |segment| {
                 section.binaryOffset = segment.binaryOffset + (section.elfOffset - segment.elfOffset);
             }
         }
 
-        sort.sort(*BinaryElfSection, self.sections.toSlice(), sectionSortCompare);
+        sort.sort(*BinaryElfSection, self.sections.span(), sectionSortCompare);
 
         return self;
     }
@@ -165,7 +165,7 @@ fn emitRaw(allocator: *Allocator, elf_path: []const u8, raw_path: []const u8) !v
     var binary_elf_output = try BinaryElfOutput.parse(allocator, elf_file);
     defer binary_elf_output.deinit();
 
-    for (binary_elf_output.sections.toSlice()) |section| {
+    for (binary_elf_output.sections.span()) |section| {
         try writeBinaryElfSection(elf_file, out_file, section);
     }
 }
lib/std/build/run.zig
@@ -139,7 +139,7 @@ pub const RunStep = struct {
         const cwd = if (self.cwd) |cwd| self.builder.pathFromRoot(cwd) else self.builder.build_root;
 
         var argv_list = ArrayList([]const u8).init(self.builder.allocator);
-        for (self.argv.toSlice()) |arg| {
+        for (self.argv.span()) |arg| {
             switch (arg) {
                 Arg.Bytes => |bytes| try argv_list.append(bytes),
                 Arg.Artifact => |artifact| {
@@ -153,7 +153,7 @@ pub const RunStep = struct {
             }
         }
 
-        const argv = argv_list.toSliceConst();
+        const argv = argv_list.span();
 
         const child = std.ChildProcess.init(argv, self.builder.allocator) catch unreachable;
         defer child.deinit();
@@ -289,7 +289,7 @@ pub const RunStep = struct {
     }
 
     fn addPathForDynLibs(self: *RunStep, artifact: *LibExeObjStep) void {
-        for (artifact.link_objects.toSliceConst()) |link_object| {
+        for (artifact.link_objects.span()) |link_object| {
             switch (link_object) {
                 .OtherStep => |other| {
                     if (other.target.isWindows() and other.isDynamicLibrary()) {
lib/std/build/translate_c.zig
@@ -71,7 +71,7 @@ pub const TranslateCStep = struct {
 
         try argv_list.append(self.source.getPath(self.builder));
 
-        const output_path_nl = try self.builder.execFromStep(argv_list.toSliceConst(), &self.step);
+        const output_path_nl = try self.builder.execFromStep(argv_list.span(), &self.step);
         const output_path = mem.trimRight(u8, output_path_nl, "\r\n");
 
         self.out_basename = fs.path.basename(output_path);
lib/std/build/write_file.zig
@@ -59,7 +59,7 @@ pub const WriteFileStep = struct {
         // new random bytes when WriteFileStep implementation is modified
         // in a non-backwards-compatible way.
         hash.update("eagVR1dYXoE7ARDP");
-        for (self.files.toSliceConst()) |file| {
+        for (self.files.span()) |file| {
             hash.update(file.basename);
             hash.update(file.bytes);
             hash.update("|");
@@ -80,7 +80,7 @@ pub const WriteFileStep = struct {
         };
         var dir = try fs.cwd().openDir(self.output_dir, .{});
         defer dir.close();
-        for (self.files.toSliceConst()) |file| {
+        for (self.files.span()) |file| {
             dir.writeFile(file.basename, file.bytes) catch |err| {
                 warn("unable to write {} into {}: {}\n", .{
                     file.basename,
lib/std/crypto/gimli.zig
@@ -23,10 +23,12 @@ pub const State = struct {
 
     const Self = @This();
 
+    /// TODO follow the span() convention instead of having this and `toSliceConst`
     pub fn toSlice(self: *Self) []u8 {
         return mem.sliceAsBytes(self.data[0..]);
     }
 
+    /// TODO follow the span() convention instead of having this and `toSlice`
     pub fn toSliceConst(self: *Self) []const u8 {
         return mem.sliceAsBytes(self.data[0..]);
     }
lib/std/event/loop.zig
@@ -1096,10 +1096,10 @@ pub const Loop = struct {
                         msg.result = noasync os.preadv(msg.fd, msg.iov, msg.offset);
                     },
                     .open => |*msg| {
-                        msg.result = noasync os.openC(msg.path, msg.flags, msg.mode);
+                        msg.result = noasync os.openZ(msg.path, msg.flags, msg.mode);
                     },
                     .openat => |*msg| {
-                        msg.result = noasync os.openatC(msg.fd, msg.path, msg.flags, msg.mode);
+                        msg.result = noasync os.openatZ(msg.fd, msg.path, msg.flags, msg.mode);
                     },
                     .faccessat => |*msg| {
                         msg.result = noasync os.faccessatZ(msg.dirfd, msg.path, msg.mode, msg.flags);
lib/std/fs/file.zig
@@ -89,7 +89,7 @@ pub const File = struct {
         if (self.isTty()) {
             if (self.handle == os.STDOUT_FILENO or self.handle == os.STDERR_FILENO) {
                 // Use getenvC to workaround https://github.com/ziglang/zig/issues/3511
-                if (os.getenvC("TERM")) |term| {
+                if (os.getenvZ("TERM")) |term| {
                     if (std.mem.eql(u8, term, "dumb"))
                         return false;
                 }
lib/std/fs/get_app_data_dir.zig
@@ -24,7 +24,7 @@ pub fn getAppDataDir(allocator: *mem.Allocator, appname: []const u8) GetAppDataD
             )) {
                 os.windows.S_OK => {
                     defer os.windows.ole32.CoTaskMemFree(@ptrCast(*c_void, dir_path_ptr));
-                    const global_dir = unicode.utf16leToUtf8Alloc(allocator, mem.toSliceConst(u16, dir_path_ptr)) catch |err| switch (err) {
+                    const global_dir = unicode.utf16leToUtf8Alloc(allocator, mem.spanZ(dir_path_ptr)) catch |err| switch (err) {
                         error.UnexpectedSecondSurrogateHalf => return error.AppDataDirUnavailable,
                         error.ExpectedSecondSurrogateHalf => return error.AppDataDirUnavailable,
                         error.DanglingSurrogateHalf => return error.AppDataDirUnavailable,
lib/std/fs/path.zig
@@ -128,11 +128,13 @@ test "join" {
     testJoinPosix(&[_][]const u8{ "a/", "/c" }, "a/c");
 }
 
-pub fn isAbsoluteC(path_c: [*:0]const u8) bool {
+pub const isAbsoluteC = @compileError("deprecated: renamed to isAbsoluteZ");
+
+pub fn isAbsoluteZ(path_c: [*:0]const u8) bool {
     if (builtin.os.tag == .windows) {
-        return isAbsoluteWindowsC(path_c);
+        return isAbsoluteWindowsZ(path_c);
     } else {
-        return isAbsolutePosixC(path_c);
+        return isAbsolutePosixZ(path_c);
     }
 }
 
@@ -172,19 +174,23 @@ pub fn isAbsoluteWindows(path: []const u8) bool {
 }
 
 pub fn isAbsoluteWindowsW(path_w: [*:0]const u16) bool {
-    return isAbsoluteWindowsImpl(u16, mem.toSliceConst(u16, path_w));
+    return isAbsoluteWindowsImpl(u16, mem.spanZ(path_w));
 }
 
-pub fn isAbsoluteWindowsC(path_c: [*:0]const u8) bool {
-    return isAbsoluteWindowsImpl(u8, mem.toSliceConst(u8, path_c));
+pub const isAbsoluteWindowsC = @compileError("deprecated: renamed to isAbsoluteWindowsZ");
+
+pub fn isAbsoluteWindowsZ(path_c: [*:0]const u8) bool {
+    return isAbsoluteWindowsImpl(u8, mem.spanZ(path_c));
 }
 
 pub fn isAbsolutePosix(path: []const u8) bool {
     return path.len > 0 and path[0] == sep_posix;
 }
 
-pub fn isAbsolutePosixC(path_c: [*:0]const u8) bool {
-    return isAbsolutePosix(mem.toSliceConst(u8, path_c));
+pub const isAbsolutePosixC = @compileError("deprecated: renamed to isAbsolutePosixZ");
+
+pub fn isAbsolutePosixZ(path_c: [*:0]const u8) bool {
+    return isAbsolutePosix(mem.spanZ(path_c));
 }
 
 test "isAbsoluteWindows" {
lib/std/fs/watch.zig
@@ -326,7 +326,7 @@ pub fn Watch(comptime V: type) type {
             var basename_with_null_consumed = false;
             defer if (!basename_with_null_consumed) self.allocator.free(basename_with_null);
 
-            const wd = try os.inotify_add_watchC(
+            const wd = try os.inotify_add_watchZ(
                 self.os_data.inotify_fd,
                 dirname_with_null.ptr,
                 os.linux.IN_CLOSE_WRITE | os.linux.IN_ONLYDIR | os.linux.IN_EXCL_UNLINK,
lib/std/http/headers.zig
@@ -129,7 +129,7 @@ pub const Headers = struct {
             self.index.deinit();
         }
         {
-            for (self.data.toSliceConst()) |entry| {
+            for (self.data.span()) |entry| {
                 entry.deinit();
             }
             self.data.deinit();
@@ -141,14 +141,14 @@ pub const Headers = struct {
         errdefer other.deinit();
         try other.data.ensureCapacity(self.data.len);
         try other.index.initCapacity(self.index.entries.len);
-        for (self.data.toSliceConst()) |entry| {
+        for (self.data.span()) |entry| {
             try other.append(entry.name, entry.value, entry.never_index);
         }
         return other;
     }
 
     pub fn toSlice(self: Self) []const HeaderEntry {
-        return self.data.toSliceConst();
+        return self.data.span();
     }
 
     pub fn append(self: *Self, name: []const u8, value: []const u8, never_index: ?bool) !void {
@@ -279,7 +279,7 @@ pub const Headers = struct {
 
         const buf = try allocator.alloc(HeaderEntry, dex.len);
         var n: usize = 0;
-        for (dex.toSliceConst()) |idx| {
+        for (dex.span()) |idx| {
             buf[n] = self.data.at(idx);
             n += 1;
         }
@@ -302,7 +302,7 @@ pub const Headers = struct {
         // adapted from mem.join
         const total_len = blk: {
             var sum: usize = dex.len - 1; // space for separator(s)
-            for (dex.toSliceConst()) |idx|
+            for (dex.span()) |idx|
                 sum += self.data.at(idx).value.len;
             break :blk sum;
         };
@@ -334,7 +334,7 @@ pub const Headers = struct {
             }
         }
         { // fill up indexes again; we know capacity is fine from before
-            for (self.data.toSliceConst()) |entry, i| {
+            for (self.data.span()) |entry, i| {
                 var dex = &self.index.get(entry.name).?.value;
                 dex.appendAssumeCapacity(i);
             }
@@ -495,8 +495,8 @@ test "Headers.getIndices" {
     try h.append("set-cookie", "y=2", null);
 
     testing.expect(null == h.getIndices("not-present"));
-    testing.expectEqualSlices(usize, &[_]usize{0}, h.getIndices("foo").?.toSliceConst());
-    testing.expectEqualSlices(usize, &[_]usize{ 1, 2 }, h.getIndices("set-cookie").?.toSliceConst());
+    testing.expectEqualSlices(usize, &[_]usize{0}, h.getIndices("foo").?.span());
+    testing.expectEqualSlices(usize, &[_]usize{ 1, 2 }, h.getIndices("set-cookie").?.span());
 }
 
 test "Headers.get" {
lib/std/io/buffered_atomic_file.zig
@@ -15,6 +15,7 @@ pub const BufferedAtomicFile = struct {
 
     /// TODO when https://github.com/ziglang/zig/issues/2761 is solved
     /// this API will not need an allocator
+    /// TODO integrate this with Dir API
     pub fn create(allocator: *mem.Allocator, dest_path: []const u8) !*BufferedAtomicFile {
         var self = try allocator.create(BufferedAtomicFile);
         self.* = BufferedAtomicFile{
@@ -25,7 +26,7 @@ pub const BufferedAtomicFile = struct {
         };
         errdefer allocator.destroy(self);
 
-        self.atomic_file = try fs.AtomicFile.init(dest_path, File.default_mode);
+        self.atomic_file = try fs.cwd().atomicFile(dest_path, .{});
         errdefer self.atomic_file.deinit();
 
         self.file_stream = self.atomic_file.file.outStream();
lib/std/io/c_out_stream.zig
@@ -36,7 +36,7 @@ test "" {
     const out_file = std.c.fopen(filename, "w") orelse return error.UnableToOpenTestFile;
     defer {
         _ = std.c.fclose(out_file);
-        fs.cwd().deleteFileC(filename) catch {};
+        fs.cwd().deleteFileZ(filename) catch {};
     }
 
     const out_stream = &io.COutStream.init(out_file).stream;
lib/std/io/in_stream.zig
@@ -48,13 +48,7 @@ pub fn InStream(
             if (amt_read < buf.len) return error.EndOfStream;
         }
 
-        /// Deprecated: use `readAllArrayList`.
-        pub fn readAllBuffer(self: Self, buffer: *Buffer, max_size: usize) !void {
-            buffer.list.shrink(0);
-            try self.readAllArrayList(&buffer.list, max_size);
-            errdefer buffer.shrink(0);
-            try buffer.list.append(0);
-        }
+        pub const readAllBuffer = @compileError("deprecated; use readAllArrayList()");
 
         /// Appends to the `std.ArrayList` contents by reading from the stream until end of stream is found.
         /// If the number of bytes appended would exceed `max_append_size`, `error.StreamTooLong` is returned
lib/std/json/write_stream.zig
@@ -211,7 +211,7 @@ pub fn WriteStream(comptime OutStream: type, comptime max_depth: usize) type {
                 .String => |inner| try self.emitString(inner),
                 .Array => |inner| {
                     try self.beginArray();
-                    for (inner.toSliceConst()) |elem| {
+                    for (inner.span()) |elem| {
                         try self.arrayElem();
                         try self.emitJson(elem);
                     }
lib/std/os/linux/vdso.zig
@@ -22,7 +22,7 @@ pub fn lookup(vername: []const u8, name: []const u8) usize {
         }) {
             const this_ph = @intToPtr(*elf.Phdr, ph_addr);
             switch (this_ph.p_type) {
-                // On WSL1 as well as older kernels, the VDSO ELF image is pre-linked in the upper half 
+                // On WSL1 as well as older kernels, the VDSO ELF image is pre-linked in the upper half
                 // of the memory space (e.g. p_vaddr = 0xffffffffff700000 on WSL1).
                 // Wrapping operations are used on this line as well as subsequent calculations relative to base
                 // (lines 47, 78) to ensure no overflow check is tripped.
@@ -70,7 +70,7 @@ pub fn lookup(vername: []const u8, name: []const u8) usize {
         if (0 == (@as(u32, 1) << @intCast(u5, syms[i].st_info >> 4) & OK_BINDS)) continue;
         if (0 == syms[i].st_shndx) continue;
         const sym_name = @ptrCast([*:0]const u8, strings + syms[i].st_name);
-        if (!mem.eql(u8, name, mem.toSliceConst(u8, sym_name))) continue;
+        if (!mem.eql(u8, name, mem.spanZ(sym_name))) continue;
         if (maybe_versym) |versym| {
             if (!checkver(maybe_verdef.?, versym[i], vername, strings))
                 continue;
@@ -93,5 +93,5 @@ fn checkver(def_arg: *elf.Verdef, vsym_arg: i32, vername: []const u8, strings: [
     }
     const aux = @intToPtr(*elf.Verdaux, @ptrToInt(def) + def.vd_aux);
     const vda_name = @ptrCast([*:0]const u8, strings + aux.vda_name);
-    return mem.eql(u8, vername, mem.toSliceConst(u8, vda_name));
+    return mem.eql(u8, vername, mem.spanZ(vda_name));
 }
lib/std/os/test.zig
@@ -18,8 +18,8 @@ const AtomicOrder = builtin.AtomicOrder;
 
 test "makePath, put some files in it, deleteTree" {
     try fs.cwd().makePath("os_test_tmp" ++ fs.path.sep_str ++ "b" ++ fs.path.sep_str ++ "c");
-    try io.writeFile("os_test_tmp" ++ fs.path.sep_str ++ "b" ++ fs.path.sep_str ++ "c" ++ fs.path.sep_str ++ "file.txt", "nonsense");
-    try io.writeFile("os_test_tmp" ++ fs.path.sep_str ++ "b" ++ fs.path.sep_str ++ "file2.txt", "blah");
+    try fs.cwd().writeFile("os_test_tmp" ++ fs.path.sep_str ++ "b" ++ fs.path.sep_str ++ "c" ++ fs.path.sep_str ++ "file.txt", "nonsense");
+    try fs.cwd().writeFile("os_test_tmp" ++ fs.path.sep_str ++ "b" ++ fs.path.sep_str ++ "file2.txt", "blah");
     try fs.cwd().deleteTree("os_test_tmp");
     if (fs.cwd().openDir("os_test_tmp", .{})) |dir| {
         @panic("expected error");
@@ -36,8 +36,8 @@ test "access file" {
         expect(err == error.FileNotFound);
     }
 
-    try io.writeFile("os_test_tmp" ++ fs.path.sep_str ++ "file.txt", "");
-    try os.access("os_test_tmp" ++ fs.path.sep_str ++ "file.txt", os.F_OK);
+    try fs.cwd().writeFile("os_test_tmp" ++ fs.path.sep_str ++ "file.txt", "");
+    try fs.cwd().access("os_test_tmp" ++ fs.path.sep_str ++ "file.txt", .{});
     try fs.cwd().deleteTree("os_test_tmp");
 }
 
@@ -65,12 +65,12 @@ test "sendfile" {
         },
     };
 
-    var src_file = try dir.createFileC("sendfile1.txt", .{ .read = true });
+    var src_file = try dir.createFileZ("sendfile1.txt", .{ .read = true });
     defer src_file.close();
 
     try src_file.writevAll(&vecs);
 
-    var dest_file = try dir.createFileC("sendfile2.txt", .{ .read = true });
+    var dest_file = try dir.createFileZ("sendfile2.txt", .{ .read = true });
     defer dest_file.close();
 
     const header1 = "header1\n";
@@ -192,12 +192,12 @@ test "AtomicFile" {
         \\ this is a test file
     ;
     {
-        var af = try fs.AtomicFile.init(test_out_file, File.default_mode);
+        var af = try fs.cwd().atomicFile(test_out_file, .{});
         defer af.deinit();
         try af.file.writeAll(test_content);
         try af.finish();
     }
-    const content = try io.readFileAlloc(testing.allocator, test_out_file);
+    const content = try fs.cwd().readFileAlloc(testing.allocator, test_out_file, 9999);
     defer testing.allocator.free(content);
     expect(mem.eql(u8, content, test_content));
 
lib/std/os/windows.zig
@@ -118,7 +118,7 @@ pub fn OpenFileW(
 
     var result: HANDLE = undefined;
 
-    const path_len_bytes = math.cast(u16, mem.toSliceConst(u16, sub_path_w).len * 2) catch |err| switch (err) {
+    const path_len_bytes = math.cast(u16, mem.lenZ(sub_path_w) * 2) catch |err| switch (err) {
         error.Overflow => return error.NameTooLong,
     };
     var nt_name = UNICODE_STRING{
@@ -685,7 +685,7 @@ pub fn CreateDirectoryW(
     sub_path_w: [*:0]const u16,
     sa: ?*SECURITY_ATTRIBUTES,
 ) CreateDirectoryError!HANDLE {
-    const path_len_bytes = math.cast(u16, mem.toSliceConst(u16, sub_path_w).len * 2) catch |err| switch (err) {
+    const path_len_bytes = math.cast(u16, mem.lenZ(sub_path_w) * 2) catch |err| switch (err) {
         error.Overflow => return error.NameTooLong,
     };
     var nt_name = UNICODE_STRING{
@@ -1214,7 +1214,7 @@ pub fn nanoSecondsToFileTime(ns: i64) FILETIME {
 }
 
 pub fn cStrToPrefixedFileW(s: [*:0]const u8) ![PATH_MAX_WIDE:0]u16 {
-    return sliceToPrefixedFileW(mem.toSliceConst(u8, s));
+    return sliceToPrefixedFileW(mem.spanZ(s));
 }
 
 pub fn sliceToPrefixedFileW(s: []const u8) ![PATH_MAX_WIDE:0]u16 {
lib/std/special/build_runner.zig
@@ -116,7 +116,7 @@ pub fn main() !void {
     if (builder.validateUserInputDidItFail())
         return usageAndErr(builder, true, stderr_stream);
 
-    builder.make(targets.toSliceConst()) catch |err| {
+    builder.make(targets.span()) catch |err| {
         switch (err) {
             error.InvalidStepName => {
                 return usageAndErr(builder, true, stderr_stream);
@@ -151,7 +151,7 @@ fn usage(builder: *Builder, already_ran_build: bool, out_stream: var) !void {
     , .{builder.zig_exe});
 
     const allocator = builder.allocator;
-    for (builder.top_level_steps.toSliceConst()) |top_level_step| {
+    for (builder.top_level_steps.span()) |top_level_step| {
         const name = if (&top_level_step.step == builder.default_step)
             try fmt.allocPrint(allocator, "{} (default)", .{top_level_step.step.name})
         else
@@ -174,7 +174,7 @@ fn usage(builder: *Builder, already_ran_build: bool, out_stream: var) !void {
     if (builder.available_options_list.len == 0) {
         try out_stream.print("  (none)\n", .{});
     } else {
-        for (builder.available_options_list.toSliceConst()) |option| {
+        for (builder.available_options_list.span()) |option| {
             const name = try fmt.allocPrint(allocator, "  -D{}=[{}]", .{
                 option.name,
                 Builder.typeIdName(option.type_id),
lib/std/zig/render.zig
@@ -1531,7 +1531,7 @@ fn renderExpression(
                 try renderToken(tree, stream, callconv_rparen, indent, start_col, Space.Space); // )
             } else if (cc_rewrite_str) |str| {
                 try stream.writeAll("callconv(");
-                try stream.writeAll(mem.toSliceConst(u8, str));
+                try stream.writeAll(mem.spanZ(str));
                 try stream.writeAll(") ");
             }
 
lib/std/zig/system.zig
@@ -119,7 +119,7 @@ pub const NativePaths = struct {
     }
 
     fn deinitArray(array: *ArrayList([:0]u8)) void {
-        for (array.toSlice()) |item| {
+        for (array.span()) |item| {
             array.allocator.free(item);
         }
         array.deinit();
@@ -201,7 +201,7 @@ pub const NativeTargetInfo = struct {
             switch (Target.current.os.tag) {
                 .linux => {
                     const uts = std.os.uname();
-                    const release = mem.toSliceConst(u8, &uts.release);
+                    const release = mem.spanZ(&uts.release);
                     // The release field may have several other fields after the
                     // kernel version
                     const kernel_version = if (mem.indexOfScalar(u8, release, '-')) |pos|
@@ -265,7 +265,7 @@ pub const NativeTargetInfo = struct {
                     // The osproductversion sysctl was introduced first with
                     // High Sierra, thankfully that's also the baseline that Zig
                     // supports
-                    std.os.sysctlbynameC(
+                    std.os.sysctlbynameZ(
                         "kern.osproductversion",
                         &product_version,
                         &size,
@@ -460,7 +460,7 @@ pub const NativeTargetInfo = struct {
             return result;
         }
 
-        const env_file = std.fs.openFileAbsoluteC("/usr/bin/env", .{}) catch |err| switch (err) {
+        const env_file = std.fs.openFileAbsoluteZ("/usr/bin/env", .{}) catch |err| switch (err) {
             error.NoSpaceLeft => unreachable,
             error.NameTooLong => unreachable,
             error.PathAlreadyExists => unreachable,
@@ -512,7 +512,7 @@ pub const NativeTargetInfo = struct {
 
     fn glibcVerFromSO(so_path: [:0]const u8) !std.builtin.Version {
         var link_buf: [std.os.PATH_MAX]u8 = undefined;
-        const link_name = std.os.readlinkC(so_path.ptr, &link_buf) catch |err| switch (err) {
+        const link_name = std.os.readlinkZ(so_path.ptr, &link_buf) catch |err| switch (err) {
             error.AccessDenied => return error.GnuLibCVersionUnavailable,
             error.FileSystem => return error.FileSystem,
             error.SymLinkLoop => return error.SymLinkLoop,
@@ -736,7 +736,7 @@ pub const NativeTargetInfo = struct {
                         );
                         const sh_name_off = elfInt(is_64, need_bswap, sh32.sh_name, sh64.sh_name);
                         // TODO this pointer cast should not be necessary
-                        const sh_name = mem.toSliceConst(u8, @ptrCast([*:0]u8, shstrtab[sh_name_off..].ptr));
+                        const sh_name = mem.spanZ(@ptrCast([*:0]u8, shstrtab[sh_name_off..].ptr));
                         if (mem.eql(u8, sh_name, ".dynstr")) {
                             break :find_dyn_str .{
                                 .offset = elfInt(is_64, need_bswap, sh32.sh_offset, sh64.sh_offset),
@@ -751,7 +751,7 @@ pub const NativeTargetInfo = struct {
                     const strtab_read_len = try preadMin(file, &strtab_buf, ds.offset, shstrtab_len);
                     const strtab = strtab_buf[0..strtab_read_len];
                     // TODO this pointer cast should not be necessary
-                    const rpath_list = mem.toSliceConst(u8, @ptrCast([*:0]u8, strtab[rpoff..].ptr));
+                    const rpath_list = mem.spanZ(@ptrCast([*:0]u8, strtab[rpoff..].ptr));
                     var it = mem.tokenize(rpath_list, ":");
                     while (it.next()) |rpath| {
                         var dir = fs.cwd().openDir(rpath, .{}) catch |err| switch (err) {
@@ -776,7 +776,7 @@ pub const NativeTargetInfo = struct {
                         defer dir.close();
 
                         var link_buf: [std.os.PATH_MAX]u8 = undefined;
-                        const link_name = std.os.readlinkatC(
+                        const link_name = std.os.readlinkatZ(
                             dir.fd,
                             glibc_so_basename,
                             &link_buf,
lib/std/buffer.zig
@@ -43,7 +43,7 @@ pub const Buffer = struct {
 
     /// Must deinitialize with deinit.
     pub fn initFromBuffer(buffer: Buffer) !Buffer {
-        return Buffer.init(buffer.list.allocator, buffer.toSliceConst());
+        return Buffer.init(buffer.list.allocator, buffer.span());
     }
 
     /// Buffer takes ownership of the passed in slice. The slice must have been
@@ -81,15 +81,8 @@ pub const Buffer = struct {
         return self.list.span()[0..self.len() :0];
     }
 
-    /// Deprecated: use `span`
-    pub fn toSlice(self: Buffer) [:0]u8 {
-        return self.span();
-    }
-
-    /// Deprecated: use `span`
-    pub fn toSliceConst(self: Buffer) [:0]const u8 {
-        return self.span();
-    }
+    pub const toSlice = @compileError("deprecated; use span()");
+    pub const toSliceConst = @compileError("deprecated; use span()");
 
     pub fn shrink(self: *Buffer, new_len: usize) void {
         assert(new_len <= self.len());
@@ -120,17 +113,17 @@ pub const Buffer = struct {
     pub fn append(self: *Buffer, m: []const u8) !void {
         const old_len = self.len();
         try self.resize(old_len + m.len);
-        mem.copy(u8, self.list.toSlice()[old_len..], m);
+        mem.copy(u8, self.list.span()[old_len..], m);
     }
 
     pub fn appendByte(self: *Buffer, byte: u8) !void {
         const old_len = self.len();
         try self.resize(old_len + 1);
-        self.list.toSlice()[old_len] = byte;
+        self.list.span()[old_len] = byte;
     }
 
     pub fn eql(self: Buffer, m: []const u8) bool {
-        return mem.eql(u8, self.toSliceConst(), m);
+        return mem.eql(u8, self.span(), m);
     }
 
     pub fn startsWith(self: Buffer, m: []const u8) bool {
@@ -147,7 +140,7 @@ pub const Buffer = struct {
 
     pub fn replaceContents(self: *Buffer, m: []const u8) !void {
         try self.resize(m.len);
-        mem.copy(u8, self.list.toSlice(), m);
+        mem.copy(u8, self.list.span(), m);
     }
 
     pub fn outStream(self: *Buffer) std.io.OutStream(*Buffer, error{OutOfMemory}, appendWrite) {
@@ -171,17 +164,17 @@ test "simple Buffer" {
     try buf.append(" ");
     try buf.append("world");
     testing.expect(buf.eql("hello world"));
-    testing.expect(mem.eql(u8, mem.toSliceConst(u8, buf.toSliceConst().ptr), buf.toSliceConst()));
+    testing.expect(mem.eql(u8, mem.spanZ(buf.span().ptr), buf.span()));
 
     var buf2 = try Buffer.initFromBuffer(buf);
     defer buf2.deinit();
-    testing.expect(buf.eql(buf2.toSliceConst()));
+    testing.expect(buf.eql(buf2.span()));
 
     testing.expect(buf.startsWith("hell"));
     testing.expect(buf.endsWith("orld"));
 
     try buf2.resize(4);
-    testing.expect(buf.startsWith(buf2.toSlice()));
+    testing.expect(buf.startsWith(buf2.span()));
 }
 
 test "Buffer.initSize" {
@@ -189,7 +182,7 @@ test "Buffer.initSize" {
     defer buf.deinit();
     testing.expect(buf.len() == 3);
     try buf.append("hello");
-    testing.expect(mem.eql(u8, buf.toSliceConst()[3..], "hello"));
+    testing.expect(mem.eql(u8, buf.span()[3..], "hello"));
 }
 
 test "Buffer.initCapacity" {
@@ -201,7 +194,7 @@ test "Buffer.initCapacity" {
     try buf.append("hello");
     testing.expect(buf.len() == 5);
     testing.expect(buf.capacity() == old_cap);
-    testing.expect(mem.eql(u8, buf.toSliceConst(), "hello"));
+    testing.expect(mem.eql(u8, buf.span(), "hello"));
 }
 
 test "Buffer.print" {
@@ -221,5 +214,5 @@ test "Buffer.outStream" {
     const y: i32 = 1234;
     try buf_stream.print("x: {}\ny: {}\n", .{ x, y });
 
-    testing.expect(mem.eql(u8, buffer.toSlice(), "x: 42\ny: 1234\n"));
+    testing.expect(mem.eql(u8, buffer.span(), "x: 42\ny: 1234\n"));
 }
lib/std/build.zig
@@ -355,7 +355,7 @@ pub const Builder = struct {
             }
         }
 
-        for (wanted_steps.toSliceConst()) |s| {
+        for (wanted_steps.span()) |s| {
             try self.makeOneStep(s);
         }
     }
@@ -372,7 +372,7 @@ pub const Builder = struct {
         const uninstall_tls = @fieldParentPtr(TopLevelStep, "step", uninstall_step);
         const self = @fieldParentPtr(Builder, "uninstall_tls", uninstall_tls);
 
-        for (self.installed_files.toSliceConst()) |installed_file| {
+        for (self.installed_files.span()) |installed_file| {
             const full_path = self.getInstallPath(installed_file.dir, installed_file.path);
             if (self.verbose) {
                 warn("rm {}\n", .{full_path});
@@ -390,7 +390,7 @@ pub const Builder = struct {
         }
         s.loop_flag = true;
 
-        for (s.dependencies.toSlice()) |dep| {
+        for (s.dependencies.span()) |dep| {
             self.makeOneStep(dep) catch |err| {
                 if (err == error.DependencyLoopDetected) {
                     warn("  {}\n", .{s.name});
@@ -405,7 +405,7 @@ pub const Builder = struct {
     }
 
     fn getTopLevelStepByName(self: *Builder, name: []const u8) !*Step {
-        for (self.top_level_steps.toSliceConst()) |top_level_step| {
+        for (self.top_level_steps.span()) |top_level_step| {
             if (mem.eql(u8, top_level_step.step.name, name)) {
                 return &top_level_step.step;
             }
@@ -470,7 +470,7 @@ pub const Builder = struct {
                     return null;
                 },
                 UserValue.Scalar => |s| return &[_][]const u8{s},
-                UserValue.List => |lst| return lst.toSliceConst(),
+                UserValue.List => |lst| return lst.span(),
             },
         }
     }
@@ -866,7 +866,7 @@ pub const Builder = struct {
     pub fn findProgram(self: *Builder, names: []const []const u8, paths: []const []const u8) ![]const u8 {
         // TODO report error for ambiguous situations
         const exe_extension = @as(CrossTarget, .{}).exeFileExt();
-        for (self.search_prefixes.toSliceConst()) |search_prefix| {
+        for (self.search_prefixes.span()) |search_prefix| {
             for (names) |name| {
                 if (fs.path.isAbsolute(name)) {
                     return name;
@@ -1010,7 +1010,7 @@ pub const Builder = struct {
                 .desc = tok_it.rest(),
             });
         }
-        return list.toSliceConst();
+        return list.span();
     }
 
     fn getPkgConfigList(self: *Builder) ![]const PkgConfigPkg {
@@ -1395,7 +1395,7 @@ pub const LibExeObjStep = struct {
         if (isLibCLibrary(name)) {
             return self.is_linking_libc;
         }
-        for (self.link_objects.toSliceConst()) |link_object| {
+        for (self.link_objects.span()) |link_object| {
             switch (link_object) {
                 LinkObject.SystemLib => |n| if (mem.eql(u8, n, name)) return true,
                 else => continue,
@@ -1599,10 +1599,7 @@ pub const LibExeObjStep = struct {
         self.main_pkg_path = dir_path;
     }
 
-    /// Deprecated; just set the field directly.
-    pub fn setDisableGenH(self: *LibExeObjStep, is_disabled: bool) void {
-        self.emit_h = !is_disabled;
-    }
+    pub const setDisableGenH = @compileError("deprecated; set the emit_h field directly");
 
     pub fn setLibCFile(self: *LibExeObjStep, libc_file: ?[]const u8) void {
         self.libc_file = libc_file;
@@ -1762,7 +1759,7 @@ pub const LibExeObjStep = struct {
         self.include_dirs.append(IncludeDir{ .OtherStep = other }) catch unreachable;
 
         // Inherit dependency on system libraries
-        for (other.link_objects.toSliceConst()) |link_object| {
+        for (other.link_objects.span()) |link_object| {
             switch (link_object) {
                 .SystemLib => |name| self.linkSystemLibrary(name),
                 else => continue,
@@ -1802,7 +1799,7 @@ pub const LibExeObjStep = struct {
 
         if (self.root_src) |root_src| try zig_args.append(root_src.getPath(builder));
 
-        for (self.link_objects.toSlice()) |link_object| {
+        for (self.link_objects.span()) |link_object| {
             switch (link_object) {
                 .StaticPath => |static_path| {
                     try zig_args.append("--object");
@@ -1855,7 +1852,7 @@ pub const LibExeObjStep = struct {
                 builder.allocator,
                 &[_][]const u8{ builder.cache_root, builder.fmt("{}_build_options.zig", .{self.name}) },
             );
-            try std.io.writeFile(build_options_file, self.build_options_contents.toSliceConst());
+            try fs.cwd().writeFile(build_options_file, self.build_options_contents.span());
             try zig_args.append("--pkg-begin");
             try zig_args.append("build_options");
             try zig_args.append(builder.pathFromRoot(build_options_file));
@@ -1978,7 +1975,7 @@ pub const LibExeObjStep = struct {
                         try mcpu_buffer.append(feature.name);
                     }
                 }
-                try zig_args.append(mcpu_buffer.toSliceConst());
+                try zig_args.append(mcpu_buffer.span());
             }
 
             if (self.target.dynamic_linker.get()) |dynamic_linker| {
@@ -2040,7 +2037,7 @@ pub const LibExeObjStep = struct {
                 try zig_args.append("--test-cmd-bin");
             },
         }
-        for (self.packages.toSliceConst()) |pkg| {
+        for (self.packages.span()) |pkg| {
             try zig_args.append("--pkg-begin");
             try zig_args.append(pkg.name);
             try zig_args.append(builder.pathFromRoot(pkg.path));
@@ -2057,7 +2054,7 @@ pub const LibExeObjStep = struct {
             try zig_args.append("--pkg-end");
         }
 
-        for (self.include_dirs.toSliceConst()) |include_dir| {
+        for (self.include_dirs.span()) |include_dir| {
             switch (include_dir) {
                 .RawPath => |include_path| {
                     try zig_args.append("-I");
@@ -2075,18 +2072,18 @@ pub const LibExeObjStep = struct {
             }
         }
 
-        for (self.lib_paths.toSliceConst()) |lib_path| {
+        for (self.lib_paths.span()) |lib_path| {
             try zig_args.append("-L");
             try zig_args.append(lib_path);
         }
 
-        for (self.c_macros.toSliceConst()) |c_macro| {
+        for (self.c_macros.span()) |c_macro| {
             try zig_args.append("-D");
             try zig_args.append(c_macro);
         }
 
         if (self.target.isDarwin()) {
-            for (self.framework_dirs.toSliceConst()) |dir| {
+            for (self.framework_dirs.span()) |dir| {
                 try zig_args.append("-F");
                 try zig_args.append(dir);
             }
@@ -2146,12 +2143,12 @@ pub const LibExeObjStep = struct {
         }
 
         if (self.kind == Kind.Test) {
-            try builder.spawnChild(zig_args.toSliceConst());
+            try builder.spawnChild(zig_args.span());
         } else {
             try zig_args.append("--cache");
             try zig_args.append("on");
 
-            const output_dir_nl = try builder.execFromStep(zig_args.toSliceConst(), &self.step);
+            const output_dir_nl = try builder.execFromStep(zig_args.span(), &self.step);
             const build_output_dir = mem.trimRight(u8, output_dir_nl, "\r\n");
 
             if (self.output_dir) |output_dir| {
lib/std/c.zig
@@ -174,7 +174,6 @@ pub extern "c" fn realloc(?*c_void, usize) ?*c_void;
 pub extern "c" fn free(*c_void) void;
 pub extern "c" fn posix_memalign(memptr: **c_void, alignment: usize, size: usize) c_int;
 
-// Deprecated
 pub extern "c" fn futimes(fd: fd_t, times: *[2]timeval) c_int;
 pub extern "c" fn utimes(path: [*:0]const u8, times: *[2]timeval) c_int;
 
lib/std/child_process.zig
@@ -175,29 +175,11 @@ pub const ChildProcess = struct {
         stderr: []u8,
     };
 
-    /// Spawns a child process, waits for it, collecting stdout and stderr, and then returns.
-    /// If it succeeds, the caller owns result.stdout and result.stderr memory.
-    /// TODO deprecate in favor of exec2
-    pub fn exec(
-        allocator: *mem.Allocator,
-        argv: []const []const u8,
-        cwd: ?[]const u8,
-        env_map: ?*const BufMap,
-        max_output_bytes: usize,
-    ) !ExecResult {
-        return exec2(.{
-            .allocator = allocator,
-            .argv = argv,
-            .cwd = cwd,
-            .env_map = env_map,
-            .max_output_bytes = max_output_bytes,
-        });
-    }
+    pub const exec2 = @compileError("deprecated: exec2 is renamed to exec");
 
     /// Spawns a child process, waits for it, collecting stdout and stderr, and then returns.
     /// If it succeeds, the caller owns result.stdout and result.stderr memory.
-    /// TODO rename to exec
-    pub fn exec2(args: struct {
+    pub fn exec(args: struct {
         allocator: *mem.Allocator,
         argv: []const []const u8,
         cwd: ?[]const u8 = null,
@@ -370,7 +352,7 @@ pub const ChildProcess = struct {
 
         const any_ignore = (self.stdin_behavior == StdIo.Ignore or self.stdout_behavior == StdIo.Ignore or self.stderr_behavior == StdIo.Ignore);
         const dev_null_fd = if (any_ignore)
-            os.openC("/dev/null", os.O_RDWR, 0) catch |err| switch (err) {
+            os.openZ("/dev/null", os.O_RDWR, 0) catch |err| switch (err) {
                 error.PathAlreadyExists => unreachable,
                 error.NoSpaceLeft => unreachable,
                 error.FileTooBig => unreachable,
lib/std/coff.zig
@@ -145,7 +145,7 @@ pub const Coff = struct {
         blk: while (i < debug_dir_entry_count) : (i += 1) {
             const debug_dir_entry = try in.readStruct(DebugDirectoryEntry);
             if (debug_dir_entry.type == IMAGE_DEBUG_TYPE_CODEVIEW) {
-                for (self.sections.toSlice()) |*section| {
+                for (self.sections.span()) |*section| {
                     const section_start = section.header.virtual_address;
                     const section_size = section.header.misc.virtual_size;
                     const rva = debug_dir_entry.address_of_raw_data;
@@ -211,7 +211,7 @@ pub const Coff = struct {
     }
 
     pub fn getSection(self: *Coff, comptime name: []const u8) ?*Section {
-        for (self.sections.toSlice()) |*sec| {
+        for (self.sections.span()) |*sec| {
             if (mem.eql(u8, sec.header.name[0..name.len], name)) {
                 return sec;
             }
lib/std/debug.zig
@@ -735,7 +735,7 @@ fn openCoffDebugInfo(allocator: *mem.Allocator, coff_file_path: [:0]const u16) !
         for (present) |_| {
             const name_offset = try pdb_stream.inStream().readIntLittle(u32);
             const name_index = try pdb_stream.inStream().readIntLittle(u32);
-            const name = mem.toSlice(u8, @ptrCast([*:0]u8, name_bytes.ptr + name_offset));
+            const name = mem.spanZ(@ptrCast([*:0]u8, name_bytes.ptr + name_offset));
             if (mem.eql(u8, name, "/names")) {
                 break :str_tab_index name_index;
             }
@@ -1131,7 +1131,7 @@ pub const DebugInfo = struct {
                     const obj_di = try self.allocator.create(ModuleDebugInfo);
                     errdefer self.allocator.destroy(obj_di);
 
-                    const macho_path = mem.toSliceConst(u8, std.c._dyld_get_image_name(i));
+                    const macho_path = mem.spanZ(std.c._dyld_get_image_name(i));
                     obj_di.* = openMachODebugInfo(self.allocator, macho_path) catch |err| switch (err) {
                         error.FileNotFound => return error.MissingDebugInfo,
                         else => return err,
@@ -1254,10 +1254,7 @@ pub const DebugInfo = struct {
                     if (context.address >= seg_start and context.address < seg_end) {
                         // Android libc uses NULL instead of an empty string to mark the
                         // main program
-                        context.name = if (info.dlpi_name) |dlpi_name|
-                            mem.toSliceConst(u8, dlpi_name)
-                        else
-                            "";
+                        context.name = if (info.dlpi_name) |dlpi_name| mem.spanZ(dlpi_name) else "";
                         context.base_address = info.dlpi_addr;
                         // Stop the iteration
                         return error.Found;
@@ -1426,7 +1423,7 @@ pub const ModuleDebugInfo = switch (builtin.os.tag) {
                 return SymbolInfo{};
 
             assert(symbol.ofile.?.n_strx < self.strings.len);
-            const o_file_path = mem.toSliceConst(u8, self.strings.ptr + symbol.ofile.?.n_strx);
+            const o_file_path = mem.spanZ(self.strings.ptr + symbol.ofile.?.n_strx);
 
             // Check if its debug infos are already in the cache
             var o_file_di = self.ofiles.getValue(o_file_path) orelse
@@ -1483,7 +1480,7 @@ pub const ModuleDebugInfo = switch (builtin.os.tag) {
             const mod_index = for (self.sect_contribs) |sect_contrib| {
                 if (sect_contrib.Section > self.coff.sections.len) continue;
                 // Remember that SectionContribEntry.Section is 1-based.
-                coff_section = &self.coff.sections.toSlice()[sect_contrib.Section - 1];
+                coff_section = &self.coff.sections.span()[sect_contrib.Section - 1];
 
                 const vaddr_start = coff_section.header.virtual_address + sect_contrib.Offset;
                 const vaddr_end = vaddr_start + sect_contrib.Size;
@@ -1510,7 +1507,7 @@ pub const ModuleDebugInfo = switch (builtin.os.tag) {
                         const vaddr_start = coff_section.header.virtual_address + proc_sym.CodeOffset;
                         const vaddr_end = vaddr_start + proc_sym.CodeSize;
                         if (relocated_address >= vaddr_start and relocated_address < vaddr_end) {
-                            break mem.toSliceConst(u8, @ptrCast([*:0]u8, proc_sym) + @sizeOf(pdb.ProcSym));
+                            break mem.spanZ(@ptrCast([*:0]u8, proc_sym) + @sizeOf(pdb.ProcSym));
                         }
                     },
                     else => {},
lib/std/dwarf.zig
@@ -82,7 +82,7 @@ const Die = struct {
     };
 
     fn getAttr(self: *const Die, id: u64) ?*const FormValue {
-        for (self.attrs.toSliceConst()) |*attr| {
+        for (self.attrs.span()) |*attr| {
             if (attr.id == id) return &attr.value;
         }
         return null;
@@ -375,7 +375,7 @@ fn parseFormValue(allocator: *mem.Allocator, in_stream: var, form_id: u64, is_64
 }
 
 fn getAbbrevTableEntry(abbrev_table: *const AbbrevTable, abbrev_code: u64) ?*const AbbrevTableEntry {
-    for (abbrev_table.toSliceConst()) |*table_entry| {
+    for (abbrev_table.span()) |*table_entry| {
         if (table_entry.abbrev_code == abbrev_code) return table_entry;
     }
     return null;
@@ -399,7 +399,7 @@ pub const DwarfInfo = struct {
     }
 
     fn getSymbolName(di: *DwarfInfo, address: u64) ?[]const u8 {
-        for (di.func_list.toSliceConst()) |*func| {
+        for (di.func_list.span()) |*func| {
             if (func.pc_range) |range| {
                 if (address >= range.start and address < range.end) {
                     return func.name;
@@ -588,7 +588,7 @@ pub const DwarfInfo = struct {
     }
 
     fn findCompileUnit(di: *DwarfInfo, target_address: u64) !*const CompileUnit {
-        for (di.compile_unit_list.toSlice()) |*compile_unit| {
+        for (di.compile_unit_list.span()) |*compile_unit| {
             if (compile_unit.pc_range) |range| {
                 if (target_address >= range.start and target_address < range.end) return compile_unit;
             }
@@ -636,7 +636,7 @@ pub const DwarfInfo = struct {
     /// Gets an already existing AbbrevTable given the abbrev_offset, or if not found,
     /// seeks in the stream and parses it.
     fn getAbbrevTable(di: *DwarfInfo, abbrev_offset: u64) !*const AbbrevTable {
-        for (di.abbrev_table_list.toSlice()) |*header| {
+        for (di.abbrev_table_list.span()) |*header| {
             if (header.offset == abbrev_offset) {
                 return &header.table;
             }
@@ -690,7 +690,7 @@ pub const DwarfInfo = struct {
             .attrs = ArrayList(Die.Attr).init(di.allocator()),
         };
         try result.attrs.resize(table_entry.attrs.len);
-        for (table_entry.attrs.toSliceConst()) |attr, i| {
+        for (table_entry.attrs.span()) |attr, i| {
             result.attrs.items[i] = Die.Attr{
                 .id = attr.attr_id,
                 .value = try parseFormValue(di.allocator(), in_stream, attr.form_id, is_64),
@@ -757,7 +757,7 @@ pub const DwarfInfo = struct {
         }
 
         var file_entries = ArrayList(FileEntry).init(di.allocator());
-        var prog = LineNumberProgram.init(default_is_stmt, include_directories.toSliceConst(), &file_entries, target_address);
+        var prog = LineNumberProgram.init(default_is_stmt, include_directories.span(), &file_entries, target_address);
 
         while (true) {
             const file_name = try in.readUntilDelimiterAlloc(di.allocator(), 0, math.maxInt(usize));
lib/std/dynamic_library.zig
@@ -254,9 +254,11 @@ pub const ElfDynLib = struct {
         };
     }
 
+    pub const openC = @compileError("deprecated: renamed to openZ");
+
     /// Trusts the file. Malicious file will be able to execute arbitrary code.
-    pub fn openC(path_c: [*:0]const u8) !ElfDynLib {
-        return open(mem.toSlice(u8, path_c));
+    pub fn openZ(path_c: [*:0]const u8) !ElfDynLib {
+        return open(mem.spanZ(path_c));
     }
 
     /// Trusts the file
@@ -285,7 +287,7 @@ pub const ElfDynLib = struct {
             if (0 == (@as(u32, 1) << @intCast(u5, self.syms[i].st_info & 0xf) & OK_TYPES)) continue;
             if (0 == (@as(u32, 1) << @intCast(u5, self.syms[i].st_info >> 4) & OK_BINDS)) continue;
             if (0 == self.syms[i].st_shndx) continue;
-            if (!mem.eql(u8, name, mem.toSliceConst(u8, self.strings + self.syms[i].st_name))) continue;
+            if (!mem.eql(u8, name, mem.spanZ(self.strings + self.syms[i].st_name))) continue;
             if (maybe_versym) |versym| {
                 if (!checkver(self.verdef.?, versym[i], vername, self.strings))
                     continue;
@@ -316,7 +318,7 @@ fn checkver(def_arg: *elf.Verdef, vsym_arg: i32, vername: []const u8, strings: [
         def = @intToPtr(*elf.Verdef, @ptrToInt(def) + def.vd_next);
     }
     const aux = @intToPtr(*elf.Verdaux, @ptrToInt(def) + def.vd_aux);
-    return mem.eql(u8, vername, mem.toSliceConst(u8, strings + aux.vda_name));
+    return mem.eql(u8, vername, mem.spanZ(strings + aux.vda_name));
 }
 
 pub const WindowsDynLib = struct {
@@ -329,7 +331,9 @@ pub const WindowsDynLib = struct {
         return openW(&path_w);
     }
 
-    pub fn openC(path_c: [*:0]const u8) !WindowsDynLib {
+    pub const openC = @compileError("deprecated: renamed to openZ");
+
+    pub fn openZ(path_c: [*:0]const u8) !WindowsDynLib {
         const path_w = try windows.cStrToPrefixedFileW(path_c);
         return openW(&path_w);
     }
@@ -362,10 +366,12 @@ pub const DlDynlib = struct {
 
     pub fn open(path: []const u8) !DlDynlib {
         const path_c = try os.toPosixPath(path);
-        return openC(&path_c);
+        return openZ(&path_c);
     }
 
-    pub fn openC(path_c: [*:0]const u8) !DlDynlib {
+    pub const openC = @compileError("deprecated: renamed to openZ");
+
+    pub fn openZ(path_c: [*:0]const u8) !DlDynlib {
         return DlDynlib{
             .handle = system.dlopen(path_c, system.RTLD_LAZY) orelse {
                 return error.FileNotFound;
lib/std/fs.zig
@@ -11,13 +11,18 @@ const math = std.math;
 pub const path = @import("fs/path.zig");
 pub const File = @import("fs/file.zig").File;
 
+// TODO audit these APIs with respect to Dir and absolute paths
+
 pub const symLink = os.symlink;
-pub const symLinkC = os.symlinkC;
+pub const symLinkZ = os.symlinkZ;
+pub const symLinkC = @compileError("deprecated: renamed to symlinkZ");
 pub const rename = os.rename;
-pub const renameC = os.renameC;
+pub const renameZ = os.renameZ;
+pub const renameC = @compileError("deprecated: renamed to renameZ");
 pub const renameW = os.renameW;
 pub const realpath = os.realpath;
-pub const realpathC = os.realpathC;
+pub const realpathZ = os.realpathZ;
+pub const realpathC = @compileError("deprecated: renamed to realpathZ");
 pub const realpathW = os.realpathW;
 
 pub const getAppDataDir = @import("fs/get_app_data_dir.zig").getAppDataDir;
@@ -120,7 +125,7 @@ pub const AtomicFile = struct {
     file: File,
     // TODO either replace this with rand_buf or use []u16 on Windows
     tmp_path_buf: [TMP_PATH_LEN:0]u8,
-    dest_path: []const u8,
+    dest_basename: []const u8,
     file_open: bool,
     file_exists: bool,
     close_dir_on_deinit: bool,
@@ -131,17 +136,23 @@ pub const AtomicFile = struct {
     const RANDOM_BYTES = 12;
     const TMP_PATH_LEN = base64.Base64Encoder.calcSize(RANDOM_BYTES);
 
-    /// TODO rename this. Callers should go through Dir API
-    pub fn init2(dest_path: []const u8, mode: File.Mode, dir: Dir, close_dir_on_deinit: bool) InitError!AtomicFile {
+    /// Note that the `Dir.atomicFile` API may be more handy than this lower-level function.
+    pub fn init(
+        dest_basename: []const u8,
+        mode: File.Mode,
+        dir: Dir,
+        close_dir_on_deinit: bool,
+    ) InitError!AtomicFile {
         var rand_buf: [RANDOM_BYTES]u8 = undefined;
         var tmp_path_buf: [TMP_PATH_LEN:0]u8 = undefined;
+        // TODO: should be able to use TMP_PATH_LEN here.
         tmp_path_buf[base64.Base64Encoder.calcSize(RANDOM_BYTES)] = 0;
 
         while (true) {
             try crypto.randomBytes(rand_buf[0..]);
             base64_encoder.encode(&tmp_path_buf, &rand_buf);
 
-            const file = dir.createFileC(
+            const file = dir.createFileZ(
                 &tmp_path_buf,
                 .{ .mode = mode, .exclusive = true },
             ) catch |err| switch (err) {
@@ -152,7 +163,7 @@ pub const AtomicFile = struct {
             return AtomicFile{
                 .file = file,
                 .tmp_path_buf = tmp_path_buf,
-                .dest_path = dest_path,
+                .dest_basename = dest_basename,
                 .file_open = true,
                 .file_exists = true,
                 .close_dir_on_deinit = close_dir_on_deinit,
@@ -161,11 +172,6 @@ pub const AtomicFile = struct {
         }
     }
 
-    /// Deprecated. Use `Dir.atomicFile`.
-    pub fn init(dest_path: []const u8, mode: File.Mode) InitError!AtomicFile {
-        return cwd().atomicFile(dest_path, .{ .mode = mode });
-    }
-
     /// always call deinit, even after successful finish()
     pub fn deinit(self: *AtomicFile) void {
         if (self.file_open) {
@@ -173,7 +179,7 @@ pub const AtomicFile = struct {
             self.file_open = false;
         }
         if (self.file_exists) {
-            self.dir.deleteFileC(&self.tmp_path_buf) catch {};
+            self.dir.deleteFileZ(&self.tmp_path_buf) catch {};
             self.file_exists = false;
         }
         if (self.close_dir_on_deinit) {
@@ -189,12 +195,12 @@ pub const AtomicFile = struct {
             self.file_open = false;
         }
         if (std.Target.current.os.tag == .windows) {
-            const dest_path_w = try os.windows.sliceToPrefixedFileW(self.dest_path);
+            const dest_path_w = try os.windows.sliceToPrefixedFileW(self.dest_basename);
             const tmp_path_w = try os.windows.cStrToPrefixedFileW(&self.tmp_path_buf);
             try os.renameatW(self.dir.fd, &tmp_path_w, self.dir.fd, &dest_path_w, os.windows.TRUE);
             self.file_exists = false;
         } else {
-            const dest_path_c = try os.toPosixPath(self.dest_path);
+            const dest_path_c = try os.toPosixPath(self.dest_basename);
             try os.renameatZ(self.dir.fd, &self.tmp_path_buf, self.dir.fd, &dest_path_c);
             self.file_exists = false;
         }
@@ -213,7 +219,7 @@ pub fn makeDirAbsolute(absolute_path: []const u8) !void {
 
 /// Same as `makeDirAbsolute` except the parameter is a null-terminated UTF8-encoded string.
 pub fn makeDirAbsoluteZ(absolute_path_z: [*:0]const u8) !void {
-    assert(path.isAbsoluteC(absolute_path_z));
+    assert(path.isAbsoluteZ(absolute_path_z));
     return os.mkdirZ(absolute_path_z, default_new_dir_mode);
 }
 
@@ -224,18 +230,25 @@ pub fn makeDirAbsoluteW(absolute_path_w: [*:0]const u16) !void {
     os.windows.CloseHandle(handle);
 }
 
-/// Deprecated; use `Dir.deleteDir`.
-pub fn deleteDir(dir_path: []const u8) !void {
+pub const deleteDir = @compileError("deprecated; use dir.deleteDir or deleteDirAbsolute");
+pub const deleteDirC = @compileError("deprecated; use dir.deleteDirZ or deleteDirAbsoluteZ");
+pub const deleteDirW = @compileError("deprecated; use dir.deleteDirW or deleteDirAbsoluteW");
+
+/// Same as `Dir.deleteDir` except the path is absolute.
+pub fn deleteDirAbsolute(dir_path: []const u8) !void {
+    assert(path.isAbsolute(dir_path));
     return os.rmdir(dir_path);
 }
 
-/// Deprecated; use `Dir.deleteDirC`.
-pub fn deleteDirC(dir_path: [*:0]const u8) !void {
-    return os.rmdirC(dir_path);
+/// Same as `deleteDirAbsolute` except the path parameter is null-terminated.
+pub fn deleteDirAbsoluteZ(dir_path: [*:0]const u8) !void {
+    assert(path.isAbsoluteZ(dir_path));
+    return os.rmdirZ(dir_path);
 }
 
-/// Deprecated; use `Dir.deleteDirW`.
-pub fn deleteDirW(dir_path: [*:0]const u16) !void {
+/// Same as `deleteDirAbsolute` except the path parameter is WTF-16 and target OS is assumed Windows.
+pub fn deleteDirAbsoluteW(dir_path: [*:0]const u16) !void {
+    assert(path.isAbsoluteWindowsW(dir_path));
     return os.rmdirW(dir_path);
 }
 
@@ -412,7 +425,7 @@ pub const Dir = struct {
                     const next_index = self.index + linux_entry.reclen();
                     self.index = next_index;
 
-                    const name = mem.toSlice(u8, @ptrCast([*:0]u8, &linux_entry.d_name));
+                    const name = mem.spanZ(@ptrCast([*:0]u8, &linux_entry.d_name));
 
                     // skip . and .. entries
                     if (mem.eql(u8, name, ".") or mem.eql(u8, name, "..")) {
@@ -573,8 +586,7 @@ pub const Dir = struct {
         return self.openFileZ(&path_c, flags);
     }
 
-    /// Deprecated; use `openFileZ`.
-    pub const openFileC = openFileZ;
+    pub const openFileC = @compileError("deprecated: renamed to openFileZ");
 
     /// Same as `openFile` but the path parameter is null-terminated.
     pub fn openFileZ(self: Dir, sub_path: [*:0]const u8, flags: File.OpenFlags) File.OpenError!File {
@@ -592,7 +604,7 @@ pub const Dir = struct {
         const fd = if (need_async_thread and !flags.always_blocking)
             try std.event.Loop.instance.?.openatZ(self.fd, sub_path, os_flags, 0)
         else
-            try os.openatC(self.fd, sub_path, os_flags, 0);
+            try os.openatZ(self.fd, sub_path, os_flags, 0);
         return File{
             .handle = fd,
             .io_mode = .blocking,
@@ -625,11 +637,13 @@ pub const Dir = struct {
             return self.createFileW(&path_w, flags);
         }
         const path_c = try os.toPosixPath(sub_path);
-        return self.createFileC(&path_c, flags);
+        return self.createFileZ(&path_c, flags);
     }
 
+    pub const createFileC = @compileError("deprecated: renamed to createFileZ");
+
     /// Same as `createFile` but the path parameter is null-terminated.
-    pub fn createFileC(self: Dir, sub_path_c: [*:0]const u8, flags: File.CreateFlags) File.OpenError!File {
+    pub fn createFileZ(self: Dir, sub_path_c: [*:0]const u8, flags: File.CreateFlags) File.OpenError!File {
         if (builtin.os.tag == .windows) {
             const path_w = try os.windows.cStrToPrefixedFileW(sub_path_c);
             return self.createFileW(&path_w, flags);
@@ -642,7 +656,7 @@ pub const Dir = struct {
         const fd = if (need_async_thread)
             try std.event.Loop.instance.?.openatZ(self.fd, sub_path_c, os_flags, flags.mode)
         else
-            try os.openatC(self.fd, sub_path_c, os_flags, flags.mode);
+            try os.openatZ(self.fd, sub_path_c, os_flags, flags.mode);
         return File{ .handle = fd, .io_mode = .blocking };
     }
 
@@ -664,27 +678,16 @@ pub const Dir = struct {
         });
     }
 
-    /// Deprecated; call `openFile` directly.
-    pub fn openRead(self: Dir, sub_path: []const u8) File.OpenError!File {
-        return self.openFile(sub_path, .{});
-    }
-
-    /// Deprecated; call `openFileZ` directly.
-    pub fn openReadC(self: Dir, sub_path: [*:0]const u8) File.OpenError!File {
-        return self.openFileZ(sub_path, .{});
-    }
-
-    /// Deprecated; call `openFileW` directly.
-    pub fn openReadW(self: Dir, sub_path: [*:0]const u16) File.OpenError!File {
-        return self.openFileW(sub_path, .{});
-    }
+    pub const openRead = @compileError("deprecated in favor of openFile");
+    pub const openReadC = @compileError("deprecated in favor of openFileZ");
+    pub const openReadW = @compileError("deprecated in favor of openFileW");
 
     pub fn makeDir(self: Dir, sub_path: []const u8) !void {
         try os.mkdirat(self.fd, sub_path, default_new_dir_mode);
     }
 
     pub fn makeDirZ(self: Dir, sub_path: [*:0]const u8) !void {
-        try os.mkdiratC(self.fd, sub_path, default_new_dir_mode);
+        try os.mkdiratZ(self.fd, sub_path, default_new_dir_mode);
     }
 
     pub fn makeDirW(self: Dir, sub_path: [*:0]const u16) !void {
@@ -758,20 +761,22 @@ pub const Dir = struct {
             return self.openDirW(&sub_path_w, args);
         } else {
             const sub_path_c = try os.toPosixPath(sub_path);
-            return self.openDirC(&sub_path_c, args);
+            return self.openDirZ(&sub_path_c, args);
         }
     }
 
+    pub const openDirC = @compileError("deprecated: renamed to openDirZ");
+
     /// Same as `openDir` except the parameter is null-terminated.
-    pub fn openDirC(self: Dir, sub_path_c: [*:0]const u8, args: OpenDirOptions) OpenError!Dir {
+    pub fn openDirZ(self: Dir, sub_path_c: [*:0]const u8, args: OpenDirOptions) OpenError!Dir {
         if (builtin.os.tag == .windows) {
             const sub_path_w = try os.windows.cStrToPrefixedFileW(sub_path_c);
             return self.openDirW(&sub_path_w, args);
         } else if (!args.iterate) {
             const O_PATH = if (@hasDecl(os, "O_PATH")) os.O_PATH else 0;
-            return self.openDirFlagsC(sub_path_c, os.O_DIRECTORY | os.O_RDONLY | os.O_CLOEXEC | O_PATH);
+            return self.openDirFlagsZ(sub_path_c, os.O_DIRECTORY | os.O_RDONLY | os.O_CLOEXEC | O_PATH);
         } else {
-            return self.openDirFlagsC(sub_path_c, os.O_DIRECTORY | os.O_RDONLY | os.O_CLOEXEC);
+            return self.openDirFlagsZ(sub_path_c, os.O_DIRECTORY | os.O_RDONLY | os.O_CLOEXEC);
         }
     }
 
@@ -787,11 +792,11 @@ pub const Dir = struct {
     }
 
     /// `flags` must contain `os.O_DIRECTORY`.
-    fn openDirFlagsC(self: Dir, sub_path_c: [*:0]const u8, flags: u32) OpenError!Dir {
+    fn openDirFlagsZ(self: Dir, sub_path_c: [*:0]const u8, flags: u32) OpenError!Dir {
         const result = if (need_async_thread)
             std.event.Loop.instance.?.openatZ(self.fd, sub_path_c, flags, 0)
         else
-            os.openatC(self.fd, sub_path_c, flags, 0);
+            os.openatZ(self.fd, sub_path_c, flags, 0);
         const fd = result catch |err| switch (err) {
             error.FileTooBig => unreachable, // can't happen for directories
             error.IsDir => unreachable, // we're providing O_DIRECTORY
@@ -809,7 +814,7 @@ pub const Dir = struct {
             .fd = undefined,
         };
 
-        const path_len_bytes = @intCast(u16, mem.toSliceConst(u16, sub_path_w).len * 2);
+        const path_len_bytes = @intCast(u16, mem.lenZ(sub_path_w) * 2);
         var nt_name = w.UNICODE_STRING{
             .Length = path_len_bytes,
             .MaximumLength = path_len_bytes,
@@ -867,9 +872,11 @@ pub const Dir = struct {
         };
     }
 
+    pub const deleteFileC = @compileError("deprecated: renamed to deleteFileZ");
+
     /// Same as `deleteFile` except the parameter is null-terminated.
-    pub fn deleteFileC(self: Dir, sub_path_c: [*:0]const u8) DeleteFileError!void {
-        os.unlinkatC(self.fd, sub_path_c, 0) catch |err| switch (err) {
+    pub fn deleteFileZ(self: Dir, sub_path_c: [*:0]const u8) DeleteFileError!void {
+        os.unlinkatZ(self.fd, sub_path_c, 0) catch |err| switch (err) {
             error.DirNotEmpty => unreachable, // not passing AT_REMOVEDIR
             else => |e| return e,
         };
@@ -908,12 +915,12 @@ pub const Dir = struct {
             return self.deleteDirW(&sub_path_w);
         }
         const sub_path_c = try os.toPosixPath(sub_path);
-        return self.deleteDirC(&sub_path_c);
+        return self.deleteDirZ(&sub_path_c);
     }
 
     /// Same as `deleteDir` except the parameter is null-terminated.
-    pub fn deleteDirC(self: Dir, sub_path_c: [*:0]const u8) DeleteDirError!void {
-        os.unlinkatC(self.fd, sub_path_c, os.AT_REMOVEDIR) catch |err| switch (err) {
+    pub fn deleteDirZ(self: Dir, sub_path_c: [*:0]const u8) DeleteDirError!void {
+        os.unlinkatZ(self.fd, sub_path_c, os.AT_REMOVEDIR) catch |err| switch (err) {
             error.IsDir => unreachable, // not possible since we pass AT_REMOVEDIR
             else => |e| return e,
         };
@@ -933,12 +940,14 @@ pub const Dir = struct {
     /// Asserts that the path parameter has no null bytes.
     pub fn readLink(self: Dir, sub_path: []const u8, buffer: *[MAX_PATH_BYTES]u8) ![]u8 {
         const sub_path_c = try os.toPosixPath(sub_path);
-        return self.readLinkC(&sub_path_c, buffer);
+        return self.readLinkZ(&sub_path_c, buffer);
     }
 
+    pub const readLinkC = @compileError("deprecated: renamed to readLinkZ");
+
     /// Same as `readLink`, except the `pathname` parameter is null-terminated.
-    pub fn readLinkC(self: Dir, sub_path_c: [*:0]const u8, buffer: *[MAX_PATH_BYTES]u8) ![]u8 {
-        return os.readlinkatC(self.fd, sub_path_c, buffer);
+    pub fn readLinkZ(self: Dir, sub_path_c: [*:0]const u8, buffer: *[MAX_PATH_BYTES]u8) ![]u8 {
+        return os.readlinkatZ(self.fd, sub_path_c, buffer);
     }
 
     /// On success, caller owns returned buffer.
@@ -956,7 +965,7 @@ pub const Dir = struct {
         max_bytes: usize,
         comptime A: u29,
     ) ![]align(A) u8 {
-        var file = try self.openRead(file_path);
+        var file = try self.openFile(file_path, .{});
         defer file.close();
 
         const size = math.cast(usize, try file.getEndPos()) catch math.maxInt(usize);
@@ -1280,9 +1289,9 @@ pub const Dir = struct {
     pub fn atomicFile(self: Dir, dest_path: []const u8, options: AtomicFileOptions) !AtomicFile {
         if (path.dirname(dest_path)) |dirname| {
             const dir = try self.openDir(dirname, .{});
-            return AtomicFile.init2(path.basename(dest_path), options.mode, dir, true);
+            return AtomicFile.init(path.basename(dest_path), options.mode, dir, true);
         } else {
-            return AtomicFile.init2(dest_path, options.mode, self, false);
+            return AtomicFile.init(dest_path, options.mode, self, false);
         }
     }
 };
@@ -1309,9 +1318,11 @@ pub fn openFileAbsolute(absolute_path: []const u8, flags: File.OpenFlags) File.O
     return cwd().openFile(absolute_path, flags);
 }
 
+pub const openFileAbsoluteC = @compileError("deprecated: renamed to openFileAbsoluteZ");
+
 /// Same as `openFileAbsolute` but the path parameter is null-terminated.
-pub fn openFileAbsoluteC(absolute_path_c: [*:0]const u8, flags: File.OpenFlags) File.OpenError!File {
-    assert(path.isAbsoluteC(absolute_path_c));
+pub fn openFileAbsoluteZ(absolute_path_c: [*:0]const u8, flags: File.OpenFlags) File.OpenError!File {
+    assert(path.isAbsoluteZ(absolute_path_c));
     return cwd().openFileZ(absolute_path_c, flags);
 }
 
@@ -1332,10 +1343,12 @@ pub fn createFileAbsolute(absolute_path: []const u8, flags: File.CreateFlags) Fi
     return cwd().createFile(absolute_path, flags);
 }
 
+pub const createFileAbsoluteC = @compileError("deprecated: renamed to createFileAbsoluteZ");
+
 /// Same as `createFileAbsolute` but the path parameter is null-terminated.
-pub fn createFileAbsoluteC(absolute_path_c: [*:0]const u8, flags: File.CreateFlags) File.OpenError!File {
-    assert(path.isAbsoluteC(absolute_path_c));
-    return cwd().createFileC(absolute_path_c, flags);
+pub fn createFileAbsoluteZ(absolute_path_c: [*:0]const u8, flags: File.CreateFlags) File.OpenError!File {
+    assert(path.isAbsoluteZ(absolute_path_c));
+    return cwd().createFileZ(absolute_path_c, flags);
 }
 
 /// Same as `createFileAbsolute` but the path parameter is WTF-16 encoded.
@@ -1353,10 +1366,12 @@ pub fn deleteFileAbsolute(absolute_path: []const u8) DeleteFileError!void {
     return cwd().deleteFile(absolute_path);
 }
 
+pub const deleteFileAbsoluteC = @compileError("deprecated: renamed to deleteFileAbsoluteZ");
+
 /// Same as `deleteFileAbsolute` except the parameter is null-terminated.
-pub fn deleteFileAbsoluteC(absolute_path_c: [*:0]const u8) DeleteFileError!void {
-    assert(path.isAbsoluteC(absolute_path_c));
-    return cwd().deleteFileC(absolute_path_c);
+pub fn deleteFileAbsoluteZ(absolute_path_c: [*:0]const u8) DeleteFileError!void {
+    assert(path.isAbsoluteZ(absolute_path_c));
+    return cwd().deleteFileZ(absolute_path_c);
 }
 
 /// Same as `deleteFileAbsolute` except the parameter is WTF-16 encoded.
@@ -1384,6 +1399,21 @@ pub fn deleteTreeAbsolute(absolute_path: []const u8) !void {
     return dir.deleteTree(path.basename(absolute_path));
 }
 
+/// Same as `Dir.readLink`, except it asserts the path is absolute.
+pub fn readLinkAbsolute(pathname: []const u8, buffer: *[MAX_PATH_BYTES]u8) ![]u8 {
+    assert(path.isAbsolute(pathname));
+    return os.readlink(pathname, buffer);
+}
+
+/// Same as `readLink`, except the path parameter is null-terminated.
+pub fn readLinkAbsoluteZ(pathname_c: [*]const u8, buffer: *[MAX_PATH_BYTES]u8) ![]u8 {
+    assert(path.isAbsoluteZ(pathname_c));
+    return os.readlinkZ(pathname_c, buffer);
+}
+
+pub const readLink = @compileError("deprecated; use Dir.readLink or readLinkAbsolute");
+pub const readLinkC = @compileError("deprecated; use Dir.readLinkZ or readLinkAbsoluteZ");
+
 pub const Walker = struct {
     stack: std.ArrayList(StackItem),
     name_buffer: std.Buffer,
@@ -1411,7 +1441,7 @@ pub const Walker = struct {
         while (true) {
             if (self.stack.len == 0) return null;
             // `top` becomes invalid after appending to `self.stack`.
-            const top = &self.stack.toSlice()[self.stack.len - 1];
+            const top = &self.stack.span()[self.stack.len - 1];
             const dirname_len = top.dirname_len;
             if (try top.dir_it.next()) |base| {
                 self.name_buffer.shrink(dirname_len);
@@ -1432,8 +1462,8 @@ pub const Walker = struct {
                 }
                 return Entry{
                     .dir = top.dir_it.dir,
-                    .basename = self.name_buffer.toSliceConst()[dirname_len + 1 ..],
-                    .path = self.name_buffer.toSliceConst(),
+                    .basename = self.name_buffer.span()[dirname_len + 1 ..],
+                    .path = self.name_buffer.span(),
                     .kind = base.kind,
                 };
             } else {
@@ -1475,31 +1505,21 @@ pub fn walkPath(allocator: *Allocator, dir_path: []const u8) !Walker {
     return walker;
 }
 
-/// Deprecated; use `Dir.readLink`.
-pub fn readLink(pathname: []const u8, buffer: *[MAX_PATH_BYTES]u8) ![]u8 {
-    return os.readlink(pathname, buffer);
-}
-
-/// Deprecated; use `Dir.readLinkC`.
-pub fn readLinkC(pathname_c: [*]const u8, buffer: *[MAX_PATH_BYTES]u8) ![]u8 {
-    return os.readlinkC(pathname_c, buffer);
-}
-
 pub const OpenSelfExeError = os.OpenError || os.windows.CreateFileError || SelfExePathError;
 
 pub fn openSelfExe() OpenSelfExeError!File {
     if (builtin.os.tag == .linux) {
-        return openFileAbsoluteC("/proc/self/exe", .{});
+        return openFileAbsoluteZ("/proc/self/exe", .{});
     }
     if (builtin.os.tag == .windows) {
         const wide_slice = selfExePathW();
         const prefixed_path_w = try os.windows.wToPrefixedFileW(wide_slice);
-        return cwd().openReadW(&prefixed_path_w);
+        return cwd().openFileW(&prefixed_path_w, .{});
     }
     var buf: [MAX_PATH_BYTES]u8 = undefined;
     const self_exe_path = try selfExePath(&buf);
     buf[self_exe_path.len] = 0;
-    return openFileAbsoluteC(self_exe_path[0..self_exe_path.len :0].ptr, .{});
+    return openFileAbsoluteZ(self_exe_path[0..self_exe_path.len :0].ptr, .{});
 }
 
 test "openSelfExe" {
@@ -1533,23 +1553,23 @@ pub fn selfExePath(out_buffer: *[MAX_PATH_BYTES]u8) SelfExePathError![]u8 {
         var u32_len: u32 = out_buffer.len;
         const rc = std.c._NSGetExecutablePath(out_buffer, &u32_len);
         if (rc != 0) return error.NameTooLong;
-        return mem.toSlice(u8, @ptrCast([*:0]u8, out_buffer));
+        return mem.spanZ(@ptrCast([*:0]u8, out_buffer));
     }
     switch (builtin.os.tag) {
-        .linux => return os.readlinkC("/proc/self/exe", out_buffer),
+        .linux => return os.readlinkZ("/proc/self/exe", out_buffer),
         .freebsd, .dragonfly => {
             var mib = [4]c_int{ os.CTL_KERN, os.KERN_PROC, os.KERN_PROC_PATHNAME, -1 };
             var out_len: usize = out_buffer.len;
             try os.sysctl(&mib, out_buffer, &out_len, null, 0);
             // TODO could this slice from 0 to out_len instead?
-            return mem.toSlice(u8, @ptrCast([*:0]u8, out_buffer));
+            return mem.spanZ(@ptrCast([*:0]u8, out_buffer));
         },
         .netbsd => {
             var mib = [4]c_int{ os.CTL_KERN, os.KERN_PROC_ARGS, -1, os.KERN_PROC_PATHNAME };
             var out_len: usize = out_buffer.len;
             try os.sysctl(&mib, out_buffer, &out_len, null, 0);
             // TODO could this slice from 0 to out_len instead?
-            return mem.toSlice(u8, @ptrCast([*:0]u8, out_buffer));
+            return mem.spanZ(@ptrCast([*:0]u8, out_buffer));
         },
         .windows => {
             const utf16le_slice = selfExePathW();
@@ -1564,7 +1584,7 @@ pub fn selfExePath(out_buffer: *[MAX_PATH_BYTES]u8) SelfExePathError![]u8 {
 /// The result is UTF16LE-encoded.
 pub fn selfExePathW() [:0]const u16 {
     const image_path_name = &os.windows.peb().ProcessParameters.ImagePathName;
-    return mem.toSliceConst(u16, @ptrCast([*:0]const u16, image_path_name.Buffer));
+    return mem.spanZ(@ptrCast([*:0]const u16, image_path_name.Buffer));
 }
 
 /// `selfExeDirPath` except allocates the result on the heap.
lib/std/heap.zig
@@ -51,8 +51,7 @@ var wasm_page_allocator_state = Allocator{
     .shrinkFn = WasmPageAllocator.shrink,
 };
 
-/// Deprecated. Use `page_allocator`.
-pub const direct_allocator = page_allocator;
+pub const direct_allocator = @compileError("deprecated; use std.heap.page_allocator");
 
 const PageAllocator = struct {
     fn alloc(allocator: *Allocator, n: usize, alignment: u29) error{OutOfMemory}![]u8 {
lib/std/io.zig
@@ -128,16 +128,6 @@ pub const BufferedAtomicFile = @import("io/buffered_atomic_file.zig").BufferedAt
 
 pub const StreamSource = @import("io/stream_source.zig").StreamSource;
 
-/// Deprecated; use `std.fs.Dir.writeFile`.
-pub fn writeFile(path: []const u8, data: []const u8) !void {
-    return fs.cwd().writeFile(path, data);
-}
-
-/// Deprecated; use `std.fs.Dir.readFileAlloc`.
-pub fn readFileAlloc(allocator: *mem.Allocator, path: []const u8) ![]u8 {
-    return fs.cwd().readFileAlloc(allocator, path, math.maxInt(usize));
-}
-
 /// An OutStream that doesn't write to anything.
 pub const null_out_stream = @as(NullOutStream, .{ .context = {} });
 
@@ -153,3 +143,6 @@ test "null_out_stream" {
 test "" {
     _ = @import("io/test.zig");
 }
+
+pub const writeFile = @compileError("deprecated: use std.fs.Dir.writeFile with math.maxInt(usize)");
+pub const readFileAlloc = @compileError("deprecated: use std.fs.Dir.readFileAlloc");
lib/std/json.zig
@@ -1944,7 +1944,7 @@ pub const Parser = struct {
     }
 
     fn pushToParent(p: *Parser, value: *const Value) !void {
-        switch (p.stack.toSlice()[p.stack.len - 1]) {
+        switch (p.stack.span()[p.stack.len - 1]) {
             // Object Parent -> [ ..., object, <key>, value ]
             Value.String => |key| {
                 _ = p.stack.pop();
lib/std/mem.zig
@@ -492,15 +492,8 @@ pub fn eql(comptime T: type, a: []const T, b: []const T) bool {
     return true;
 }
 
-/// Deprecated. Use `spanZ`.
-pub fn toSliceConst(comptime T: type, ptr: [*:0]const T) [:0]const T {
-    return ptr[0..lenZ(ptr) :0];
-}
-
-/// Deprecated. Use `spanZ`.
-pub fn toSlice(comptime T: type, ptr: [*:0]T) [:0]T {
-    return ptr[0..lenZ(ptr) :0];
-}
+pub const toSliceConst = @compileError("deprecated; use std.mem.spanZ");
+pub const toSlice = @compileError("deprecated; use std.mem.spanZ");
 
 /// Takes a pointer to an array, a sentinel-terminated pointer, or a slice, and
 /// returns a slice. If there is a sentinel on the input type, there will be a
lib/std/net.zig
@@ -490,7 +490,7 @@ pub fn getAddressList(allocator: *mem.Allocator, name: []const u8, port: u16) !*
 
             if (info.canonname) |n| {
                 if (result.canon_name == null) {
-                    result.canon_name = try mem.dupe(arena, u8, mem.toSliceConst(u8, n));
+                    result.canon_name = try mem.dupe(arena, u8, mem.spanZ(n));
                 }
             }
             i += 1;
@@ -514,7 +514,7 @@ pub fn getAddressList(allocator: *mem.Allocator, name: []const u8, port: u16) !*
             result.canon_name = canon.toOwnedSlice();
         }
 
-        for (lookup_addrs.toSliceConst()) |lookup_addr, i| {
+        for (lookup_addrs.span()) |lookup_addr, i| {
             result.addrs[i] = lookup_addr.addr;
             assert(result.addrs[i].getPort() == port);
         }
@@ -567,7 +567,7 @@ fn linuxLookupName(
     // No further processing is needed if there are fewer than 2
     // results or if there are only IPv4 results.
     if (addrs.len == 1 or family == os.AF_INET) return;
-    const all_ip4 = for (addrs.toSliceConst()) |addr| {
+    const all_ip4 = for (addrs.span()) |addr| {
         if (addr.addr.any.family != os.AF_INET) break false;
     } else true;
     if (all_ip4) return;
@@ -579,7 +579,7 @@ fn linuxLookupName(
     // So far the label/precedence table cannot be customized.
     // This implementation is ported from musl libc.
     // A more idiomatic "ziggy" implementation would be welcome.
-    for (addrs.toSlice()) |*addr, i| {
+    for (addrs.span()) |*addr, i| {
         var key: i32 = 0;
         var sa6: os.sockaddr_in6 = undefined;
         @memset(@ptrCast([*]u8, &sa6), 0, @sizeOf(os.sockaddr_in6));
@@ -644,7 +644,7 @@ fn linuxLookupName(
         key |= (MAXADDRS - @intCast(i32, i)) << DAS_ORDER_SHIFT;
         addr.sortkey = key;
     }
-    std.sort.sort(LookupAddr, addrs.toSlice(), addrCmpLessThan);
+    std.sort.sort(LookupAddr, addrs.span(), addrCmpLessThan);
 }
 
 const Policy = struct {
@@ -803,7 +803,7 @@ fn linuxLookupNameFromHosts(
     family: os.sa_family_t,
     port: u16,
 ) !void {
-    const file = fs.openFileAbsoluteC("/etc/hosts", .{}) catch |err| switch (err) {
+    const file = fs.openFileAbsoluteZ("/etc/hosts", .{}) catch |err| switch (err) {
         error.FileNotFound,
         error.NotDir,
         error.AccessDenied,
@@ -887,7 +887,7 @@ fn linuxLookupNameFromDnsSearch(
     const search = if (rc.search.isNull() or dots >= rc.ndots or mem.endsWith(u8, name, "."))
         &[_]u8{}
     else
-        rc.search.toSliceConst();
+        rc.search.span();
 
     var canon_name = name;
 
@@ -900,14 +900,14 @@ fn linuxLookupNameFromDnsSearch(
     // name is not a CNAME record) and serves as a buffer for passing
     // the full requested name to name_from_dns.
     try canon.resize(canon_name.len);
-    mem.copy(u8, canon.toSlice(), canon_name);
+    mem.copy(u8, canon.span(), canon_name);
     try canon.appendByte('.');
 
     var tok_it = mem.tokenize(search, " \t");
     while (tok_it.next()) |tok| {
         canon.shrink(canon_name.len + 1);
         try canon.append(tok);
-        try linuxLookupNameFromDns(addrs, canon, canon.toSliceConst(), family, rc, port);
+        try linuxLookupNameFromDns(addrs, canon, canon.span(), family, rc, port);
         if (addrs.len != 0) return;
     }
 
@@ -1000,7 +1000,7 @@ fn getResolvConf(allocator: *mem.Allocator, rc: *ResolvConf) !void {
     };
     errdefer rc.deinit();
 
-    const file = fs.openFileAbsoluteC("/etc/resolv.conf", .{}) catch |err| switch (err) {
+    const file = fs.openFileAbsoluteZ("/etc/resolv.conf", .{}) catch |err| switch (err) {
         error.FileNotFound,
         error.NotDir,
         error.AccessDenied,
@@ -1079,9 +1079,9 @@ fn resMSendRc(
     defer ns_list.deinit();
 
     try ns_list.resize(rc.ns.len);
-    const ns = ns_list.toSlice();
+    const ns = ns_list.span();
 
-    for (rc.ns.toSliceConst()) |iplit, i| {
+    for (rc.ns.span()) |iplit, i| {
         ns[i] = iplit.addr;
         assert(ns[i].getPort() == 53);
         if (iplit.addr.any.family != os.AF_INET) {
@@ -1265,7 +1265,7 @@ fn dnsParseCallback(ctx: dpc_ctx, rr: u8, data: []const u8, packet: []const u8)
             var tmp: [256]u8 = undefined;
             // Returns len of compressed name. strlen to get canon name.
             _ = try os.dn_expand(packet, data, &tmp);
-            const canon_name = mem.toSliceConst(u8, @ptrCast([*:0]const u8, &tmp));
+            const canon_name = mem.spanZ(@ptrCast([*:0]const u8, &tmp));
             if (isValidHostName(canon_name)) {
                 try ctx.canon.replaceContents(canon_name);
             }
lib/std/os.zig
@@ -163,7 +163,7 @@ pub fn getrandom(buffer: []u8) GetRandomError!void {
 }
 
 fn getRandomBytesDevURandom(buf: []u8) !void {
-    const fd = try openC("/dev/urandom", O_RDONLY | O_CLOEXEC, 0);
+    const fd = try openZ("/dev/urandom", O_RDONLY | O_CLOEXEC, 0);
     defer close(fd);
 
     const st = try fstat(fd);
@@ -853,13 +853,15 @@ pub const OpenError = error{
 /// TODO support windows
 pub fn open(file_path: []const u8, flags: u32, perm: usize) OpenError!fd_t {
     const file_path_c = try toPosixPath(file_path);
-    return openC(&file_path_c, flags, perm);
+    return openZ(&file_path_c, flags, perm);
 }
 
+pub const openC = @compileError("deprecated: renamed to openZ");
+
 /// Open and possibly create a file. Keeps trying if it gets interrupted.
 /// See also `open`.
 /// TODO support windows
-pub fn openC(file_path: [*:0]const u8, flags: u32, perm: usize) OpenError!fd_t {
+pub fn openZ(file_path: [*:0]const u8, flags: u32, perm: usize) OpenError!fd_t {
     while (true) {
         const rc = system.open(file_path, flags, perm);
         switch (errno(rc)) {
@@ -895,14 +897,16 @@ pub fn openC(file_path: [*:0]const u8, flags: u32, perm: usize) OpenError!fd_t {
 /// TODO support windows
 pub fn openat(dir_fd: fd_t, file_path: []const u8, flags: u32, mode: mode_t) OpenError!fd_t {
     const file_path_c = try toPosixPath(file_path);
-    return openatC(dir_fd, &file_path_c, flags, mode);
+    return openatZ(dir_fd, &file_path_c, flags, mode);
 }
 
+pub const openatC = @compileError("deprecated: renamed to openatZ");
+
 /// Open and possibly create a file. Keeps trying if it gets interrupted.
 /// `file_path` is relative to the open directory handle `dir_fd`.
 /// See also `openat`.
 /// TODO support windows
-pub fn openatC(dir_fd: fd_t, file_path: [*:0]const u8, flags: u32, mode: mode_t) OpenError!fd_t {
+pub fn openatZ(dir_fd: fd_t, file_path: [*:0]const u8, flags: u32, mode: mode_t) OpenError!fd_t {
     while (true) {
         const rc = system.openat(dir_fd, file_path, flags, mode);
         switch (errno(rc)) {
@@ -959,8 +963,7 @@ pub const ExecveError = error{
     NameTooLong,
 } || UnexpectedError;
 
-/// Deprecated in favor of `execveZ`.
-pub const execveC = execveZ;
+pub const execveC = @compileError("deprecated: use execveZ");
 
 /// Like `execve` except the parameters are null-terminated,
 /// matching the syscall API on all targets. This removes the need for an allocator.
@@ -992,8 +995,7 @@ pub fn execveZ(
     }
 }
 
-/// Deprecated in favor of `execvpeZ`.
-pub const execvpeC = execvpeZ;
+pub const execvpeC = @compileError("deprecated in favor of execvpeZ");
 
 pub const Arg0Expand = enum {
     expand,
@@ -1012,7 +1014,7 @@ pub fn execvpeZ_expandArg0(
     },
     envp: [*:null]const ?[*:0]const u8,
 ) ExecveError {
-    const file_slice = mem.toSliceConst(u8, file);
+    const file_slice = mem.spanZ(file);
     if (mem.indexOfScalar(u8, file_slice, '/') != null) return execveZ(file, child_argv, envp);
 
     const PATH = getenvZ("PATH") orelse "/usr/local/bin:/bin/:/usr/bin";
@@ -1076,7 +1078,7 @@ pub fn execvpe_expandArg0(
     mem.set(?[*:0]u8, argv_buf, null);
     defer {
         for (argv_buf) |arg| {
-            const arg_buf = if (arg) |ptr| mem.toSlice(u8, ptr) else break;
+            const arg_buf = if (arg) |ptr| mem.spanZ(ptr) else break;
             allocator.free(arg_buf);
         }
         allocator.free(argv_buf);
@@ -1189,20 +1191,19 @@ pub fn getenv(key: []const u8) ?[]const u8 {
     return null;
 }
 
-/// Deprecated in favor of `getenvZ`.
-pub const getenvC = getenvZ;
+pub const getenvC = @compileError("Deprecated in favor of `getenvZ`");
 
 /// Get an environment variable with a null-terminated name.
 /// See also `getenv`.
 pub fn getenvZ(key: [*:0]const u8) ?[]const u8 {
     if (builtin.link_libc) {
         const value = system.getenv(key) orelse return null;
-        return mem.toSliceConst(u8, value);
+        return mem.spanZ(value);
     }
     if (builtin.os.tag == .windows) {
         @compileError("std.os.getenvZ is unavailable for Windows because environment string is in WTF-16 format. See std.process.getEnvVarOwned for cross-platform API or std.os.getenvW for Windows-specific API.");
     }
-    return getenv(mem.toSliceConst(u8, key));
+    return getenv(mem.spanZ(key));
 }
 
 /// Windows-only. Get an environment variable with a null-terminated, WTF-16 encoded name.
@@ -1211,7 +1212,7 @@ pub fn getenvW(key: [*:0]const u16) ?[:0]const u16 {
     if (builtin.os.tag != .windows) {
         @compileError("std.os.getenvW is a Windows-only API");
     }
-    const key_slice = mem.toSliceConst(u16, key);
+    const key_slice = mem.spanZ(key);
     const ptr = windows.peb().ProcessParameters.Environment;
     var i: usize = 0;
     while (ptr[i] != 0) {
@@ -1250,7 +1251,7 @@ pub fn getcwd(out_buffer: []u8) GetCwdError![]u8 {
         break :blk errno(system.getcwd(out_buffer.ptr, out_buffer.len));
     };
     switch (err) {
-        0 => return mem.toSlice(u8, @ptrCast([*:0]u8, out_buffer.ptr)),
+        0 => return mem.spanZ(@ptrCast([*:0]u8, out_buffer.ptr)),
         EFAULT => unreachable,
         EINVAL => unreachable,
         ENOENT => return error.CurrentWorkingDirectoryUnlinked,
@@ -1288,13 +1289,15 @@ pub fn symlink(target_path: []const u8, sym_link_path: []const u8) SymLinkError!
     } else {
         const target_path_c = try toPosixPath(target_path);
         const sym_link_path_c = try toPosixPath(sym_link_path);
-        return symlinkC(&target_path_c, &sym_link_path_c);
+        return symlinkZ(&target_path_c, &sym_link_path_c);
     }
 }
 
+pub const symlinkC = @compileError("deprecated: renamed to symlinkZ");
+
 /// This is the same as `symlink` except the parameters are null-terminated pointers.
 /// See also `symlink`.
-pub fn symlinkC(target_path: [*:0]const u8, sym_link_path: [*:0]const u8) SymLinkError!void {
+pub fn symlinkZ(target_path: [*:0]const u8, sym_link_path: [*:0]const u8) SymLinkError!void {
     if (builtin.os.tag == .windows) {
         const target_path_w = try windows.cStrToPrefixedFileW(target_path);
         const sym_link_path_w = try windows.cStrToPrefixedFileW(sym_link_path);
@@ -1323,10 +1326,12 @@ pub fn symlinkC(target_path: [*:0]const u8, sym_link_path: [*:0]const u8) SymLin
 pub fn symlinkat(target_path: []const u8, newdirfd: fd_t, sym_link_path: []const u8) SymLinkError!void {
     const target_path_c = try toPosixPath(target_path);
     const sym_link_path_c = try toPosixPath(sym_link_path);
-    return symlinkatC(target_path_c, newdirfd, sym_link_path_c);
+    return symlinkatZ(target_path_c, newdirfd, sym_link_path_c);
 }
 
-pub fn symlinkatC(target_path: [*:0]const u8, newdirfd: fd_t, sym_link_path: [*:0]const u8) SymLinkError!void {
+pub const symlinkatC = @compileError("deprecated: renamed to symlinkatZ");
+
+pub fn symlinkatZ(target_path: [*:0]const u8, newdirfd: fd_t, sym_link_path: [*:0]const u8) SymLinkError!void {
     switch (errno(system.symlinkat(target_path, newdirfd, sym_link_path))) {
         0 => return,
         EFAULT => unreachable,
@@ -1375,12 +1380,14 @@ pub fn unlink(file_path: []const u8) UnlinkError!void {
         return windows.DeleteFileW(&file_path_w);
     } else {
         const file_path_c = try toPosixPath(file_path);
-        return unlinkC(&file_path_c);
+        return unlinkZ(&file_path_c);
     }
 }
 
+pub const unlinkC = @compileError("deprecated: renamed to unlinkZ");
+
 /// Same as `unlink` except the parameter is a null terminated UTF8-encoded string.
-pub fn unlinkC(file_path: [*:0]const u8) UnlinkError!void {
+pub fn unlinkZ(file_path: [*:0]const u8) UnlinkError!void {
     if (builtin.os.tag == .windows) {
         const file_path_w = try windows.cStrToPrefixedFileW(file_path);
         return windows.DeleteFileW(&file_path_w);
@@ -1417,11 +1424,13 @@ pub fn unlinkat(dirfd: fd_t, file_path: []const u8, flags: u32) UnlinkatError!vo
         return unlinkatW(dirfd, &file_path_w, flags);
     }
     const file_path_c = try toPosixPath(file_path);
-    return unlinkatC(dirfd, &file_path_c, flags);
+    return unlinkatZ(dirfd, &file_path_c, flags);
 }
 
+pub const unlinkatC = @compileError("deprecated: renamed to unlinkatZ");
+
 /// Same as `unlinkat` but `file_path` is a null-terminated string.
-pub fn unlinkatC(dirfd: fd_t, file_path_c: [*:0]const u8, flags: u32) UnlinkatError!void {
+pub fn unlinkatZ(dirfd: fd_t, file_path_c: [*:0]const u8, flags: u32) UnlinkatError!void {
     if (builtin.os.tag == .windows) {
         const file_path_w = try windows.cStrToPrefixedFileW(file_path_c);
         return unlinkatW(dirfd, &file_path_w, flags);
@@ -1459,7 +1468,7 @@ pub fn unlinkatW(dirfd: fd_t, sub_path_w: [*:0]const u16, flags: u32) UnlinkatEr
     else
         @as(w.ULONG, w.FILE_DELETE_ON_CLOSE | w.FILE_NON_DIRECTORY_FILE);
 
-    const path_len_bytes = @intCast(u16, mem.toSliceConst(u16, sub_path_w).len * 2);
+    const path_len_bytes = @intCast(u16, mem.lenZ(sub_path_w) * 2);
     var nt_name = w.UNICODE_STRING{
         .Length = path_len_bytes,
         .MaximumLength = path_len_bytes,
@@ -1543,12 +1552,14 @@ pub fn rename(old_path: []const u8, new_path: []const u8) RenameError!void {
     } else {
         const old_path_c = try toPosixPath(old_path);
         const new_path_c = try toPosixPath(new_path);
-        return renameC(&old_path_c, &new_path_c);
+        return renameZ(&old_path_c, &new_path_c);
     }
 }
 
+pub const renameC = @compileError("deprecated: renamed to renameZ");
+
 /// Same as `rename` except the parameters are null-terminated byte arrays.
-pub fn renameC(old_path: [*:0]const u8, new_path: [*:0]const u8) RenameError!void {
+pub fn renameZ(old_path: [*:0]const u8, new_path: [*:0]const u8) RenameError!void {
     if (builtin.os.tag == .windows) {
         const old_path_w = try windows.cStrToPrefixedFileW(old_path);
         const new_path_w = try windows.cStrToPrefixedFileW(new_path);
@@ -1715,11 +1726,13 @@ pub fn mkdirat(dir_fd: fd_t, sub_dir_path: []const u8, mode: u32) MakeDirError!v
         return mkdiratW(dir_fd, &sub_dir_path_w, mode);
     } else {
         const sub_dir_path_c = try toPosixPath(sub_dir_path);
-        return mkdiratC(dir_fd, &sub_dir_path_c, mode);
+        return mkdiratZ(dir_fd, &sub_dir_path_c, mode);
     }
 }
 
-pub fn mkdiratC(dir_fd: fd_t, sub_dir_path: [*:0]const u8, mode: u32) MakeDirError!void {
+pub const mkdiratC = @compileError("deprecated: renamed to mkdiratZ");
+
+pub fn mkdiratZ(dir_fd: fd_t, sub_dir_path: [*:0]const u8, mode: u32) MakeDirError!void {
     if (builtin.os.tag == .windows) {
         const sub_dir_path_w = try windows.cStrToPrefixedFileW(sub_dir_path);
         return mkdiratW(dir_fd, &sub_dir_path_w, mode);
@@ -1810,12 +1823,14 @@ pub fn rmdir(dir_path: []const u8) DeleteDirError!void {
         return windows.RemoveDirectoryW(&dir_path_w);
     } else {
         const dir_path_c = try toPosixPath(dir_path);
-        return rmdirC(&dir_path_c);
+        return rmdirZ(&dir_path_c);
     }
 }
 
+pub const rmdirC = @compileError("deprecated: renamed to rmdirZ");
+
 /// Same as `rmdir` except the parameter is null-terminated.
-pub fn rmdirC(dir_path: [*:0]const u8) DeleteDirError!void {
+pub fn rmdirZ(dir_path: [*:0]const u8) DeleteDirError!void {
     if (builtin.os.tag == .windows) {
         const dir_path_w = try windows.cStrToPrefixedFileW(dir_path);
         return windows.RemoveDirectoryW(&dir_path_w);
@@ -1857,12 +1872,14 @@ pub fn chdir(dir_path: []const u8) ChangeCurDirError!void {
         @compileError("TODO implement chdir for Windows");
     } else {
         const dir_path_c = try toPosixPath(dir_path);
-        return chdirC(&dir_path_c);
+        return chdirZ(&dir_path_c);
     }
 }
 
+pub const chdirC = @compileError("deprecated: renamed to chdirZ");
+
 /// Same as `chdir` except the parameter is null-terminated.
-pub fn chdirC(dir_path: [*:0]const u8) ChangeCurDirError!void {
+pub fn chdirZ(dir_path: [*:0]const u8) ChangeCurDirError!void {
     if (builtin.os.tag == .windows) {
         const dir_path_w = try windows.cStrToPrefixedFileW(dir_path);
         @compileError("TODO implement chdir for Windows");
@@ -1919,12 +1936,14 @@ pub fn readlink(file_path: []const u8, out_buffer: []u8) ReadLinkError![]u8 {
         @compileError("TODO implement readlink for Windows");
     } else {
         const file_path_c = try toPosixPath(file_path);
-        return readlinkC(&file_path_c, out_buffer);
+        return readlinkZ(&file_path_c, out_buffer);
     }
 }
 
+pub const readlinkC = @compileError("deprecated: renamed to readlinkZ");
+
 /// Same as `readlink` except `file_path` is null-terminated.
-pub fn readlinkC(file_path: [*:0]const u8, out_buffer: []u8) ReadLinkError![]u8 {
+pub fn readlinkZ(file_path: [*:0]const u8, out_buffer: []u8) ReadLinkError![]u8 {
     if (builtin.os.tag == .windows) {
         const file_path_w = try windows.cStrToPrefixedFileW(file_path);
         @compileError("TODO implement readlink for Windows");
@@ -1945,7 +1964,9 @@ pub fn readlinkC(file_path: [*:0]const u8, out_buffer: []u8) ReadLinkError![]u8
     }
 }
 
-pub fn readlinkatC(dirfd: fd_t, file_path: [*:0]const u8, out_buffer: []u8) ReadLinkError![]u8 {
+pub const readlinkatC = @compileError("deprecated: renamed to readlinkatZ");
+
+pub fn readlinkatZ(dirfd: fd_t, file_path: [*:0]const u8, out_buffer: []u8) ReadLinkError![]u8 {
     if (builtin.os.tag == .windows) {
         const file_path_w = try windows.cStrToPrefixedFileW(file_path);
         @compileError("TODO implement readlink for Windows");
@@ -2553,10 +2574,12 @@ const FStatAtError = FStatError || error{NameTooLong};
 
 pub fn fstatat(dirfd: fd_t, pathname: []const u8, flags: u32) FStatAtError![]Stat {
     const pathname_c = try toPosixPath(pathname);
-    return fstatatC(dirfd, &pathname_c, flags);
+    return fstatatZ(dirfd, &pathname_c, flags);
 }
 
-pub fn fstatatC(dirfd: fd_t, pathname: [*:0]const u8, flags: u32) FStatAtError!Stat {
+pub const fstatatC = @compileError("deprecated: renamed to fstatatZ");
+
+pub fn fstatatZ(dirfd: fd_t, pathname: [*:0]const u8, flags: u32) FStatAtError!Stat {
     var stat: Stat = undefined;
     switch (errno(system.fstatat(dirfd, pathname, &stat, flags))) {
         0 => return stat,
@@ -2668,11 +2691,13 @@ pub const INotifyAddWatchError = error{
 /// add a watch to an initialized inotify instance
 pub fn inotify_add_watch(inotify_fd: i32, pathname: []const u8, mask: u32) INotifyAddWatchError!i32 {
     const pathname_c = try toPosixPath(pathname);
-    return inotify_add_watchC(inotify_fd, &pathname_c, mask);
+    return inotify_add_watchZ(inotify_fd, &pathname_c, mask);
 }
 
+pub const inotify_add_watchC = @compileError("deprecated: renamed to inotify_add_watchZ");
+
 /// Same as `inotify_add_watch` except pathname is null-terminated.
-pub fn inotify_add_watchC(inotify_fd: i32, pathname: [*:0]const u8, mask: u32) INotifyAddWatchError!i32 {
+pub fn inotify_add_watchZ(inotify_fd: i32, pathname: [*:0]const u8, mask: u32) INotifyAddWatchError!i32 {
     const rc = system.inotify_add_watch(inotify_fd, pathname, mask);
     switch (errno(rc)) {
         0 => return @intCast(i32, rc),
@@ -2829,11 +2854,10 @@ pub fn access(path: []const u8, mode: u32) AccessError!void {
         return;
     }
     const path_c = try toPosixPath(path);
-    return accessC(&path_c, mode);
+    return accessZ(&path_c, mode);
 }
 
-/// Deprecated in favor of `accessZ`.
-pub const accessC = accessZ;
+pub const accessC = @compileError("Deprecated in favor of `accessZ`");
 
 /// Same as `access` except `path` is null-terminated.
 pub fn accessZ(path: [*:0]const u8, mode: u32) AccessError!void {
@@ -2920,7 +2944,7 @@ pub fn faccessatW(dirfd: fd_t, sub_path_w: [*:0]const u16, mode: u32, flags: u32
         return;
     }
 
-    const path_len_bytes = math.cast(u16, mem.toSliceConst(u16, sub_path_w).len * 2) catch |err| switch (err) {
+    const path_len_bytes = math.cast(u16, mem.lenZ(sub_path_w) * 2) catch |err| switch (err) {
         error.Overflow => return error.NameTooLong,
     };
     var nt_name = windows.UNICODE_STRING{
@@ -3019,7 +3043,9 @@ pub fn sysctl(
     }
 }
 
-pub fn sysctlbynameC(
+pub const sysctlbynameC = @compileError("deprecated: renamed to sysctlbynameZ");
+
+pub fn sysctlbynameZ(
     name: [*:0]const u8,
     oldp: ?*c_void,
     oldlenp: ?*usize,
@@ -3224,23 +3250,25 @@ pub fn realpath(pathname: []const u8, out_buffer: *[MAX_PATH_BYTES]u8) RealPathE
         return realpathW(&pathname_w, out_buffer);
     }
     const pathname_c = try toPosixPath(pathname);
-    return realpathC(&pathname_c, out_buffer);
+    return realpathZ(&pathname_c, out_buffer);
 }
 
+pub const realpathC = @compileError("deprecated: renamed realpathZ");
+
 /// Same as `realpath` except `pathname` is null-terminated.
-pub fn realpathC(pathname: [*:0]const u8, out_buffer: *[MAX_PATH_BYTES]u8) RealPathError![]u8 {
+pub fn realpathZ(pathname: [*:0]const u8, out_buffer: *[MAX_PATH_BYTES]u8) RealPathError![]u8 {
     if (builtin.os.tag == .windows) {
         const pathname_w = try windows.cStrToPrefixedFileW(pathname);
         return realpathW(&pathname_w, out_buffer);
     }
     if (builtin.os.tag == .linux and !builtin.link_libc) {
-        const fd = try openC(pathname, linux.O_PATH | linux.O_NONBLOCK | linux.O_CLOEXEC, 0);
+        const fd = try openZ(pathname, linux.O_PATH | linux.O_NONBLOCK | linux.O_CLOEXEC, 0);
         defer close(fd);
 
         var procfs_buf: ["/proc/self/fd/-2147483648".len:0]u8 = undefined;
         const proc_path = std.fmt.bufPrint(procfs_buf[0..], "/proc/self/fd/{}\x00", .{fd}) catch unreachable;
 
-        return readlinkC(@ptrCast([*:0]const u8, proc_path.ptr), out_buffer);
+        return readlinkZ(@ptrCast([*:0]const u8, proc_path.ptr), out_buffer);
     }
     const result_path = std.c.realpath(pathname, out_buffer) orelse switch (std.c._errno().*) {
         EINVAL => unreachable,
@@ -3255,7 +3283,7 @@ pub fn realpathC(pathname: [*:0]const u8, out_buffer: *[MAX_PATH_BYTES]u8) RealP
         EIO => return error.InputOutput,
         else => |err| return unexpectedErrno(@intCast(usize, err)),
     };
-    return mem.toSlice(u8, result_path);
+    return mem.spanZ(result_path);
 }
 
 /// Same as `realpath` except `pathname` is null-terminated and UTF16LE-encoded.
@@ -3564,7 +3592,7 @@ pub const GetHostNameError = error{PermissionDenied} || UnexpectedError;
 pub fn gethostname(name_buffer: *[HOST_NAME_MAX]u8) GetHostNameError![]u8 {
     if (builtin.link_libc) {
         switch (errno(system.gethostname(name_buffer, name_buffer.len))) {
-            0 => return mem.toSlice(u8, @ptrCast([*:0]u8, name_buffer)),
+            0 => return mem.spanZ(@ptrCast([*:0]u8, name_buffer)),
             EFAULT => unreachable,
             ENAMETOOLONG => unreachable, // HOST_NAME_MAX prevents this
             EPERM => return error.PermissionDenied,
@@ -3573,7 +3601,7 @@ pub fn gethostname(name_buffer: *[HOST_NAME_MAX]u8) GetHostNameError![]u8 {
     }
     if (builtin.os.tag == .linux) {
         const uts = uname();
-        const hostname = mem.toSliceConst(u8, @ptrCast([*:0]const u8, &uts.nodename));
+        const hostname = mem.spanZ(@ptrCast([*:0]const u8, &uts.nodename));
         mem.copy(u8, name_buffer, hostname);
         return name_buffer[0..hostname.len];
     }
@@ -4260,7 +4288,9 @@ pub const MemFdCreateError = error{
     SystemOutdated,
 } || UnexpectedError;
 
-pub fn memfd_createC(name: [*:0]const u8, flags: u32) MemFdCreateError!fd_t {
+pub const memfd_createC = @compileError("deprecated: renamed to memfd_createZ");
+
+pub fn memfd_createZ(name: [*:0]const u8, flags: u32) MemFdCreateError!fd_t {
     // memfd_create is available only in glibc versions starting with 2.27.
     const use_c = std.c.versionCheck(.{ .major = 2, .minor = 27, .patch = 0 }).ok;
     const sys = if (use_c) std.c else linux;
@@ -4291,7 +4321,7 @@ fn toMemFdPath(name: []const u8) ![MFD_MAX_NAME_LEN:0]u8 {
 
 pub fn memfd_create(name: []const u8, flags: u32) !fd_t {
     const name_t = try toMemFdPath(name);
-    return memfd_createC(&name_t, flags);
+    return memfd_createZ(&name_t, flags);
 }
 
 pub fn getrusage(who: i32) rusage {
lib/std/pdb.zig
@@ -649,7 +649,7 @@ const MsfStream = struct {
         while (true) {
             const byte = try self.inStream().readByte();
             if (byte == 0) {
-                return list.toSlice();
+                return list.span();
             }
             try list.append(byte);
         }
lib/std/process.zig
@@ -83,7 +83,7 @@ pub fn getEnvMap(allocator: *Allocator) !BufMap {
 
         for (environ) |env| {
             if (env) |ptr| {
-                const pair = mem.toSlice(u8, ptr);
+                const pair = mem.spanZ(ptr);
                 var parts = mem.separate(pair, "=");
                 const key = parts.next().?;
                 const value = parts.next().?;
@@ -176,7 +176,7 @@ pub const ArgIteratorPosix = struct {
 
         const s = os.argv[self.index];
         self.index += 1;
-        return mem.toSlice(u8, s);
+        return mem.spanZ(s);
     }
 
     pub fn skip(self: *ArgIteratorPosix) bool {
@@ -401,7 +401,7 @@ pub fn argsAlloc(allocator: *mem.Allocator) ![][]u8 {
 
         var i: usize = 0;
         while (i < count) : (i += 1) {
-            result_slice[i] = mem.toSlice(u8, argv[i]);
+            result_slice[i] = mem.spanZ(argv[i]);
         }
 
         return result_slice;
@@ -422,8 +422,8 @@ pub fn argsAlloc(allocator: *mem.Allocator) ![][]u8 {
         try slice_list.append(arg.len);
     }
 
-    const contents_slice = contents.toSliceConst();
-    const slice_sizes = slice_list.toSliceConst();
+    const contents_slice = contents.span();
+    const slice_sizes = slice_list.span();
     const slice_list_bytes = try math.mul(usize, @sizeOf([]u8), slice_sizes.len);
     const total_bytes = try math.add(usize, slice_list_bytes, contents_slice.len);
     const buf = try allocator.alignedAlloc(u8, @alignOf([]u8), total_bytes);
@@ -636,7 +636,7 @@ pub fn getSelfExeSharedLibPaths(allocator: *Allocator) error{OutOfMemory}![][:0]
                 fn callback(info: *os.dl_phdr_info, size: usize, list: *List) !void {
                     const name = info.dlpi_name orelse return;
                     if (name[0] == '/') {
-                        const item = try mem.dupeZ(list.allocator, u8, mem.toSliceConst(u8, name));
+                        const item = try mem.dupeZ(list.allocator, u8, mem.spanZ(name));
                         errdefer list.allocator.free(item);
                         try list.append(item);
                     }
@@ -657,7 +657,7 @@ pub fn getSelfExeSharedLibPaths(allocator: *Allocator) error{OutOfMemory}![][:0]
             var i: u32 = 0;
             while (i < img_count) : (i += 1) {
                 const name = std.c._dyld_get_image_name(i);
-                const item = try mem.dupeZ(allocator, u8, mem.toSliceConst(u8, name));
+                const item = try mem.dupeZ(allocator, u8, mem.spanZ(name));
                 errdefer allocator.free(item);
                 try paths.append(item);
             }
lib/std/rand.zig
@@ -59,7 +59,7 @@ pub const Random = struct {
         return @bitCast(T, unsigned_result);
     }
 
-    /// Constant-time implementation off ::uintLessThan.
+    /// Constant-time implementation off `uintLessThan`.
     /// The results of this function may be biased.
     pub fn uintLessThanBiased(r: *Random, comptime T: type, less_than: T) T {
         comptime assert(T.is_signed == false);
@@ -73,13 +73,13 @@ pub const Random = struct {
     }
 
     /// Returns an evenly distributed random unsigned integer `0 <= i < less_than`.
-    /// This function assumes that the underlying ::fillFn produces evenly distributed values.
+    /// This function assumes that the underlying `fillFn` produces evenly distributed values.
     /// Within this assumption, the runtime of this function is exponentially distributed.
-    /// If ::fillFn were backed by a true random generator,
+    /// If `fillFn` were backed by a true random generator,
     /// the runtime of this function would technically be unbounded.
-    /// However, if ::fillFn is backed by any evenly distributed pseudo random number generator,
+    /// However, if `fillFn` is backed by any evenly distributed pseudo random number generator,
     /// this function is guaranteed to return.
-    /// If you need deterministic runtime bounds, use `::uintLessThanBiased`.
+    /// If you need deterministic runtime bounds, use `uintLessThanBiased`.
     pub fn uintLessThan(r: *Random, comptime T: type, less_than: T) T {
         comptime assert(T.is_signed == false);
         comptime assert(T.bit_count <= 64); // TODO: workaround: LLVM ERROR: Unsupported library call operation!
@@ -116,7 +116,7 @@ pub const Random = struct {
         return @intCast(T, m >> Small.bit_count);
     }
 
-    /// Constant-time implementation off ::uintAtMost.
+    /// Constant-time implementation off `uintAtMost`.
     /// The results of this function may be biased.
     pub fn uintAtMostBiased(r: *Random, comptime T: type, at_most: T) T {
         assert(T.is_signed == false);
@@ -128,7 +128,7 @@ pub const Random = struct {
     }
 
     /// Returns an evenly distributed random unsigned integer `0 <= i <= at_most`.
-    /// See ::uintLessThan, which this function uses in most cases,
+    /// See `uintLessThan`, which this function uses in most cases,
     /// for commentary on the runtime of this function.
     pub fn uintAtMost(r: *Random, comptime T: type, at_most: T) T {
         assert(T.is_signed == false);
@@ -139,7 +139,7 @@ pub const Random = struct {
         return r.uintLessThan(T, at_most + 1);
     }
 
-    /// Constant-time implementation off ::intRangeLessThan.
+    /// Constant-time implementation off `intRangeLessThan`.
     /// The results of this function may be biased.
     pub fn intRangeLessThanBiased(r: *Random, comptime T: type, at_least: T, less_than: T) T {
         assert(at_least < less_than);
@@ -157,7 +157,7 @@ pub const Random = struct {
     }
 
     /// Returns an evenly distributed random integer `at_least <= i < less_than`.
-    /// See ::uintLessThan, which this function uses in most cases,
+    /// See `uintLessThan`, which this function uses in most cases,
     /// for commentary on the runtime of this function.
     pub fn intRangeLessThan(r: *Random, comptime T: type, at_least: T, less_than: T) T {
         assert(at_least < less_than);
@@ -174,7 +174,7 @@ pub const Random = struct {
         }
     }
 
-    /// Constant-time implementation off ::intRangeAtMostBiased.
+    /// Constant-time implementation off `intRangeAtMostBiased`.
     /// The results of this function may be biased.
     pub fn intRangeAtMostBiased(r: *Random, comptime T: type, at_least: T, at_most: T) T {
         assert(at_least <= at_most);
@@ -192,7 +192,7 @@ pub const Random = struct {
     }
 
     /// Returns an evenly distributed random integer `at_least <= i <= at_most`.
-    /// See ::uintLessThan, which this function uses in most cases,
+    /// See `uintLessThan`, which this function uses in most cases,
     /// for commentary on the runtime of this function.
     pub fn intRangeAtMost(r: *Random, comptime T: type, at_least: T, at_most: T) T {
         assert(at_least <= at_most);
@@ -209,15 +209,9 @@ pub const Random = struct {
         }
     }
 
-    /// TODO: deprecated. use ::boolean or ::int instead.
-    pub fn scalar(r: *Random, comptime T: type) T {
-        return if (T == bool) r.boolean() else r.int(T);
-    }
+    pub const scalar = @compileError("deprecated; use boolean() or int() instead");
 
-    /// TODO: deprecated. renamed to ::intRangeLessThan
-    pub fn range(r: *Random, comptime T: type, start: T, end: T) T {
-        return r.intRangeLessThan(T, start, end);
-    }
+    pub const range = @compileError("deprecated; use intRangeLessThan()");
 
     /// Return a floating point value evenly distributed in the range [0, 1).
     pub fn float(r: *Random, comptime T: type) T {
lib/std/sort.zig
@@ -1227,13 +1227,13 @@ test "sort fuzz testing" {
 var fixed_buffer_mem: [100 * 1024]u8 = undefined;
 
 fn fuzzTest(rng: *std.rand.Random) !void {
-    const array_size = rng.range(usize, 0, 1000);
+    const array_size = rng.intRangeLessThan(usize, 0, 1000);
     var array = try testing.allocator.alloc(IdAndValue, array_size);
     defer testing.allocator.free(array);
     // populate with random data
     for (array) |*item, index| {
         item.id = index;
-        item.value = rng.range(i32, 0, 100);
+        item.value = rng.intRangeLessThan(i32, 0, 100);
     }
     sort(IdAndValue, array, cmpByValue);
 
lib/std/thread.zig
@@ -464,7 +464,7 @@ pub const Thread = struct {
         var count: c_int = undefined;
         var count_len: usize = @sizeOf(c_int);
         const name = if (comptime std.Target.current.isDarwin()) "hw.logicalcpu" else "hw.ncpu";
-        os.sysctlbynameC(name, &count, &count_len, null, 0) catch |err| switch (err) {
+        os.sysctlbynameZ(name, &count, &count_len, null, 0) catch |err| switch (err) {
             error.NameTooLong, error.UnknownName => unreachable,
             else => |e| return e,
         };
src-self-hosted/codegen.zig
@@ -25,10 +25,10 @@ pub async fn renderToLlvm(comp: *Compilation, fn_val: *Value.Fn, code: *ir.Code)
 
     const context = llvm_handle.node.data;
 
-    const module = llvm.ModuleCreateWithNameInContext(comp.name.toSliceConst(), context) orelse return error.OutOfMemory;
+    const module = llvm.ModuleCreateWithNameInContext(comp.name.span(), context) orelse return error.OutOfMemory;
     defer llvm.DisposeModule(module);
 
-    llvm.SetTarget(module, comp.llvm_triple.toSliceConst());
+    llvm.SetTarget(module, comp.llvm_triple.span());
     llvm.SetDataLayout(module, comp.target_layout_str);
 
     if (comp.target.getObjectFormat() == .coff) {
@@ -54,15 +54,15 @@ pub async fn renderToLlvm(comp: *Compilation, fn_val: *Value.Fn, code: *ir.Code)
     const runtime_version = 0;
     const compile_unit_file = llvm.CreateFile(
         dibuilder,
-        comp.name.toSliceConst(),
-        comp.root_package.root_src_dir.toSliceConst(),
+        comp.name.span(),
+        comp.root_package.root_src_dir.span(),
     ) orelse return error.OutOfMemory;
     const is_optimized = comp.build_mode != .Debug;
     const compile_unit = llvm.CreateCompileUnit(
         dibuilder,
         DW.LANG_C99,
         compile_unit_file,
-        producer.toSliceConst(),
+        producer.span(),
         is_optimized,
         flags,
         runtime_version,
@@ -109,14 +109,14 @@ pub async fn renderToLlvm(comp: *Compilation, fn_val: *Value.Fn, code: *ir.Code)
     if (llvm.TargetMachineEmitToFile(
         comp.target_machine,
         module,
-        output_path.toSliceConst(),
+        output_path.span(),
         llvm.EmitBinary,
         &err_msg,
         is_debug,
         is_small,
     )) {
         if (std.debug.runtime_safety) {
-            std.debug.panic("unable to write object file {}: {s}\n", .{ output_path.toSliceConst(), err_msg });
+            std.debug.panic("unable to write object file {}: {s}\n", .{ output_path.span(), err_msg });
         }
         return error.WritingObjectFileFailed;
     }
@@ -127,7 +127,7 @@ pub async fn renderToLlvm(comp: *Compilation, fn_val: *Value.Fn, code: *ir.Code)
         llvm.DumpModule(ofile.module);
     }
     if (comp.verbose_link) {
-        std.debug.warn("created {}\n", .{output_path.toSliceConst()});
+        std.debug.warn("created {}\n", .{output_path.span()});
     }
 }
 
@@ -150,7 +150,7 @@ pub fn renderToLlvmModule(ofile: *ObjectFile, fn_val: *Value.Fn, code: *ir.Code)
     const llvm_fn_type = try fn_val.base.typ.getLlvmType(ofile.arena, ofile.context);
     const llvm_fn = llvm.AddFunction(
         ofile.module,
-        fn_val.symbol_name.toSliceConst(),
+        fn_val.symbol_name.span(),
         llvm_fn_type,
     ) orelse return error.OutOfMemory;
 
@@ -211,7 +211,7 @@ pub fn renderToLlvmModule(ofile: *ObjectFile, fn_val: *Value.Fn, code: *ir.Code)
     const cur_ret_ptr = if (fn_type_normal.return_type.handleIsPtr()) llvm.GetParam(llvm_fn, 0) else null;
 
     // build all basic blocks
-    for (code.basic_block_list.toSlice()) |bb| {
+    for (code.basic_block_list.span()) |bb| {
         bb.llvm_block = llvm.AppendBasicBlockInContext(
             ofile.context,
             llvm_fn,
@@ -226,7 +226,7 @@ pub fn renderToLlvmModule(ofile: *ObjectFile, fn_val: *Value.Fn, code: *ir.Code)
     // TODO set up error return tracing
     // TODO allocate temporary stack values
 
-    const var_list = fn_type.non_key.Normal.variable_list.toSliceConst();
+    const var_list = fn_type.non_key.Normal.variable_list.span();
     // create debug variable declarations for variables and allocate all local variables
     for (var_list) |var_scope, i| {
         const var_type = switch (var_scope.data) {
@@ -306,9 +306,9 @@ pub fn renderToLlvmModule(ofile: *ObjectFile, fn_val: *Value.Fn, code: *ir.Code)
         //}
     }
 
-    for (code.basic_block_list.toSlice()) |current_block| {
+    for (code.basic_block_list.span()) |current_block| {
         llvm.PositionBuilderAtEnd(ofile.builder, current_block.llvm_block);
-        for (current_block.instruction_list.toSlice()) |instruction| {
+        for (current_block.instruction_list.span()) |instruction| {
             if (instruction.ref_count == 0 and !instruction.hasSideEffects()) continue;
 
             instruction.llvm_value = try instruction.render(ofile, fn_val);
src-self-hosted/compilation.zig
@@ -465,7 +465,7 @@ pub const Compilation = struct {
 
         comp.target_machine = llvm.CreateTargetMachine(
             comp.llvm_target,
-            comp.llvm_triple.toSliceConst(),
+            comp.llvm_triple.span(),
             target_specific_cpu_args orelse "",
             target_specific_cpu_features orelse "",
             opt_level,
@@ -1106,7 +1106,7 @@ pub const Compilation = struct {
             }
         }
 
-        for (self.link_libs_list.toSliceConst()) |existing_lib| {
+        for (self.link_libs_list.span()) |existing_lib| {
             if (mem.eql(u8, name, existing_lib.name)) {
                 return existing_lib;
             }
@@ -1371,7 +1371,7 @@ fn analyzeFnType(
     var params = ArrayList(Type.Fn.Param).init(comp.gpa());
     var params_consumed = false;
     defer if (!params_consumed) {
-        for (params.toSliceConst()) |param| {
+        for (params.span()) |param| {
             param.typ.base.deref(comp);
         }
         params.deinit();
src-self-hosted/dep_tokenizer.zig
@@ -89,7 +89,7 @@ pub const Tokenizer = struct {
                     },
                     .target_colon => |*target| switch (char) {
                         '\n', '\r' => {
-                            const bytes = target.toSlice();
+                            const bytes = target.span();
                             if (bytes.len != 0) {
                                 self.state = State{ .lhs = {} };
                                 return Token{ .id = .target, .bytes = bytes };
@@ -103,7 +103,7 @@ pub const Tokenizer = struct {
                             break; // advance
                         },
                         else => {
-                            const bytes = target.toSlice();
+                            const bytes = target.span();
                             if (bytes.len != 0) {
                                 self.state = State{ .rhs = {} };
                                 return Token{ .id = .target, .bytes = bytes };
@@ -115,7 +115,7 @@ pub const Tokenizer = struct {
                     },
                     .target_colon_reverse_solidus => |*target| switch (char) {
                         '\n', '\r' => {
-                            const bytes = target.toSlice();
+                            const bytes = target.span();
                             if (bytes.len != 0) {
                                 self.state = State{ .lhs = {} };
                                 return Token{ .id = .target, .bytes = bytes };
@@ -175,7 +175,7 @@ pub const Tokenizer = struct {
                     },
                     .prereq_quote => |*prereq| switch (char) {
                         '"' => {
-                            const bytes = prereq.toSlice();
+                            const bytes = prereq.span();
                             self.index += 1;
                             self.state = State{ .rhs = {} };
                             return Token{ .id = .prereq, .bytes = bytes };
@@ -187,12 +187,12 @@ pub const Tokenizer = struct {
                     },
                     .prereq => |*prereq| switch (char) {
                         '\t', ' ' => {
-                            const bytes = prereq.toSlice();
+                            const bytes = prereq.span();
                             self.state = State{ .rhs = {} };
                             return Token{ .id = .prereq, .bytes = bytes };
                         },
                         '\n', '\r' => {
-                            const bytes = prereq.toSlice();
+                            const bytes = prereq.span();
                             self.state = State{ .lhs = {} };
                             return Token{ .id = .prereq, .bytes = bytes };
                         },
@@ -207,7 +207,7 @@ pub const Tokenizer = struct {
                     },
                     .prereq_continuation => |*prereq| switch (char) {
                         '\n' => {
-                            const bytes = prereq.toSlice();
+                            const bytes = prereq.span();
                             self.index += 1;
                             self.state = State{ .rhs = {} };
                             return Token{ .id = .prereq, .bytes = bytes };
@@ -225,7 +225,7 @@ pub const Tokenizer = struct {
                     },
                     .prereq_continuation_linefeed => |prereq| switch (char) {
                         '\n' => {
-                            const bytes = prereq.toSlice();
+                            const bytes = prereq.span();
                             self.index += 1;
                             self.state = State{ .rhs = {} };
                             return Token{ .id = .prereq, .bytes = bytes };
@@ -249,7 +249,7 @@ pub const Tokenizer = struct {
             .rhs_continuation_linefeed,
             => {},
             .target => |target| {
-                return self.errorPosition(idx, target.toSlice(), "incomplete target", .{});
+                return self.errorPosition(idx, target.span(), "incomplete target", .{});
             },
             .target_reverse_solidus,
             .target_dollar_sign,
@@ -258,7 +258,7 @@ pub const Tokenizer = struct {
                 return self.errorIllegalChar(idx, self.bytes[idx], "incomplete escape", .{});
             },
             .target_colon => |target| {
-                const bytes = target.toSlice();
+                const bytes = target.span();
                 if (bytes.len != 0) {
                     self.index += 1;
                     self.state = State{ .rhs = {} };
@@ -268,7 +268,7 @@ pub const Tokenizer = struct {
                 self.state = State{ .lhs = {} };
             },
             .target_colon_reverse_solidus => |target| {
-                const bytes = target.toSlice();
+                const bytes = target.span();
                 if (bytes.len != 0) {
                     self.index += 1;
                     self.state = State{ .rhs = {} };
@@ -278,20 +278,20 @@ pub const Tokenizer = struct {
                 self.state = State{ .lhs = {} };
             },
             .prereq_quote => |prereq| {
-                return self.errorPosition(idx, prereq.toSlice(), "incomplete quoted prerequisite", .{});
+                return self.errorPosition(idx, prereq.span(), "incomplete quoted prerequisite", .{});
             },
             .prereq => |prereq| {
-                const bytes = prereq.toSlice();
+                const bytes = prereq.span();
                 self.state = State{ .lhs = {} };
                 return Token{ .id = .prereq, .bytes = bytes };
             },
             .prereq_continuation => |prereq| {
-                const bytes = prereq.toSlice();
+                const bytes = prereq.span();
                 self.state = State{ .lhs = {} };
                 return Token{ .id = .prereq, .bytes = bytes };
             },
             .prereq_continuation_linefeed => |prereq| {
-                const bytes = prereq.toSlice();
+                const bytes = prereq.span();
                 self.state = State{ .lhs = {} };
                 return Token{ .id = .prereq, .bytes = bytes };
             },
@@ -300,7 +300,7 @@ pub const Tokenizer = struct {
     }
 
     fn errorf(self: *Tokenizer, comptime fmt: []const u8, args: var) Error {
-        self.error_text = (try std.Buffer.allocPrint(&self.arena.allocator, fmt, args)).toSlice();
+        self.error_text = (try std.Buffer.allocPrint(&self.arena.allocator, fmt, args)).span();
         return Error.InvalidInput;
     }
 
@@ -312,7 +312,7 @@ pub const Tokenizer = struct {
         try printCharValues(&out, bytes);
         try buffer.append("'");
         try buffer.outStream().print(" at position {}", .{position - (bytes.len - 1)});
-        self.error_text = buffer.toSlice();
+        self.error_text = buffer.span();
         return Error.InvalidInput;
     }
 
@@ -322,7 +322,7 @@ pub const Tokenizer = struct {
         try printUnderstandableChar(&buffer, char);
         try buffer.outStream().print(" at position {}", .{position});
         if (fmt.len != 0) try buffer.outStream().print(": " ++ fmt, args);
-        self.error_text = buffer.toSlice();
+        self.error_text = buffer.span();
         return Error.InvalidInput;
     }
 
@@ -865,7 +865,7 @@ fn depTokenizer(input: []const u8, expect: []const u8) !void {
         try buffer.append("}");
         i += 1;
     }
-    const got: []const u8 = buffer.toSlice();
+    const got: []const u8 = buffer.span();
 
     if (std.mem.eql(u8, expect, got)) {
         testing.expect(true);
src-self-hosted/ir.zig
@@ -965,9 +965,9 @@ pub const Code = struct {
 
     pub fn dump(self: *Code) void {
         var bb_i: usize = 0;
-        for (self.basic_block_list.toSliceConst()) |bb| {
+        for (self.basic_block_list.span()) |bb| {
             std.debug.warn("{s}_{}:\n", .{ bb.name_hint, bb.debug_id });
-            for (bb.instruction_list.toSliceConst()) |instr| {
+            for (bb.instruction_list.span()) |instr| {
                 std.debug.warn("  ", .{});
                 instr.dump();
                 std.debug.warn("\n", .{});
@@ -978,7 +978,7 @@ pub const Code = struct {
     /// returns a ref-incremented value, or adds a compile error
     pub fn getCompTimeResult(self: *Code, comp: *Compilation) !*Value {
         const bb = self.basic_block_list.at(0);
-        for (bb.instruction_list.toSliceConst()) |inst| {
+        for (bb.instruction_list.span()) |inst| {
             if (inst.cast(Inst.Return)) |ret_inst| {
                 const ret_value = ret_inst.params.return_value;
                 if (ret_value.isCompTime()) {
@@ -2585,6 +2585,6 @@ pub fn analyze(comp: *Compilation, old_code: *Code, expected_type: ?*Type) !*Cod
         return ira.irb.finish();
     }
 
-    ira.irb.code.return_type = try ira.resolvePeerTypes(expected_type, ira.src_implicit_return_type_list.toSliceConst());
+    ira.irb.code.return_type = try ira.resolvePeerTypes(expected_type, ira.src_implicit_return_type_list.span());
     return ira.irb.finish();
 }
src-self-hosted/libc_installation.zig
@@ -54,7 +54,7 @@ pub const LibCInstallation = struct {
             }
         }
 
-        const contents = try std.io.readFileAlloc(allocator, libc_file);
+        const contents = try std.fs.cwd().readFileAlloc(allocator, libc_file, std.math.maxInt(usize));
         defer allocator.free(contents);
 
         var it = std.mem.tokenize(contents, "\n");
@@ -229,7 +229,7 @@ pub const LibCInstallation = struct {
             "-xc",
             dev_null,
         };
-        const exec_res = std.ChildProcess.exec2(.{
+        const exec_res = std.ChildProcess.exec(.{
             .allocator = allocator,
             .argv = &argv,
             .max_output_bytes = 1024 * 1024,
@@ -335,7 +335,7 @@ pub const LibCInstallation = struct {
             const stream = result_buf.outStream();
             try stream.print("{}\\Include\\{}\\ucrt", .{ search.path, search.version });
 
-            var dir = fs.cwd().openDir(result_buf.toSliceConst(), .{}) catch |err| switch (err) {
+            var dir = fs.cwd().openDir(result_buf.span(), .{}) catch |err| switch (err) {
                 error.FileNotFound,
                 error.NotDir,
                 error.NoDevice,
@@ -382,7 +382,7 @@ pub const LibCInstallation = struct {
             const stream = result_buf.outStream();
             try stream.print("{}\\Lib\\{}\\ucrt\\{}", .{ search.path, search.version, arch_sub_dir });
 
-            var dir = fs.cwd().openDir(result_buf.toSliceConst(), .{}) catch |err| switch (err) {
+            var dir = fs.cwd().openDir(result_buf.span(), .{}) catch |err| switch (err) {
                 error.FileNotFound,
                 error.NotDir,
                 error.NoDevice,
@@ -437,7 +437,7 @@ pub const LibCInstallation = struct {
             const stream = result_buf.outStream();
             try stream.print("{}\\Lib\\{}\\um\\{}", .{ search.path, search.version, arch_sub_dir });
 
-            var dir = fs.cwd().openDir(result_buf.toSliceConst(), .{}) catch |err| switch (err) {
+            var dir = fs.cwd().openDir(result_buf.span(), .{}) catch |err| switch (err) {
                 error.FileNotFound,
                 error.NotDir,
                 error.NoDevice,
@@ -475,7 +475,7 @@ pub const LibCInstallation = struct {
 
         try result_buf.append("\\include");
 
-        var dir = fs.cwd().openDir(result_buf.toSliceConst(), .{}) catch |err| switch (err) {
+        var dir = fs.cwd().openDir(result_buf.span(), .{}) catch |err| switch (err) {
             error.FileNotFound,
             error.NotDir,
             error.NoDevice,
@@ -522,7 +522,7 @@ fn ccPrintFileName(args: CCPrintFileNameOptions) ![:0]u8 {
     defer allocator.free(arg1);
     const argv = [_][]const u8{ cc_exe, arg1 };
 
-    const exec_res = std.ChildProcess.exec2(.{
+    const exec_res = std.ChildProcess.exec(.{
         .allocator = allocator,
         .argv = &argv,
         .max_output_bytes = 1024 * 1024,
src-self-hosted/link.zig
@@ -36,7 +36,7 @@ pub fn link(comp: *Compilation) !void {
     ctx.args = std.ArrayList([*:0]const u8).init(&ctx.arena.allocator);
     ctx.link_msg = std.Buffer.initNull(&ctx.arena.allocator);
 
-    ctx.out_file_path = try std.Buffer.init(&ctx.arena.allocator, comp.name.toSliceConst());
+    ctx.out_file_path = try std.Buffer.init(&ctx.arena.allocator, comp.name.span());
     switch (comp.kind) {
         .Exe => {
             try ctx.out_file_path.append(comp.target.exeFileExt());
@@ -70,7 +70,7 @@ pub fn link(comp: *Compilation) !void {
     try constructLinkerArgs(&ctx);
 
     if (comp.verbose_link) {
-        for (ctx.args.toSliceConst()) |arg, i| {
+        for (ctx.args.span()) |arg, i| {
             const space = if (i == 0) "" else " ";
             std.debug.warn("{}{s}", .{ space, arg });
         }
@@ -78,7 +78,7 @@ pub fn link(comp: *Compilation) !void {
     }
 
     const extern_ofmt = toExternObjectFormatType(comp.target.getObjectFormat());
-    const args_slice = ctx.args.toSlice();
+    const args_slice = ctx.args.span();
 
     {
         // LLD is not thread-safe, so we grab a global lock.
@@ -91,7 +91,7 @@ pub fn link(comp: *Compilation) !void {
                 // TODO capture these messages and pass them through the system, reporting them through the
                 // event system instead of printing them directly here.
                 // perhaps try to parse and understand them.
-                std.debug.warn("{}\n", .{ctx.link_msg.toSliceConst()});
+                std.debug.warn("{}\n", .{ctx.link_msg.span()});
             }
             return error.LinkFailed;
         }
@@ -173,7 +173,7 @@ fn constructLinkerArgsElf(ctx: *Context) !void {
     //}
 
     try ctx.args.append("-o");
-    try ctx.args.append(ctx.out_file_path.toSliceConst());
+    try ctx.args.append(ctx.out_file_path.span());
 
     if (ctx.link_in_crt) {
         const crt1o = if (ctx.comp.is_static) "crt1.o" else "Scrt1.o";
@@ -291,7 +291,7 @@ fn constructLinkerArgsCoff(ctx: *Context) !void {
 
     const is_library = ctx.comp.kind == .Lib;
 
-    const out_arg = try std.fmt.allocPrint(&ctx.arena.allocator, "-OUT:{}\x00", .{ctx.out_file_path.toSliceConst()});
+    const out_arg = try std.fmt.allocPrint(&ctx.arena.allocator, "-OUT:{}\x00", .{ctx.out_file_path.span()});
     try ctx.args.append(@ptrCast([*:0]const u8, out_arg.ptr));
 
     if (ctx.comp.haveLibC()) {
@@ -394,7 +394,7 @@ fn constructLinkerArgsMachO(ctx: *Context) !void {
     }
 
     try ctx.args.append("-o");
-    try ctx.args.append(ctx.out_file_path.toSliceConst());
+    try ctx.args.append(ctx.out_file_path.span());
 
     if (shared) {
         try ctx.args.append("-headerpad_max_install_names");
@@ -432,7 +432,7 @@ fn constructLinkerArgsMachO(ctx: *Context) !void {
 
     // TODO
     //if (ctx.comp.target == Target.Native) {
-    //    for (ctx.comp.link_libs_list.toSliceConst()) |lib| {
+    //    for (ctx.comp.link_libs_list.span()) |lib| {
     //        if (mem.eql(u8, lib.name, "c")) {
     //            // on Darwin, libSystem has libc in it, but also you have to use it
     //            // to make syscalls because the syscall numbers are not documented
@@ -482,7 +482,7 @@ fn addFnObjects(ctx: *Context) !void {
             ctx.comp.gpa().destroy(node);
             continue;
         };
-        try ctx.args.append(fn_val.containing_object.toSliceConst());
+        try ctx.args.append(fn_val.containing_object.span());
         it = node.next;
     }
 }
src-self-hosted/main.zig
@@ -421,7 +421,7 @@ fn buildOutputType(allocator: *Allocator, args: []const []const u8, out_type: Co
         process.exit(1);
     }
 
-    try ZigCompiler.setLlvmArgv(allocator, mllvm_flags.toSliceConst());
+    try ZigCompiler.setLlvmArgv(allocator, mllvm_flags.span());
 
     const zig_lib_dir = introspect.resolveZigLibDir(allocator) catch process.exit(1);
     defer allocator.free(zig_lib_dir);
@@ -448,14 +448,14 @@ fn buildOutputType(allocator: *Allocator, args: []const []const u8, out_type: Co
         comp.override_libc = &override_libc;
     }
 
-    for (system_libs.toSliceConst()) |lib| {
+    for (system_libs.span()) |lib| {
         _ = try comp.addLinkLib(lib, true);
     }
 
     comp.version = version;
     comp.is_test = false;
     comp.linker_script = linker_script;
-    comp.clang_argv = clang_argv_buf.toSliceConst();
+    comp.clang_argv = clang_argv_buf.span();
     comp.strip = strip;
 
     comp.verbose_tokenize = verbose_tokenize;
@@ -488,8 +488,8 @@ fn buildOutputType(allocator: *Allocator, args: []const []const u8, out_type: Co
     comp.emit_asm = emit_asm;
     comp.emit_llvm_ir = emit_llvm_ir;
     comp.emit_h = emit_h;
-    comp.assembly_files = assembly_files.toSliceConst();
-    comp.link_objects = link_objects.toSliceConst();
+    comp.assembly_files = assembly_files.span();
+    comp.link_objects = link_objects.span();
 
     comp.start();
     processBuildEvents(comp, color);
@@ -683,7 +683,7 @@ fn cmdFmt(allocator: *Allocator, args: []const []const u8) !void {
     };
 
     var group = event.Group(FmtError!void).init(allocator);
-    for (input_files.toSliceConst()) |file_path| {
+    for (input_files.span()) |file_path| {
         try group.call(fmtPath, .{ &fmt, file_path, check_flag });
     }
     try group.wait();
@@ -898,7 +898,7 @@ const CliPkg = struct {
     }
 
     pub fn deinit(self: *CliPkg) void {
-        for (self.children.toSliceConst()) |child| {
+        for (self.children.span()) |child| {
             child.deinit();
         }
         self.children.deinit();
src-self-hosted/stage2.zig
@@ -185,14 +185,14 @@ fn fmtMain(argc: c_int, argv: [*]const [*:0]const u8) !void {
     const argc_usize = @intCast(usize, argc);
     var arg_i: usize = 0;
     while (arg_i < argc_usize) : (arg_i += 1) {
-        try args_list.append(mem.toSliceConst(u8, argv[arg_i]));
+        try args_list.append(mem.spanZ(argv[arg_i]));
     }
 
     stdout = std.io.getStdOut().outStream();
     stderr_file = std.io.getStdErr();
     stderr = stderr_file.outStream();
 
-    const args = args_list.toSliceConst()[2..];
+    const args = args_list.span()[2..];
 
     var color: errmsg.Color = .Auto;
     var stdin_flag: bool = false;
@@ -285,7 +285,7 @@ fn fmtMain(argc: c_int, argv: [*]const [*:0]const u8) !void {
         .allocator = allocator,
     };
 
-    for (input_files.toSliceConst()) |file_path| {
+    for (input_files.span()) |file_path| {
         try fmtPath(&fmt, file_path, check_flag);
     }
     if (fmt.any_error) {
@@ -318,7 +318,8 @@ fn fmtPath(fmt: *Fmt, file_path: []const u8, check_mode: bool) FmtError!void {
     if (fmt.seen.exists(file_path)) return;
     try fmt.seen.put(file_path);
 
-    const source_code = io.readFileAlloc(fmt.allocator, file_path) catch |err| switch (err) {
+    const max = std.math.maxInt(usize);
+    const source_code = fs.cwd().readFileAlloc(fmt.allocator, file_path, max) catch |err| switch (err) {
         error.IsDir, error.AccessDenied => {
             // TODO make event based (and dir.next())
             var dir = try fs.cwd().openDir(file_path, .{ .iterate = true });
@@ -450,7 +451,7 @@ export fn stage2_DepTokenizer_next(self: *stage2_DepTokenizer) stage2_DepNextRes
         const textz = std.Buffer.init(&self.handle.arena.allocator, self.handle.error_text) catch @panic("failed to create .d tokenizer error text");
         return stage2_DepNextResult{
             .type_id = .error_,
-            .textz = textz.toSlice().ptr,
+            .textz = textz.span().ptr,
         };
     };
     const token = otoken orelse {
@@ -465,7 +466,7 @@ export fn stage2_DepTokenizer_next(self: *stage2_DepTokenizer) stage2_DepNextRes
             .target => .target,
             .prereq => .prereq,
         },
-        .textz = textz.toSlice().ptr,
+        .textz = textz.span().ptr,
     };
 }
 
@@ -572,7 +573,7 @@ fn detectNativeCpuWithLLVM(
     var result = Target.Cpu.baseline(arch);
 
     if (llvm_cpu_name_z) |cpu_name_z| {
-        const llvm_cpu_name = mem.toSliceConst(u8, cpu_name_z);
+        const llvm_cpu_name = mem.spanZ(cpu_name_z);
 
         for (arch.allCpuModels()) |model| {
             const this_llvm_name = model.llvm_name orelse continue;
@@ -593,7 +594,7 @@ fn detectNativeCpuWithLLVM(
     const all_features = arch.allFeaturesList();
 
     if (llvm_cpu_features_opt) |llvm_cpu_features| {
-        var it = mem.tokenize(mem.toSliceConst(u8, llvm_cpu_features), ",");
+        var it = mem.tokenize(mem.spanZ(llvm_cpu_features), ",");
         while (it.next()) |decorated_llvm_feat| {
             var op: enum {
                 add,
@@ -688,9 +689,9 @@ fn stage2CrossTarget(
     mcpu_oz: ?[*:0]const u8,
     dynamic_linker_oz: ?[*:0]const u8,
 ) !CrossTarget {
-    const zig_triple = if (zig_triple_oz) |zig_triple_z| mem.toSliceConst(u8, zig_triple_z) else "native";
-    const mcpu = if (mcpu_oz) |mcpu_z| mem.toSliceConst(u8, mcpu_z) else null;
-    const dynamic_linker = if (dynamic_linker_oz) |dl_z| mem.toSliceConst(u8, dl_z) else null;
+    const zig_triple = if (zig_triple_oz) |zig_triple_z| mem.spanZ(zig_triple_z) else "native";
+    const mcpu = if (mcpu_oz) |mcpu_z| mem.spanZ(mcpu_z) else null;
+    const dynamic_linker = if (dynamic_linker_oz) |dl_z| mem.spanZ(dl_z) else null;
     var diags: CrossTarget.ParseOptions.Diagnostics = .{};
     const target: CrossTarget = CrossTarget.parse(.{
         .arch_os_abi = zig_triple,
@@ -814,7 +815,7 @@ const Stage2LibCInstallation = extern struct {
 export fn stage2_libc_parse(stage1_libc: *Stage2LibCInstallation, libc_file_z: [*:0]const u8) Error {
     stderr_file = std.io.getStdErr();
     stderr = stderr_file.outStream();
-    const libc_file = mem.toSliceConst(u8, libc_file_z);
+    const libc_file = mem.spanZ(libc_file_z);
     var libc = LibCInstallation.parse(std.heap.c_allocator, libc_file, stderr) catch |err| switch (err) {
         error.ParseError => return .SemanticAnalyzeFail,
         error.DiskQuota => return .DiskQuota,
@@ -995,7 +996,7 @@ const Stage2Target = extern struct {
             \\
         );
 
-        assert(mem.endsWith(u8, llvm_features_buffer.toSliceConst(), ","));
+        assert(mem.endsWith(u8, llvm_features_buffer.span(), ","));
         llvm_features_buffer.shrink(llvm_features_buffer.len() - 1);
 
         var os_builtin_str_buffer = try std.Buffer.allocPrint(allocator,
@@ -1120,7 +1121,7 @@ const Stage2Target = extern struct {
         try os_builtin_str_buffer.append("};\n");
 
         try cache_hash.append(
-            os_builtin_str_buffer.toSlice()[os_builtin_str_ver_start_index..os_builtin_str_buffer.len()],
+            os_builtin_str_buffer.span()[os_builtin_str_ver_start_index..os_builtin_str_buffer.len()],
         );
 
         const glibc_or_darwin_version = blk: {
@@ -1232,10 +1233,10 @@ fn stage2DetectNativePaths(stage1_paths: *Stage2NativePaths) !void {
     var paths = try std.zig.system.NativePaths.detect(std.heap.c_allocator);
     errdefer paths.deinit();
 
-    try convertSlice(paths.include_dirs.toSlice(), &stage1_paths.include_dirs_ptr, &stage1_paths.include_dirs_len);
-    try convertSlice(paths.lib_dirs.toSlice(), &stage1_paths.lib_dirs_ptr, &stage1_paths.lib_dirs_len);
-    try convertSlice(paths.rpaths.toSlice(), &stage1_paths.rpaths_ptr, &stage1_paths.rpaths_len);
-    try convertSlice(paths.warnings.toSlice(), &stage1_paths.warnings_ptr, &stage1_paths.warnings_len);
+    try convertSlice(paths.include_dirs.span(), &stage1_paths.include_dirs_ptr, &stage1_paths.include_dirs_len);
+    try convertSlice(paths.lib_dirs.span(), &stage1_paths.lib_dirs_ptr, &stage1_paths.lib_dirs_len);
+    try convertSlice(paths.rpaths.span(), &stage1_paths.rpaths_ptr, &stage1_paths.rpaths_len);
+    try convertSlice(paths.warnings.span(), &stage1_paths.warnings_ptr, &stage1_paths.warnings_len);
 }
 
 fn convertSlice(slice: [][:0]u8, ptr: *[*][*:0]u8, len: *usize) !void {
src-self-hosted/test.zig
@@ -88,8 +88,7 @@ pub const TestContext = struct {
             try std.fs.cwd().makePath(dirname);
         }
 
-        // TODO async I/O
-        try std.io.writeFile(file1_path, source);
+        try std.fs.cwd().writeFile(file1_path, source);
 
         var comp = try Compilation.create(
             &self.zig_compiler,
@@ -122,8 +121,7 @@ pub const TestContext = struct {
             try std.fs.cwd().makePath(dirname);
         }
 
-        // TODO async I/O
-        try std.io.writeFile(file1_path, source);
+        try std.fs.cwd().writeFile(file1_path, source);
 
         var comp = try Compilation.create(
             &self.zig_compiler,
@@ -156,7 +154,11 @@ pub const TestContext = struct {
             .Ok => {
                 const argv = [_][]const u8{exe_file};
                 // TODO use event loop
-                const child = try std.ChildProcess.exec(allocator, argv, null, null, 1024 * 1024);
+                const child = try std.ChildProcess.exec(.{
+                    .allocator = allocator,
+                    .argv = argv,
+                    .max_output_bytes = 1024 * 1024,
+                });
                 switch (child.term) {
                     .Exited => |code| {
                         if (code != 0) {
src-self-hosted/translate_c.zig
@@ -235,7 +235,7 @@ pub const Context = struct {
 
     /// Convert a null-terminated C string to a slice allocated in the arena
     fn str(c: *Context, s: [*:0]const u8) ![]u8 {
-        return mem.dupe(c.a(), u8, mem.toSliceConst(u8, s));
+        return mem.dupe(c.a(), u8, mem.spanZ(s));
     }
 
     /// Convert a clang source location to a file:line:column string
@@ -5851,7 +5851,7 @@ fn parseCPrefixOpExpr(c: *Context, it: *CTokenList.Iterator, source: []const u8,
 
 fn tokenSlice(c: *Context, token: ast.TokenIndex) []u8 {
     const tok = c.tree.tokens.at(token);
-    const slice = c.source_buffer.toSlice()[tok.start..tok.end];
+    const slice = c.source_buffer.span()[tok.start..tok.end];
     return if (mem.startsWith(u8, slice, "@\""))
         slice[2 .. slice.len - 1]
     else
src-self-hosted/util.zig
@@ -19,8 +19,8 @@ pub fn getDarwinArchString(self: Target) [:0]const u8 {
 pub fn llvmTargetFromTriple(triple: std.Buffer) !*llvm.Target {
     var result: *llvm.Target = undefined;
     var err_msg: [*:0]u8 = undefined;
-    if (llvm.GetTargetFromTriple(triple.toSlice(), &result, &err_msg) != 0) {
-        std.debug.warn("triple: {s} error: {s}\n", .{ triple.toSlice(), err_msg });
+    if (llvm.GetTargetFromTriple(triple.span(), &result, &err_msg) != 0) {
+        std.debug.warn("triple: {s} error: {s}\n", .{ triple.span(), err_msg });
         return error.UnsupportedTarget;
     }
     return result;
src-self-hosted/value.zig
@@ -156,7 +156,7 @@ pub const Value = struct {
             const llvm_fn_type = try self.base.typ.getLlvmType(ofile.arena, ofile.context);
             const llvm_fn = llvm.AddFunction(
                 ofile.module,
-                self.symbol_name.toSliceConst(),
+                self.symbol_name.span(),
                 llvm_fn_type,
             ) orelse return error.OutOfMemory;
 
@@ -241,7 +241,7 @@ pub const Value = struct {
             const llvm_fn_type = try self.base.typ.getLlvmType(ofile.arena, ofile.context);
             const llvm_fn = llvm.AddFunction(
                 ofile.module,
-                self.symbol_name.toSliceConst(),
+                self.symbol_name.span(),
                 llvm_fn_type,
             ) orelse return error.OutOfMemory;
 
test/src/compare_output.zig
@@ -91,7 +91,7 @@ pub const CompareOutputContext = struct {
         const b = self.b;
 
         const write_src = b.addWriteFiles();
-        for (case.sources.toSliceConst()) |src_file| {
+        for (case.sources.span()) |src_file| {
             write_src.add(src_file.filename, src_file.source);
         }
 
@@ -105,7 +105,7 @@ pub const CompareOutputContext = struct {
                 }
 
                 const exe = b.addExecutable("test", null);
-                exe.addAssemblyFileFromWriteFileStep(write_src, case.sources.toSliceConst()[0].filename);
+                exe.addAssemblyFileFromWriteFileStep(write_src, case.sources.span()[0].filename);
 
                 const run = exe.run();
                 run.addArgs(case.cli_args);
@@ -125,7 +125,7 @@ pub const CompareOutputContext = struct {
                         if (mem.indexOf(u8, annotated_case_name, filter) == null) continue;
                     }
 
-                    const basename = case.sources.toSliceConst()[0].filename;
+                    const basename = case.sources.span()[0].filename;
                     const exe = b.addExecutableFromWriteFileStep("test", write_src, basename);
                     exe.setBuildMode(mode);
                     if (case.link_libc) {
@@ -146,7 +146,7 @@ pub const CompareOutputContext = struct {
                     if (mem.indexOf(u8, annotated_case_name, filter) == null) return;
                 }
 
-                const basename = case.sources.toSliceConst()[0].filename;
+                const basename = case.sources.span()[0].filename;
                 const exe = b.addExecutableFromWriteFileStep("test", write_src, basename);
                 if (case.link_libc) {
                     exe.linkSystemLibrary("c");
test/src/run_translated_c.zig
@@ -82,13 +82,13 @@ pub const RunTranslatedCContext = struct {
         }
 
         const write_src = b.addWriteFiles();
-        for (case.sources.toSliceConst()) |src_file| {
+        for (case.sources.span()) |src_file| {
             write_src.add(src_file.filename, src_file.source);
         }
         const translate_c = b.addTranslateC(.{
             .write_file = .{
                 .step = write_src,
-                .basename = case.sources.toSliceConst()[0].filename,
+                .basename = case.sources.span()[0].filename,
             },
         });
         translate_c.step.name = b.fmt("{} translate-c", .{annotated_case_name});
test/src/translate_c.zig
@@ -105,20 +105,20 @@ pub const TranslateCContext = struct {
         }
 
         const write_src = b.addWriteFiles();
-        for (case.sources.toSliceConst()) |src_file| {
+        for (case.sources.span()) |src_file| {
             write_src.add(src_file.filename, src_file.source);
         }
 
         const translate_c = b.addTranslateC(.{
             .write_file = .{
                 .step = write_src,
-                .basename = case.sources.toSliceConst()[0].filename,
+                .basename = case.sources.span()[0].filename,
             },
         });
         translate_c.step.name = annotated_case_name;
         translate_c.setTarget(case.target);
 
-        const check_file = translate_c.addCheckFile(case.expected_lines.toSliceConst());
+        const check_file = translate_c.addCheckFile(case.expected_lines.span());
 
         self.step.dependOn(&check_file.step);
     }
test/stage1/behavior/cast.zig
@@ -329,7 +329,7 @@ fn testCastPtrOfArrayToSliceAndPtr() void {
 test "cast *[1][*]const u8 to [*]const ?[*]const u8" {
     const window_name = [1][*]const u8{"window name"};
     const x: [*]const ?[*]const u8 = &window_name;
-    expect(mem.eql(u8, std.mem.toSliceConst(u8, @ptrCast([*:0]const u8, x[0].?)), "window name"));
+    expect(mem.eql(u8, std.mem.spanZ(@ptrCast([*:0]const u8, x[0].?)), "window name"));
 }
 
 test "@intCast comptime_int" {
test/stage1/behavior/pointers.zig
@@ -225,7 +225,7 @@ test "null terminated pointer" {
             var zero_ptr: [*:0]const u8 = @ptrCast([*:0]const u8, &array_with_zero);
             var no_zero_ptr: [*]const u8 = zero_ptr;
             var zero_ptr_again = @ptrCast([*:0]const u8, no_zero_ptr);
-            expect(std.mem.eql(u8, std.mem.toSliceConst(u8, zero_ptr_again), "hello"));
+            expect(std.mem.eql(u8, std.mem.spanZ(zero_ptr_again), "hello"));
         }
     };
     S.doTheTest();
test/standalone/brace_expansion/main.zig
@@ -131,11 +131,11 @@ fn expandString(input: []const u8, output: *Buffer) !void {
     try expandNode(root, &result_list);
 
     try output.resize(0);
-    for (result_list.toSliceConst()) |buf, i| {
+    for (result_list.span()) |buf, i| {
         if (i != 0) {
             try output.appendByte(' ');
         }
-        try output.append(buf.toSliceConst());
+        try output.append(buf.span());
     }
 }
 
@@ -157,20 +157,20 @@ fn expandNode(node: Node, output: *ArrayList(Buffer)) ExpandNodeError!void {
             var child_list_b = ArrayList(Buffer).init(global_allocator);
             try expandNode(b_node, &child_list_b);
 
-            for (child_list_a.toSliceConst()) |buf_a| {
-                for (child_list_b.toSliceConst()) |buf_b| {
+            for (child_list_a.span()) |buf_a| {
+                for (child_list_b.span()) |buf_b| {
                     var combined_buf = try Buffer.initFromBuffer(buf_a);
-                    try combined_buf.append(buf_b.toSliceConst());
+                    try combined_buf.append(buf_b.span());
                     try output.append(combined_buf);
                 }
             }
         },
         Node.List => |list| {
-            for (list.toSliceConst()) |child_node| {
+            for (list.span()) |child_node| {
                 var child_list = ArrayList(Buffer).init(global_allocator);
                 try expandNode(child_node, &child_list);
 
-                for (child_list.toSliceConst()) |buf| {
+                for (child_list.span()) |buf| {
                     try output.append(buf);
                 }
             }
@@ -196,8 +196,8 @@ pub fn main() !void {
     var result_buf = try Buffer.initSize(global_allocator, 0);
     defer result_buf.deinit();
 
-    try expandString(stdin_buf.toSlice(), &result_buf);
-    try stdout_file.write(result_buf.toSliceConst());
+    try expandString(stdin_buf.span(), &result_buf);
+    try stdout_file.write(result_buf.span());
 }
 
 test "invalid inputs" {
@@ -256,5 +256,5 @@ fn expectExpansion(test_input: []const u8, expected_result: []const u8) void {
 
     expandString(test_input, &result) catch unreachable;
 
-    testing.expectEqualSlices(u8, expected_result, result.toSlice());
+    testing.expectEqualSlices(u8, expected_result, result.span());
 }
test/standalone/guess_number/main.zig
@@ -17,7 +17,7 @@ pub fn main() !void {
     const seed = std.mem.readIntNative(u64, &seed_bytes);
     var prng = std.rand.DefaultPrng.init(seed);
 
-    const answer = prng.random.range(u8, 0, 100) + 1;
+    const answer = prng.random.intRangeLessThan(u8, 0, 100) + 1;
 
     while (true) {
         try stdout.print("\nGuess a number between 1 and 100: ", .{});
test/cli.zig
@@ -59,7 +59,12 @@ fn printCmd(cwd: []const u8, argv: []const []const u8) void {
 
 fn exec(cwd: []const u8, argv: []const []const u8) !ChildProcess.ExecResult {
     const max_output_size = 100 * 1024;
-    const result = ChildProcess.exec(a, argv, cwd, null, max_output_size) catch |err| {
+    const result = ChildProcess.exec(.{
+        .allocator = a,
+        .argv = argv,
+        .cwd = cwd,
+        .max_output_bytes = max_output_size,
+    }) catch |err| {
         std.debug.warn("The following command failed:\n", .{});
         printCmd(cwd, argv);
         return err;
@@ -101,7 +106,7 @@ fn testGodboltApi(zig_exe: []const u8, dir_path: []const u8) anyerror!void {
     const example_zig_path = try fs.path.join(a, &[_][]const u8{ dir_path, "example.zig" });
     const example_s_path = try fs.path.join(a, &[_][]const u8{ dir_path, "example.s" });
 
-    try std.io.writeFile(example_zig_path,
+    try fs.cwd().writeFile(example_zig_path,
         \\// Type your code here, or load an example.
         \\export fn square(num: i32) i32 {
         \\    return num * num;
@@ -124,7 +129,7 @@ fn testGodboltApi(zig_exe: []const u8, dir_path: []const u8) anyerror!void {
     };
     _ = try exec(dir_path, &args);
 
-    const out_asm = try std.io.readFileAlloc(a, example_s_path);
+    const out_asm = try std.fs.cwd().readFileAlloc(a, example_s_path, std.math.maxInt(usize));
     testing.expect(std.mem.indexOf(u8, out_asm, "square:") != null);
     testing.expect(std.mem.indexOf(u8, out_asm, "mov\teax, edi") != null);
     testing.expect(std.mem.indexOf(u8, out_asm, "imul\teax, edi") != null);
test/tests.zig
@@ -583,7 +583,7 @@ pub const StackTracesContext = struct {
 
             warn("Test {}/{} {}...", .{ self.test_index + 1, self.context.test_index, self.name });
 
-            const child = std.ChildProcess.init(args.toSliceConst(), b.allocator) catch unreachable;
+            const child = std.ChildProcess.init(args.span(), b.allocator) catch unreachable;
             defer child.deinit();
 
             child.stdin_behavior = .Ignore;
@@ -592,7 +592,7 @@ pub const StackTracesContext = struct {
             child.env_map = b.env_map;
 
             if (b.verbose) {
-                printInvocation(args.toSliceConst());
+                printInvocation(args.span());
             }
             child.spawn() catch |err| debug.panic("Unable to spawn {}: {}\n", .{ full_exe_path, @errorName(err) });
 
@@ -614,23 +614,23 @@ pub const StackTracesContext = struct {
                             code,
                             expect_code,
                         });
-                        printInvocation(args.toSliceConst());
+                        printInvocation(args.span());
                         return error.TestFailed;
                     }
                 },
                 .Signal => |signum| {
                     warn("Process {} terminated on signal {}\n", .{ full_exe_path, signum });
-                    printInvocation(args.toSliceConst());
+                    printInvocation(args.span());
                     return error.TestFailed;
                 },
                 .Stopped => |signum| {
                     warn("Process {} stopped on signal {}\n", .{ full_exe_path, signum });
-                    printInvocation(args.toSliceConst());
+                    printInvocation(args.span());
                     return error.TestFailed;
                 },
                 .Unknown => |code| {
                     warn("Process {} terminated unexpectedly with error code {}\n", .{ full_exe_path, code });
-                    printInvocation(args.toSliceConst());
+                    printInvocation(args.span());
                     return error.TestFailed;
                 },
             }
@@ -785,7 +785,7 @@ pub const CompileErrorContext = struct {
             } else {
                 try zig_args.append("build-obj");
             }
-            const root_src_basename = self.case.sources.toSliceConst()[0].filename;
+            const root_src_basename = self.case.sources.span()[0].filename;
             try zig_args.append(self.write_src.getOutputPath(root_src_basename));
 
             zig_args.append("--name") catch unreachable;
@@ -809,10 +809,10 @@ pub const CompileErrorContext = struct {
             warn("Test {}/{} {}...", .{ self.test_index + 1, self.context.test_index, self.name });
 
             if (b.verbose) {
-                printInvocation(zig_args.toSliceConst());
+                printInvocation(zig_args.span());
             }
 
-            const child = std.ChildProcess.init(zig_args.toSliceConst(), b.allocator) catch unreachable;
+            const child = std.ChildProcess.init(zig_args.span(), b.allocator) catch unreachable;
             defer child.deinit();
 
             child.env_map = b.env_map;
@@ -822,11 +822,11 @@ pub const CompileErrorContext = struct {
 
             child.spawn() catch |err| debug.panic("Unable to spawn {}: {}\n", .{ zig_args.items[0], @errorName(err) });
 
-            var stdout_buf = Buffer.initNull(b.allocator);
-            var stderr_buf = Buffer.initNull(b.allocator);
+            var stdout_buf = ArrayList(u8).init(b.allocator);
+            var stderr_buf = ArrayList(u8).init(b.allocator);
 
-            child.stdout.?.inStream().readAllBuffer(&stdout_buf, max_stdout_size) catch unreachable;
-            child.stderr.?.inStream().readAllBuffer(&stderr_buf, max_stdout_size) catch unreachable;
+            child.stdout.?.inStream().readAllArrayList(&stdout_buf, max_stdout_size) catch unreachable;
+            child.stderr.?.inStream().readAllArrayList(&stderr_buf, max_stdout_size) catch unreachable;
 
             const term = child.wait() catch |err| {
                 debug.panic("Unable to spawn {}: {}\n", .{ zig_args.items[0], @errorName(err) });
@@ -834,19 +834,19 @@ pub const CompileErrorContext = struct {
             switch (term) {
                 .Exited => |code| {
                     if (code == 0) {
-                        printInvocation(zig_args.toSliceConst());
+                        printInvocation(zig_args.span());
                         return error.CompilationIncorrectlySucceeded;
                     }
                 },
                 else => {
                     warn("Process {} terminated unexpectedly\n", .{b.zig_exe});
-                    printInvocation(zig_args.toSliceConst());
+                    printInvocation(zig_args.span());
                     return error.TestFailed;
                 },
             }
 
-            const stdout = stdout_buf.toSliceConst();
-            const stderr = stderr_buf.toSliceConst();
+            const stdout = stdout_buf.span();
+            const stderr = stderr_buf.span();
 
             if (stdout.len != 0) {
                 warn(
@@ -875,12 +875,12 @@ pub const CompileErrorContext = struct {
 
                 if (!ok) {
                     warn("\n======== Expected these compile errors: ========\n", .{});
-                    for (self.case.expected_errors.toSliceConst()) |expected| {
+                    for (self.case.expected_errors.span()) |expected| {
                         warn("{}\n", .{expected});
                     }
                 }
             } else {
-                for (self.case.expected_errors.toSliceConst()) |expected| {
+                for (self.case.expected_errors.span()) |expected| {
                     if (mem.indexOf(u8, stderr, expected) == null) {
                         warn(
                             \\
@@ -980,7 +980,7 @@ pub const CompileErrorContext = struct {
             if (mem.indexOf(u8, annotated_case_name, filter) == null) return;
         }
         const write_src = b.addWriteFiles();
-        for (case.sources.toSliceConst()) |src_file| {
+        for (case.sources.span()) |src_file| {
             write_src.add(src_file.filename, src_file.source);
         }
 
@@ -1027,7 +1027,7 @@ pub const StandaloneContext = struct {
             zig_args.append("--verbose") catch unreachable;
         }
 
-        const run_cmd = b.addSystemCommand(zig_args.toSliceConst());
+        const run_cmd = b.addSystemCommand(zig_args.span());
 
         const log_step = b.addLog("PASS {}\n", .{annotated_case_name});
         log_step.step.dependOn(&run_cmd.step);
@@ -1127,7 +1127,7 @@ pub const GenHContext = struct {
             const full_h_path = self.obj.getOutputHPath();
             const actual_h = try io.readFileAlloc(b.allocator, full_h_path);
 
-            for (self.case.expected_lines.toSliceConst()) |expected_line| {
+            for (self.case.expected_lines.span()) |expected_line| {
                 if (mem.indexOf(u8, actual_h, expected_line) == null) {
                     warn(
                         \\
@@ -1188,7 +1188,7 @@ pub const GenHContext = struct {
         }
 
         const write_src = b.addWriteFiles();
-        for (case.sources.toSliceConst()) |src_file| {
+        for (case.sources.span()) |src_file| {
             write_src.add(src_file.filename, src_file.source);
         }
 
tools/merge_anal_dumps.zig
@@ -183,13 +183,13 @@ const Dump = struct {
         try mergeSameStrings(&self.zig_version, zig_version);
         try mergeSameStrings(&self.root_name, root_name);
 
-        for (params.get("builds").?.value.Array.toSliceConst()) |json_build| {
+        for (params.get("builds").?.value.Array.span()) |json_build| {
             const target = json_build.Object.get("target").?.value.String;
             try self.targets.append(target);
         }
 
         // Merge files. If the string matches, it's the same file.
-        const other_files = root.Object.get("files").?.value.Array.toSliceConst();
+        const other_files = root.Object.get("files").?.value.Array.span();
         var other_file_to_mine = std.AutoHashMap(usize, usize).init(self.a());
         for (other_files) |other_file, i| {
             const gop = try self.file_map.getOrPut(other_file.String);
@@ -201,7 +201,7 @@ const Dump = struct {
         }
 
         // Merge AST nodes. If the file id, line, and column all match, it's the same AST node.
-        const other_ast_nodes = root.Object.get("astNodes").?.value.Array.toSliceConst();
+        const other_ast_nodes = root.Object.get("astNodes").?.value.Array.span();
         var other_ast_node_to_mine = std.AutoHashMap(usize, usize).init(self.a());
         for (other_ast_nodes) |other_ast_node_json, i| {
             const other_file_id = jsonObjInt(other_ast_node_json, "file");
@@ -221,9 +221,9 @@ const Dump = struct {
         // convert fields lists
         for (other_ast_nodes) |other_ast_node_json, i| {
             const my_node_index = other_ast_node_to_mine.get(i).?.value;
-            const my_node = &self.node_list.toSlice()[my_node_index];
+            const my_node = &self.node_list.span()[my_node_index];
             if (other_ast_node_json.Object.get("fields")) |fields_json_kv| {
-                const other_fields = fields_json_kv.value.Array.toSliceConst();
+                const other_fields = fields_json_kv.value.Array.span();
                 my_node.fields = try self.a().alloc(usize, other_fields.len);
                 for (other_fields) |other_field_index, field_i| {
                     const other_index = @intCast(usize, other_field_index.Integer);
@@ -233,7 +233,7 @@ const Dump = struct {
         }
 
         // Merge errors. If the AST Node matches, it's the same error value.
-        const other_errors = root.Object.get("errors").?.value.Array.toSliceConst();
+        const other_errors = root.Object.get("errors").?.value.Array.span();
         var other_error_to_mine = std.AutoHashMap(usize, usize).init(self.a());
         for (other_errors) |other_error_json, i| {
             const other_src_id = jsonObjInt(other_error_json, "src");
@@ -253,7 +253,7 @@ const Dump = struct {
         // First we identify all the simple types and merge those.
         // Example: void, type, noreturn
         // We can also do integers and floats.
-        const other_types = root.Object.get("types").?.value.Array.toSliceConst();
+        const other_types = root.Object.get("types").?.value.Array.span();
         var other_types_to_mine = std.AutoHashMap(usize, usize).init(self.a());
         for (other_types) |other_type_json, i| {
             const type_kind = jsonObjInt(other_type_json, "kind");
@@ -336,7 +336,7 @@ const Dump = struct {
 
         try jw.objectField("builds");
         try jw.beginArray();
-        for (self.targets.toSliceConst()) |target| {
+        for (self.targets.span()) |target| {
             try jw.arrayElem();
             try jw.beginObject();
             try jw.objectField("target");
@@ -349,7 +349,7 @@ const Dump = struct {
 
         try jw.objectField("types");
         try jw.beginArray();
-        for (self.type_list.toSliceConst()) |t| {
+        for (self.type_list.span()) |t| {
             try jw.arrayElem();
             try jw.beginObject();
 
@@ -379,7 +379,7 @@ const Dump = struct {
 
         try jw.objectField("errors");
         try jw.beginArray();
-        for (self.error_list.toSliceConst()) |zig_error| {
+        for (self.error_list.span()) |zig_error| {
             try jw.arrayElem();
             try jw.beginObject();
 
@@ -395,7 +395,7 @@ const Dump = struct {
 
         try jw.objectField("astNodes");
         try jw.beginArray();
-        for (self.node_list.toSliceConst()) |node| {
+        for (self.node_list.span()) |node| {
             try jw.arrayElem();
             try jw.beginObject();
 
@@ -425,7 +425,7 @@ const Dump = struct {
 
         try jw.objectField("files");
         try jw.beginArray();
-        for (self.file_list.toSliceConst()) |file| {
+        for (self.file_list.span()) |file| {
             try jw.arrayElem();
             try jw.emitString(file);
         }
tools/process_headers.zig
@@ -324,7 +324,7 @@ pub fn main() !void {
             },
             .os = .linux,
         };
-        search: for (search_paths.toSliceConst()) |search_path| {
+        search: for (search_paths.span()) |search_path| {
             var sub_path: []const []const u8 = undefined;
             switch (vendor) {
                 .musl => {
@@ -414,13 +414,13 @@ pub fn main() !void {
                 try contents_list.append(contents);
             }
         }
-        std.sort.sort(*Contents, contents_list.toSlice(), Contents.hitCountLessThan);
+        std.sort.sort(*Contents, contents_list.span(), Contents.hitCountLessThan);
         var best_contents = contents_list.popOrNull().?;
         if (best_contents.hit_count > 1) {
             // worth it to make it generic
             const full_path = try std.fs.path.join(allocator, &[_][]const u8{ out_dir, generic_name, path_kv.key });
             try std.fs.cwd().makePath(std.fs.path.dirname(full_path).?);
-            try std.io.writeFile(full_path, best_contents.bytes);
+            try std.fs.cwd().writeFile(full_path, best_contents.bytes);
             best_contents.is_generic = true;
             while (contents_list.popOrNull()) |contender| {
                 if (contender.hit_count > 1) {
@@ -447,7 +447,7 @@ pub fn main() !void {
             });
             const full_path = try std.fs.path.join(allocator, &[_][]const u8{ out_dir, out_subpath, path_kv.key });
             try std.fs.cwd().makePath(std.fs.path.dirname(full_path).?);
-            try std.io.writeFile(full_path, contents.bytes);
+            try std.fs.cwd().writeFile(full_path, contents.bytes);
         }
     }
 }
tools/update_clang_options.zig
@@ -239,7 +239,7 @@ pub fn main() anyerror!void {
         try std.fmt.allocPrint(allocator, "-I={}/clang/include/clang/Driver", .{llvm_src_root}),
     };
 
-    const child_result = try std.ChildProcess.exec2(.{
+    const child_result = try std.ChildProcess.exec(.{
         .allocator = allocator,
         .argv = &child_args,
         .max_output_bytes = 100 * 1024 * 1024,
tools/update_glibc.zig
@@ -223,15 +223,15 @@ pub fn main() !void {
         var list = std.ArrayList([]const u8).init(allocator);
         var it = global_fn_set.iterator();
         while (it.next()) |kv| try list.append(kv.key);
-        std.sort.sort([]const u8, list.toSlice(), strCmpLessThan);
-        break :blk list.toSliceConst();
+        std.sort.sort([]const u8, list.span(), strCmpLessThan);
+        break :blk list.span();
     };
     const global_ver_list = blk: {
         var list = std.ArrayList([]const u8).init(allocator);
         var it = global_ver_set.iterator();
         while (it.next()) |kv| try list.append(kv.key);
-        std.sort.sort([]const u8, list.toSlice(), versionLessThan);
-        break :blk list.toSliceConst();
+        std.sort.sort([]const u8, list.span(), versionLessThan);
+        break :blk list.span();
     };
     {
         const vers_txt_path = try fs.path.join(allocator, &[_][]const u8{ glibc_out_dir, "vers.txt" });
@@ -264,13 +264,13 @@ pub fn main() !void {
     for (abi_lists) |*abi_list, abi_index| {
         const kv = target_functions.get(@ptrToInt(abi_list)).?;
         const fn_vers_list = &kv.value.fn_vers_list;
-        for (kv.value.list.toSliceConst()) |*ver_fn| {
+        for (kv.value.list.span()) |*ver_fn| {
             const gop = try fn_vers_list.getOrPut(ver_fn.name);
             if (!gop.found_existing) {
                 gop.kv.value = std.ArrayList(usize).init(allocator);
             }
             const ver_index = global_ver_set.get(ver_fn.ver).?.value;
-            if (std.mem.indexOfScalar(usize, gop.kv.value.toSliceConst(), ver_index) == null) {
+            if (std.mem.indexOfScalar(usize, gop.kv.value.span(), ver_index) == null) {
                 try gop.kv.value.append(ver_index);
             }
         }
@@ -297,7 +297,7 @@ pub fn main() !void {
                     try abilist_txt.writeByte('\n');
                     continue;
                 };
-                for (kv.value.toSliceConst()) |ver_index, it_i| {
+                for (kv.value.span()) |ver_index, it_i| {
                     if (it_i != 0) try abilist_txt.writeByte(' ');
                     try abilist_txt.print("{d}", .{ver_index});
                 }