diff --git a/lib/std/Build/Cache/DepTokenizer.zig b/lib/std/Build/Cache/DepTokenizer.zig index c640fa4adc..1a4e2ddb74 100644 --- a/lib/std/Build/Cache/DepTokenizer.zig +++ b/lib/std/Build/Cache/DepTokenizer.zig @@ -974,7 +974,7 @@ fn hexDump(out: anytype, bytes: []const u8) !void { var line: usize = 0; var offset: usize = 0; while (line < n16) : (line += 1) { - try hexDump16(out, offset, bytes[offset .. offset + 16]); + try hexDump16(out, offset, bytes[offset..][0..16]); offset += 16; } diff --git a/lib/std/array_list.zig b/lib/std/array_list.zig index cbca601b82..bbfa588d6d 100644 --- a/lib/std/array_list.zig +++ b/lib/std/array_list.zig @@ -173,7 +173,7 @@ pub fn ArrayListAligned(comptime T: type, comptime alignment: ?u29) type { @memcpy(self.items[i..][0..items.len], items); } - /// Replace range of elements `list[start..start+len]` with `new_items`. + /// Replace range of elements `list[start..][0..len]` with `new_items`. /// Grows list if `len < new_items.len`. /// Shrinks list if `len > new_items.len`. /// Invalidates pointers if this ArrayList is resized. @@ -654,7 +654,7 @@ pub fn ArrayListAlignedUnmanaged(comptime T: type, comptime alignment: ?u29) typ @memcpy(self.items[i..][0..items.len], items); } - /// Replace range of elements `list[start..start+len]` with `new_items` + /// Replace range of elements `list[start..][0..len]` with `new_items` /// Grows list if `len < new_items.len`. /// Shrinks list if `len > new_items.len` /// Invalidates pointers if this ArrayList is resized. diff --git a/lib/std/bounded_array.zig b/lib/std/bounded_array.zig index be32093fe7..0e0b601af6 100644 --- a/lib/std/bounded_array.zig +++ b/lib/std/bounded_array.zig @@ -168,7 +168,7 @@ pub fn BoundedArrayAligned( @memcpy(self.slice()[i..][0..items.len], items); } - /// Replace range of elements `slice[start..start+len]` with `new_items`. + /// Replace range of elements `slice[start..][0..len]` with `new_items`. /// Grows slice if `len < new_items.len`. /// Shrinks slice if `len > new_items.len`. pub fn replaceRange( diff --git a/lib/std/compress/deflate/decompressor.zig b/lib/std/compress/deflate/decompressor.zig index 6c232c598e..40bde67326 100644 --- a/lib/std/compress/deflate/decompressor.zig +++ b/lib/std/compress/deflate/decompressor.zig @@ -591,7 +591,7 @@ pub fn Decompressor(comptime ReaderType: type) type { } if (!try self.hd1.init(self.allocator, self.bits[0..nlit]) or - !try self.hd2.init(self.allocator, self.bits[nlit .. nlit + ndist])) + !try self.hd2.init(self.allocator, self.bits[nlit..][0..ndist])) { corrupt_input_error_offset = self.roffset; self.err = InflateError.CorruptInput; diff --git a/lib/std/compress/deflate/huffman_bit_writer.zig b/lib/std/compress/deflate/huffman_bit_writer.zig index a42aae467b..0b76d9d89d 100644 --- a/lib/std/compress/deflate/huffman_bit_writer.zig +++ b/lib/std/compress/deflate/huffman_bit_writer.zig @@ -139,7 +139,7 @@ pub fn HuffmanBitWriter(comptime WriterType: type) type { self.bits >>= 48; self.nbits -= 48; var n = self.nbytes; - var bytes = self.bytes[n .. n + 6]; + var bytes = self.bytes[n..][0..6]; bytes[0] = @truncate(u8, bits); bytes[1] = @truncate(u8, bits >> 8); bytes[2] = @truncate(u8, bits >> 16); @@ -344,7 +344,7 @@ pub fn HuffmanBitWriter(comptime WriterType: type) type { self.bits >>= 48; self.nbits -= 48; var n = self.nbytes; - var bytes = self.bytes[n .. n + 6]; + var bytes = self.bytes[n..][0..6]; bytes[0] = @truncate(u8, bits); bytes[1] = @truncate(u8, bits >> 8); bytes[2] = @truncate(u8, bits >> 16); @@ -751,7 +751,7 @@ pub fn HuffmanBitWriter(comptime WriterType: type) type { var bits = self.bits; self.bits >>= 48; self.nbits -= 48; - var bytes = self.bytes[n .. n + 6]; + var bytes = self.bytes[n..][0..6]; bytes[0] = @truncate(u8, bits); bytes[1] = @truncate(u8, bits >> 8); bytes[2] = @truncate(u8, bits >> 16); diff --git a/lib/std/hash/crc.zig b/lib/std/hash/crc.zig index 271b4f93da..0ad154abef 100644 --- a/lib/std/hash/crc.zig +++ b/lib/std/hash/crc.zig @@ -160,7 +160,7 @@ pub fn Crc32WithPoly(comptime poly: Polynomial) type { pub fn update(self: *Self, input: []const u8) void { var i: usize = 0; while (i + 8 <= input.len) : (i += 8) { - const p = input[i .. i + 8]; + const p = input[i..][0..8]; // Unrolling this way gives ~50Mb/s increase self.crc ^= std.mem.readIntLittle(u32, p[0..4]); diff --git a/lib/std/hash/wyhash.zig b/lib/std/hash/wyhash.zig index 772395eab9..934c4f96ad 100644 --- a/lib/std/hash/wyhash.zig +++ b/lib/std/hash/wyhash.zig @@ -65,7 +65,7 @@ const WyhashStateless = struct { var off: usize = 0; while (off < b.len) : (off += 32) { - @call(.always_inline, self.round, .{b[off .. off + 32]}); + @call(.always_inline, self.round, .{b[off..][0..32]}); } self.msg_len += b.len; diff --git a/lib/std/json.zig b/lib/std/json.zig index af928bc564..011463faef 100644 --- a/lib/std/json.zig +++ b/lib/std/json.zig @@ -63,7 +63,7 @@ fn encodesTo(decoded: []const u8, encoded: []const u8) bool { var buf: [4]u8 = undefined; const len = std.unicode.utf8Encode(codepoint, &buf) catch unreachable; if (i + len > decoded.len) return false; - if (!mem.eql(u8, decoded[i .. i + len], buf[0..len])) return false; + if (!mem.eql(u8, decoded[i..][0..len], buf[0..len])) return false; i += len; } } @@ -2285,10 +2285,10 @@ pub fn encodeJsonStringChars(chars: []const u8, options: StringifyOptions, write const ulen = std.unicode.utf8ByteSequenceLength(chars[i]) catch unreachable; // control characters (only things left with 1 byte length) should always be printed as unicode escapes if (ulen == 1 or options.string.String.escape_unicode) { - const codepoint = std.unicode.utf8Decode(chars[i .. i + ulen]) catch unreachable; + const codepoint = std.unicode.utf8Decode(chars[i..][0..ulen]) catch unreachable; try outputUnicodeEscape(codepoint, writer); } else { - try writer.writeAll(chars[i .. i + ulen]); + try writer.writeAll(chars[i..][0..ulen]); } i += ulen - 1; }, diff --git a/lib/std/math/big/int.zig b/lib/std/math/big/int.zig index b01d9b04ff..5683d8681c 100644 --- a/lib/std/math/big/int.zig +++ b/lib/std/math/big/int.zig @@ -4035,7 +4035,7 @@ fn llsquareBasecase(r: []Limb, x: []const Limb) void { for (x_norm, 0..) |v, i| { // Compute and add the squares - const overflow = llmulLimb(.add, r[2 * i ..], x[i .. i + 1], v); + const overflow = llmulLimb(.add, r[2 * i ..], x[i..][0..1], v); assert(!overflow); } } diff --git a/lib/std/net.zig b/lib/std/net.zig index 15a9e01da8..57e50a7349 100644 --- a/lib/std/net.zig +++ b/lib/std/net.zig @@ -1701,7 +1701,7 @@ fn dnsParse( p += @as(usize, 1) + @boolToInt(p[0] != 0); const len = p[8] * @as(usize, 256) + p[9]; if (@ptrToInt(p) + len > @ptrToInt(r.ptr) + r.len) return error.InvalidDnsPacket; - try callback(ctx, p[1], p[10 .. 10 + len], r); + try callback(ctx, p[1], p[10..][0..len], r); p += 10 + len; } } diff --git a/lib/std/os/windows.zig b/lib/std/os/windows.zig index 22ffc850e6..6755e7adf2 100644 --- a/lib/std/os/windows.zig +++ b/lib/std/os/windows.zig @@ -835,14 +835,14 @@ pub fn ReadLink(dir: ?HANDLE, sub_path_w: []const u16, out_buffer: []u8) ReadLin const len = buf.SubstituteNameLength >> 1; const path_buf = @as([*]const u16, &buf.PathBuffer); const is_relative = buf.Flags & SYMLINK_FLAG_RELATIVE != 0; - return parseReadlinkPath(path_buf[offset .. offset + len], is_relative, out_buffer); + return parseReadlinkPath(path_buf[offset..][0..len], is_relative, out_buffer); }, IO_REPARSE_TAG_MOUNT_POINT => { const buf = @ptrCast(*const MOUNT_POINT_REPARSE_BUFFER, @alignCast(@alignOf(MOUNT_POINT_REPARSE_BUFFER), &reparse_struct.DataBuffer[0])); const offset = buf.SubstituteNameOffset >> 1; const len = buf.SubstituteNameLength >> 1; const path_buf = @as([*]const u16, &buf.PathBuffer); - return parseReadlinkPath(path_buf[offset .. offset + len], false, out_buffer); + return parseReadlinkPath(path_buf[offset..][0..len], false, out_buffer); }, else => |value| { std.debug.print("unsupported symlink type: {}", .{value}); diff --git a/lib/std/testing.zig b/lib/std/testing.zig index 37e15ff08b..2857ebdbd3 100644 --- a/lib/std/testing.zig +++ b/lib/std/testing.zig @@ -941,7 +941,7 @@ fn printIndicatorLine(source: []const u8, indicator_index: usize) void { fn printWithVisibleNewlines(source: []const u8) void { var i: usize = 0; while (std.mem.indexOfScalar(u8, source[i..], '\n')) |nl| : (i += nl + 1) { - printLine(source[i .. i + nl]); + printLine(source[i..][0..nl]); } print("{s}␃\n", .{source[i..]}); // End of Text symbol (ETX) } diff --git a/lib/std/unicode.zig b/lib/std/unicode.zig index 378b216ef3..9d334218c1 100644 --- a/lib/std/unicode.zig +++ b/lib/std/unicode.zig @@ -185,7 +185,7 @@ pub fn utf8CountCodepoints(s: []const u8) !usize { switch (n) { 1 => {}, // ASCII, no validation needed - else => _ = try utf8Decode(s[i .. i + n]), + else => _ = try utf8Decode(s[i..][0..n]), } i += n; diff --git a/src/link/Plan9/aout.zig b/src/link/Plan9/aout.zig index b39cae5166..d6fbb47d35 100644 --- a/src/link/Plan9/aout.zig +++ b/src/link/Plan9/aout.zig @@ -21,7 +21,7 @@ pub const ExecHdr = extern struct { var buf: [40]u8 = undefined; var i: u8 = 0; inline for (std.meta.fields(@This())) |f| { - std.mem.writeIntSliceBig(u32, buf[i .. i + 4], @field(self, f.name)); + std.mem.writeIntSliceBig(u32, buf[i..][0..4], @field(self, f.name)); i += 4; } return buf;