aboutsummaryrefslogtreecommitdiff
path: root/lib/std
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2019-12-02 00:03:41 -0500
committerGitHub <noreply@github.com>2019-12-02 00:03:41 -0500
commitfecd540826b14275784f10fe429ed147543377b6 (patch)
treecb2e096bd1b4ec17f7badc7ac73e706d66c99df1 /lib/std
parent4b6740e19d57454f3c4eac0c2e9a92ce08e7ec04 (diff)
parente7ee6647a16738d344173d0482028dc5578cc6c2 (diff)
downloadzig-fecd540826b14275784f10fe429ed147543377b6.tar.gz
zig-fecd540826b14275784f10fe429ed147543377b6.zip
Merge pull request #3787 from ziglang/remove-array-type-coercion
Remove array type coercion and fix result location bugs
Diffstat (limited to 'lib/std')
-rw-r--r--lib/std/array_list.zig15
-rw-r--r--lib/std/bloom_filter.zig6
-rw-r--r--lib/std/build.zig55
-rw-r--r--lib/std/child_process.zig6
-rw-r--r--lib/std/coff.zig6
-rw-r--r--lib/std/crypto/aes.zig4
-rw-r--r--lib/std/crypto/blake2.zig4
-rw-r--r--lib/std/crypto/chacha20.zig14
-rw-r--r--lib/std/crypto/gimli.zig8
-rw-r--r--lib/std/crypto/md5.zig2
-rw-r--r--lib/std/crypto/poly1305.zig2
-rw-r--r--lib/std/crypto/sha1.zig2
-rw-r--r--lib/std/crypto/sha2.zig4
-rw-r--r--lib/std/crypto/sha3.zig4
-rw-r--r--lib/std/crypto/test.zig4
-rw-r--r--lib/std/crypto/x25519.zig36
-rw-r--r--lib/std/debug.zig8
-rw-r--r--lib/std/elf.zig2
-rw-r--r--lib/std/event/fs.zig2
-rw-r--r--lib/std/event/loop.zig4
-rw-r--r--lib/std/fifo.zig10
-rw-r--r--lib/std/fmt.zig25
-rw-r--r--lib/std/fs.zig8
-rw-r--r--lib/std/fs/get_app_data_dir.zig6
-rw-r--r--lib/std/fs/path.zig122
-rw-r--r--lib/std/hash/cityhash.zig2
-rw-r--r--lib/std/hash/murmur.zig2
-rw-r--r--lib/std/hash_map.zig2
-rw-r--r--lib/std/http/headers.zig4
-rw-r--r--lib/std/io.zig2
-rw-r--r--lib/std/io/out_stream.zig10
-rw-r--r--lib/std/io/test.zig8
-rw-r--r--lib/std/mem.zig128
-rw-r--r--lib/std/meta/trait.zig2
-rw-r--r--lib/std/net.zig8
-rw-r--r--lib/std/os.zig6
-rw-r--r--lib/std/os/test.zig2
-rw-r--r--lib/std/os/windows.zig6
-rw-r--r--lib/std/packed_int_array.zig24
-rw-r--r--lib/std/pdb.zig4
-rw-r--r--lib/std/priority_queue.zig2
-rw-r--r--lib/std/process.zig16
-rw-r--r--lib/std/rand.zig2
-rw-r--r--lib/std/segmented_list.zig12
-rw-r--r--lib/std/sort.zig86
-rw-r--r--lib/std/unicode.zig12
-rw-r--r--lib/std/zig/tokenizer.zig122
47 files changed, 389 insertions, 432 deletions
diff --git a/lib/std/array_list.zig b/lib/std/array_list.zig
index 8db16b226e..c718972537 100644
--- a/lib/std/array_list.zig
+++ b/lib/std/array_list.zig
@@ -35,7 +35,7 @@ pub fn AlignedArrayList(comptime T: type, comptime alignment: ?u29) type {
/// Deinitialize with `deinit` or use `toOwnedSlice`.
pub fn init(allocator: *Allocator) Self {
return Self{
- .items = [_]T{},
+ .items = &[_]T{},
.len = 0,
.allocator = allocator,
};
@@ -323,18 +323,14 @@ test "std.ArrayList.basic" {
testing.expect(list.pop() == 10);
testing.expect(list.len == 9);
- list.appendSlice([_]i32{
- 1,
- 2,
- 3,
- }) catch unreachable;
+ list.appendSlice(&[_]i32{ 1, 2, 3 }) catch unreachable;
testing.expect(list.len == 12);
testing.expect(list.pop() == 3);
testing.expect(list.pop() == 2);
testing.expect(list.pop() == 1);
testing.expect(list.len == 9);
- list.appendSlice([_]i32{}) catch unreachable;
+ list.appendSlice(&[_]i32{}) catch unreachable;
testing.expect(list.len == 9);
// can only set on indices < self.len
@@ -481,10 +477,7 @@ test "std.ArrayList.insertSlice" {
try list.append(2);
try list.append(3);
try list.append(4);
- try list.insertSlice(1, [_]i32{
- 9,
- 8,
- });
+ try list.insertSlice(1, &[_]i32{ 9, 8 });
testing.expect(list.items[0] == 1);
testing.expect(list.items[1] == 9);
testing.expect(list.items[2] == 8);
diff --git a/lib/std/bloom_filter.zig b/lib/std/bloom_filter.zig
index 6c4d713076..f12f0d86af 100644
--- a/lib/std/bloom_filter.zig
+++ b/lib/std/bloom_filter.zig
@@ -62,7 +62,7 @@ pub fn BloomFilter(
}
pub fn getCell(self: Self, cell: Index) Cell {
- return Io.get(self.data, cell, 0);
+ return Io.get(&self.data, cell, 0);
}
pub fn incrementCell(self: *Self, cell: Index) void {
@@ -70,7 +70,7 @@ pub fn BloomFilter(
// skip the 'get' operation
Io.set(&self.data, cell, 0, cellMax);
} else {
- const old = Io.get(self.data, cell, 0);
+ const old = Io.get(&self.data, cell, 0);
if (old != cellMax) {
Io.set(&self.data, cell, 0, old + 1);
}
@@ -120,7 +120,7 @@ pub fn BloomFilter(
} else if (newsize > n_items) {
var copied: usize = 0;
while (copied < r.data.len) : (copied += self.data.len) {
- std.mem.copy(u8, r.data[copied .. copied + self.data.len], self.data);
+ std.mem.copy(u8, r.data[copied .. copied + self.data.len], &self.data);
}
}
return r;
diff --git a/lib/std/build.zig b/lib/std/build.zig
index 026e889b7b..bfde2f52d7 100644
--- a/lib/std/build.zig
+++ b/lib/std/build.zig
@@ -186,7 +186,7 @@ pub const Builder = struct {
pub fn resolveInstallPrefix(self: *Builder) void {
if (self.dest_dir) |dest_dir| {
const install_prefix = self.install_prefix orelse "/usr";
- self.install_path = fs.path.join(self.allocator, [_][]const u8{ dest_dir, install_prefix }) catch unreachable;
+ self.install_path = fs.path.join(self.allocator, &[_][]const u8{ dest_dir, install_prefix }) catch unreachable;
} else {
const install_prefix = self.install_prefix orelse blk: {
const p = self.cache_root;
@@ -195,8 +195,8 @@ pub const Builder = struct {
};
self.install_path = install_prefix;
}
- self.lib_dir = fs.path.join(self.allocator, [_][]const u8{ self.install_path, "lib" }) catch unreachable;
- self.exe_dir = fs.path.join(self.allocator, [_][]const u8{ self.install_path, "bin" }) catch unreachable;
+ self.lib_dir = fs.path.join(self.allocator, &[_][]const u8{ self.install_path, "lib" }) catch unreachable;
+ self.exe_dir = fs.path.join(self.allocator, &[_][]const u8{ self.install_path, "bin" }) catch unreachable;
}
pub fn addExecutable(self: *Builder, name: []const u8, root_src: ?[]const u8) *LibExeObjStep {
@@ -803,7 +803,7 @@ pub const Builder = struct {
}
fn pathFromRoot(self: *Builder, rel_path: []const u8) []u8 {
- return fs.path.resolve(self.allocator, [_][]const u8{ self.build_root, rel_path }) catch unreachable;
+ return fs.path.resolve(self.allocator, &[_][]const u8{ self.build_root, rel_path }) catch unreachable;
}
pub fn fmt(self: *Builder, comptime format: []const u8, args: ...) []u8 {
@@ -818,7 +818,7 @@ pub const Builder = struct {
if (fs.path.isAbsolute(name)) {
return name;
}
- const full_path = try fs.path.join(self.allocator, [_][]const u8{ search_prefix, "bin", self.fmt("{}{}", name, exe_extension) });
+ const full_path = try fs.path.join(self.allocator, &[_][]const u8{ search_prefix, "bin", self.fmt("{}{}", name, exe_extension) });
return fs.realpathAlloc(self.allocator, full_path) catch continue;
}
}
@@ -827,9 +827,9 @@ pub const Builder = struct {
if (fs.path.isAbsolute(name)) {
return name;
}
- var it = mem.tokenize(PATH, [_]u8{fs.path.delimiter});
+ var it = mem.tokenize(PATH, &[_]u8{fs.path.delimiter});
while (it.next()) |path| {
- const full_path = try fs.path.join(self.allocator, [_][]const u8{ path, self.fmt("{}{}", name, exe_extension) });
+ const full_path = try fs.path.join(self.allocator, &[_][]const u8{ path, self.fmt("{}{}", name, exe_extension) });
return fs.realpathAlloc(self.allocator, full_path) catch continue;
}
}
@@ -839,7 +839,7 @@ pub const Builder = struct {
return name;
}
for (paths) |path| {
- const full_path = try fs.path.join(self.allocator, [_][]const u8{ path, self.fmt("{}{}", name, exe_extension) });
+ const full_path = try fs.path.join(self.allocator, &[_][]const u8{ path, self.fmt("{}{}", name, exe_extension) });
return fs.realpathAlloc(self.allocator, full_path) catch continue;
}
}
@@ -926,12 +926,12 @@ pub const Builder = struct {
};
return fs.path.resolve(
self.allocator,
- [_][]const u8{ base_dir, dest_rel_path },
+ &[_][]const u8{ base_dir, dest_rel_path },
) catch unreachable;
}
fn execPkgConfigList(self: *Builder, out_code: *u8) ![]const PkgConfigPkg {
- const stdout = try self.execAllowFail([_][]const u8{ "pkg-config", "--list-all" }, out_code, .Ignore);
+ const stdout = try self.execAllowFail(&[_][]const u8{ "pkg-config", "--list-all" }, out_code, .Ignore);
var list = ArrayList(PkgConfigPkg).init(self.allocator);
var line_it = mem.tokenize(stdout, "\r\n");
while (line_it.next()) |line| {
@@ -970,7 +970,7 @@ pub const Builder = struct {
test "builder.findProgram compiles" {
const builder = try Builder.create(std.heap.page_allocator, "zig", "zig-cache", "zig-cache");
- _ = builder.findProgram([_][]const u8{}, [_][]const u8{}) catch null;
+ _ = builder.findProgram(&[_][]const u8{}, &[_][]const u8{}) catch null;
}
/// Deprecated. Use `builtin.Version`.
@@ -1384,7 +1384,7 @@ pub const LibExeObjStep = struct {
};
var code: u8 = undefined;
- const stdout = if (self.builder.execAllowFail([_][]const u8{
+ const stdout = if (self.builder.execAllowFail(&[_][]const u8{
"pkg-config",
pkg_name,
"--cflags",
@@ -1504,7 +1504,7 @@ pub const LibExeObjStep = struct {
pub fn getOutputPath(self: *LibExeObjStep) []const u8 {
return fs.path.join(
self.builder.allocator,
- [_][]const u8{ self.output_dir.?, self.out_filename },
+ &[_][]const u8{ self.output_dir.?, self.out_filename },
) catch unreachable;
}
@@ -1514,7 +1514,7 @@ pub const LibExeObjStep = struct {
assert(self.kind == Kind.Lib);
return fs.path.join(
self.builder.allocator,
- [_][]const u8{ self.output_dir.?, self.out_lib_filename },
+ &[_][]const u8{ self.output_dir.?, self.out_lib_filename },
) catch unreachable;
}
@@ -1525,7 +1525,7 @@ pub const LibExeObjStep = struct {
assert(!self.disable_gen_h);
return fs.path.join(
self.builder.allocator,
- [_][]const u8{ self.output_dir.?, self.out_h_filename },
+ &[_][]const u8{ self.output_dir.?, self.out_h_filename },
) catch unreachable;
}
@@ -1535,7 +1535,7 @@ pub const LibExeObjStep = struct {
assert(self.target.isWindows() or self.target.isUefi());
return fs.path.join(
self.builder.allocator,
- [_][]const u8{ self.output_dir.?, self.out_pdb_filename },
+ &[_][]const u8{ self.output_dir.?, self.out_pdb_filename },
) catch unreachable;
}
@@ -1605,14 +1605,14 @@ pub const LibExeObjStep = struct {
const triplet = try Target.vcpkgTriplet(allocator, self.target, linkage);
defer self.builder.allocator.free(triplet);
- const include_path = try fs.path.join(allocator, [_][]const u8{ root, "installed", triplet, "include" });
+ const include_path = try fs.path.join(allocator, &[_][]const u8{ root, "installed", triplet, "include" });
errdefer allocator.free(include_path);
try self.include_dirs.append(IncludeDir{ .RawPath = include_path });
- const lib_path = try fs.path.join(allocator, [_][]const u8{ root, "installed", triplet, "lib" });
+ const lib_path = try fs.path.join(allocator, &[_][]const u8{ root, "installed", triplet, "lib" });
try self.lib_paths.append(lib_path);
- self.vcpkg_bin_path = try fs.path.join(allocator, [_][]const u8{ root, "installed", triplet, "bin" });
+ self.vcpkg_bin_path = try fs.path.join(allocator, &[_][]const u8{ root, "installed", triplet, "bin" });
},
}
}
@@ -1725,7 +1725,7 @@ pub const LibExeObjStep = struct {
if (self.build_options_contents.len() > 0) {
const build_options_file = try fs.path.join(
builder.allocator,
- [_][]const u8{ builder.cache_root, builder.fmt("{}_build_options.zig", self.name) },
+ &[_][]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 zig_args.append("--pkg-begin");
@@ -1849,7 +1849,7 @@ pub const LibExeObjStep = struct {
try zig_args.append("--test-cmd");
try zig_args.append(bin_name);
if (glibc_dir_arg) |dir| {
- const full_dir = try fs.path.join(builder.allocator, [_][]const u8{
+ const full_dir = try fs.path.join(builder.allocator, &[_][]const u8{
dir,
try self.target.linuxTriple(builder.allocator),
});
@@ -1994,7 +1994,7 @@ pub const LibExeObjStep = struct {
const output_path = mem.trimRight(u8, output_path_nl, "\r\n");
if (self.output_dir) |output_dir| {
- const full_dest = try fs.path.join(builder.allocator, [_][]const u8{
+ const full_dest = try fs.path.join(builder.allocator, &[_][]const u8{
output_dir,
fs.path.basename(output_path),
});
@@ -2176,6 +2176,9 @@ const InstallArtifactStep = struct {
if (self.artifact.isDynamicLibrary()) {
builder.pushInstalledFile(.Lib, artifact.major_only_filename);
builder.pushInstalledFile(.Lib, artifact.name_only_filename);
+ if (self.artifact.target.isWindows()) {
+ builder.pushInstalledFile(.Lib, artifact.out_lib_filename);
+ }
}
if (self.pdb_dir) |pdb_dir| {
builder.pushInstalledFile(pdb_dir, artifact.out_pdb_filename);
@@ -2268,7 +2271,7 @@ pub const InstallDirStep = struct {
};
const rel_path = entry.path[full_src_dir.len + 1 ..];
- const dest_path = try fs.path.join(self.builder.allocator, [_][]const u8{ dest_prefix, rel_path });
+ const dest_path = try fs.path.join(self.builder.allocator, &[_][]const u8{ dest_prefix, rel_path });
switch (entry.kind) {
.Directory => try fs.makePath(self.builder.allocator, dest_path),
.File => try self.builder.updateFile(entry.path, dest_path),
@@ -2391,7 +2394,7 @@ fn doAtomicSymLinks(allocator: *Allocator, output_path: []const u8, filename_maj
// sym link for libfoo.so.1 to libfoo.so.1.2.3
const major_only_path = fs.path.join(
allocator,
- [_][]const u8{ out_dir, filename_major_only },
+ &[_][]const u8{ out_dir, filename_major_only },
) catch unreachable;
fs.atomicSymLink(allocator, out_basename, major_only_path) catch |err| {
warn("Unable to symlink {} -> {}\n", major_only_path, out_basename);
@@ -2400,7 +2403,7 @@ fn doAtomicSymLinks(allocator: *Allocator, output_path: []const u8, filename_maj
// sym link for libfoo.so to libfoo.so.1
const name_only_path = fs.path.join(
allocator,
- [_][]const u8{ out_dir, filename_name_only },
+ &[_][]const u8{ out_dir, filename_name_only },
) catch unreachable;
fs.atomicSymLink(allocator, filename_major_only, name_only_path) catch |err| {
warn("Unable to symlink {} -> {}\n", name_only_path, filename_major_only);
@@ -2413,7 +2416,7 @@ fn findVcpkgRoot(allocator: *Allocator) !?[]const u8 {
const appdata_path = try fs.getAppDataDir(allocator, "vcpkg");
defer allocator.free(appdata_path);
- const path_file = try fs.path.join(allocator, [_][]const u8{ appdata_path, "vcpkg.path.txt" });
+ const path_file = try fs.path.join(allocator, &[_][]const u8{ appdata_path, "vcpkg.path.txt" });
defer allocator.free(path_file);
const file = fs.cwd().openFile(path_file, .{}) catch return null;
diff --git a/lib/std/child_process.zig b/lib/std/child_process.zig
index 36621758b2..be616196b1 100644
--- a/lib/std/child_process.zig
+++ b/lib/std/child_process.zig
@@ -571,7 +571,7 @@ pub const ChildProcess = struct {
// to match posix semantics
const app_name = x: {
if (self.cwd) |cwd| {
- const resolved = try fs.path.resolve(self.allocator, [_][]const u8{ cwd, self.argv[0] });
+ const resolved = try fs.path.resolve(self.allocator, &[_][]const u8{ cwd, self.argv[0] });
defer self.allocator.free(resolved);
break :x try cstr.addNullByte(self.allocator, resolved);
} else {
@@ -613,10 +613,10 @@ pub const ChildProcess = struct {
retry: while (it.next()) |search_path| {
var ext_it = mem.tokenize(PATHEXT, ";");
while (ext_it.next()) |app_ext| {
- const app_basename = try mem.concat(self.allocator, u8, [_][]const u8{ app_name[0 .. app_name.len - 1], app_ext });
+ const app_basename = try mem.concat(self.allocator, u8, &[_][]const u8{ app_name[0 .. app_name.len - 1], app_ext });
defer self.allocator.free(app_basename);
- const joined_path = try fs.path.join(self.allocator, [_][]const u8{ search_path, app_basename });
+ const joined_path = try fs.path.join(self.allocator, &[_][]const u8{ search_path, app_basename });
defer self.allocator.free(joined_path);
const joined_path_w = try unicode.utf8ToUtf16LeWithNull(self.allocator, joined_path);
diff --git a/lib/std/coff.zig b/lib/std/coff.zig
index c6d7660f8b..b1be21c4d3 100644
--- a/lib/std/coff.zig
+++ b/lib/std/coff.zig
@@ -61,7 +61,7 @@ pub const Coff = struct {
var magic: [2]u8 = undefined;
try in.readNoEof(magic[0..]);
- if (!mem.eql(u8, magic, "MZ"))
+ if (!mem.eql(u8, &magic, "MZ"))
return error.InvalidPEMagic;
// Seek to PE File Header (coff header)
@@ -71,7 +71,7 @@ pub const Coff = struct {
var pe_header_magic: [4]u8 = undefined;
try in.readNoEof(pe_header_magic[0..]);
- if (!mem.eql(u8, pe_header_magic, [_]u8{ 'P', 'E', 0, 0 }))
+ if (!mem.eql(u8, &pe_header_magic, &[_]u8{ 'P', 'E', 0, 0 }))
return error.InvalidPEHeader;
self.coff_header = CoffHeader{
@@ -163,7 +163,7 @@ pub const Coff = struct {
var cv_signature: [4]u8 = undefined; // CodeView signature
try in.readNoEof(cv_signature[0..]);
// 'RSDS' indicates PDB70 format, used by lld.
- if (!mem.eql(u8, cv_signature, "RSDS"))
+ if (!mem.eql(u8, &cv_signature, "RSDS"))
return error.InvalidPEMagic;
try in.readNoEof(self.guid[0..]);
self.age = try in.readIntLittle(u32);
diff --git a/lib/std/crypto/aes.zig b/lib/std/crypto/aes.zig
index ddccd0b1b3..1cc166f943 100644
--- a/lib/std/crypto/aes.zig
+++ b/lib/std/crypto/aes.zig
@@ -136,7 +136,7 @@ fn AES(comptime keysize: usize) type {
pub fn init(key: [keysize / 8]u8) Self {
var ctx: Self = undefined;
- expandKey(key, ctx.enc[0..], ctx.dec[0..]);
+ expandKey(&key, ctx.enc[0..], ctx.dec[0..]);
return ctx;
}
@@ -157,7 +157,7 @@ fn AES(comptime keysize: usize) type {
var ctr_i = std.mem.readIntSliceBig(u128, ctrbuf[0..]);
std.mem.writeIntSliceBig(u128, ctrbuf[0..], ctr_i +% 1);
- n += xorBytes(dst[n..], src[n..], keystream);
+ n += xorBytes(dst[n..], src[n..], &keystream);
}
}
};
diff --git a/lib/std/crypto/blake2.zig b/lib/std/crypto/blake2.zig
index d6b1e49724..aa866acbe4 100644
--- a/lib/std/crypto/blake2.zig
+++ b/lib/std/crypto/blake2.zig
@@ -256,7 +256,7 @@ test "blake2s256 aligned final" {
var out: [Blake2s256.digest_length]u8 = undefined;
var h = Blake2s256.init();
- h.update(block);
+ h.update(&block);
h.final(out[0..]);
}
@@ -490,6 +490,6 @@ test "blake2b512 aligned final" {
var out: [Blake2b512.digest_length]u8 = undefined;
var h = Blake2b512.init();
- h.update(block);
+ h.update(&block);
h.final(out[0..]);
}
diff --git a/lib/std/crypto/chacha20.zig b/lib/std/crypto/chacha20.zig
index d5d03f2bfa..10d2130659 100644
--- a/lib/std/crypto/chacha20.zig
+++ b/lib/std/crypto/chacha20.zig
@@ -218,12 +218,12 @@ test "crypto.chacha20 test vector sunscreen" {
};
chaCha20IETF(result[0..], input[0..], 1, key, nonce);
- testing.expectEqualSlices(u8, expected_result, result);
+ testing.expectEqualSlices(u8, &expected_result, &result);
// Chacha20 is self-reversing.
var plaintext: [114]u8 = undefined;
chaCha20IETF(plaintext[0..], result[0..], 1, key, nonce);
- testing.expect(mem.compare(u8, input, plaintext) == mem.Compare.Equal);
+ testing.expect(mem.compare(u8, input, &plaintext) == mem.Compare.Equal);
}
// https://tools.ietf.org/html/draft-agl-tls-chacha20poly1305-04#section-7
@@ -258,7 +258,7 @@ test "crypto.chacha20 test vector 1" {
const nonce = [_]u8{ 0, 0, 0, 0, 0, 0, 0, 0 };
chaCha20With64BitNonce(result[0..], input[0..], 0, key, nonce);
- testing.expectEqualSlices(u8, expected_result, result);
+ testing.expectEqualSlices(u8, &expected_result, &result);
}
test "crypto.chacha20 test vector 2" {
@@ -292,7 +292,7 @@ test "crypto.chacha20 test vector 2" {
const nonce = [_]u8{ 0, 0, 0, 0, 0, 0, 0, 0 };
chaCha20With64BitNonce(result[0..], input[0..], 0, key, nonce);
- testing.expectEqualSlices(u8, expected_result, result);
+ testing.expectEqualSlices(u8, &expected_result, &result);
}
test "crypto.chacha20 test vector 3" {
@@ -326,7 +326,7 @@ test "crypto.chacha20 test vector 3" {
const nonce = [_]u8{ 0, 0, 0, 0, 0, 0, 0, 1 };
chaCha20With64BitNonce(result[0..], input[0..], 0, key, nonce);
- testing.expectEqualSlices(u8, expected_result, result);
+ testing.expectEqualSlices(u8, &expected_result, &result);
}
test "crypto.chacha20 test vector 4" {
@@ -360,7 +360,7 @@ test "crypto.chacha20 test vector 4" {
const nonce = [_]u8{ 1, 0, 0, 0, 0, 0, 0, 0 };
chaCha20With64BitNonce(result[0..], input[0..], 0, key, nonce);
- testing.expectEqualSlices(u8, expected_result, result);
+ testing.expectEqualSlices(u8, &expected_result, &result);
}
test "crypto.chacha20 test vector 5" {
@@ -432,5 +432,5 @@ test "crypto.chacha20 test vector 5" {
};
chaCha20With64BitNonce(result[0..], input[0..], 0, key, nonce);
- testing.expectEqualSlices(u8, expected_result, result);
+ testing.expectEqualSlices(u8, &expected_result, &result);
}
diff --git a/lib/std/crypto/gimli.zig b/lib/std/crypto/gimli.zig
index 0d18afd705..1d835b231b 100644
--- a/lib/std/crypto/gimli.zig
+++ b/lib/std/crypto/gimli.zig
@@ -83,7 +83,7 @@ test "permute" {
while (i < 12) : (i += 1) {
input[i] = i * i * i + i *% 0x9e3779b9;
}
- testing.expectEqualSlices(u32, input, [_]u32{
+ testing.expectEqualSlices(u32, &input, &[_]u32{
0x00000000, 0x9e3779ba, 0x3c6ef37a, 0xdaa66d46,
0x78dde724, 0x1715611a, 0xb54cdb2e, 0x53845566,
0xf1bbcfc8, 0x8ff34a5a, 0x2e2ac522, 0xcc624026,
@@ -92,7 +92,7 @@ test "permute" {
},
};
state.permute();
- testing.expectEqualSlices(u32, state.data, [_]u32{
+ testing.expectEqualSlices(u32, &state.data, &[_]u32{
0xba11c85a, 0x91bad119, 0x380ce880, 0xd24c2c68,
0x3eceffea, 0x277a921c, 0x4f73a0bd, 0xda5a9cd8,
0x84b673f0, 0x34e52ff7, 0x9e2bef49, 0xf41bb8d6,
@@ -163,6 +163,6 @@ test "hash" {
var msg: [58 / 2]u8 = undefined;
try std.fmt.hexToBytes(&msg, "000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C");
var md: [32]u8 = undefined;
- hash(&md, msg);
- htest.assertEqual("1C9A03DC6A5DDC5444CFC6F4B154CFF5CF081633B2CEA4D7D0AE7CCFED5AAA44", md);
+ hash(&md, &msg);
+ htest.assertEqual("1C9A03DC6A5DDC5444CFC6F4B154CFF5CF081633B2CEA4D7D0AE7CCFED5AAA44", &md);
}
diff --git a/lib/std/crypto/md5.zig b/lib/std/crypto/md5.zig
index db6150699d..41ce802dd7 100644
--- a/lib/std/crypto/md5.zig
+++ b/lib/std/crypto/md5.zig
@@ -276,6 +276,6 @@ test "md5 aligned final" {
var out: [Md5.digest_length]u8 = undefined;
var h = Md5.init();
- h.update(block);
+ h.update(&block);
h.final(out[0..]);
}
diff --git a/lib/std/crypto/poly1305.zig b/lib/std/crypto/poly1305.zig
index 78881ba049..2395b1c7aa 100644
--- a/lib/std/crypto/poly1305.zig
+++ b/lib/std/crypto/poly1305.zig
@@ -230,5 +230,5 @@ test "poly1305 rfc7439 vector1" {
var mac: [16]u8 = undefined;
Poly1305.create(mac[0..], msg, key);
- std.testing.expectEqualSlices(u8, expected_mac, mac);
+ std.testing.expectEqualSlices(u8, expected_mac, &mac);
}
diff --git a/lib/std/crypto/sha1.zig b/lib/std/crypto/sha1.zig
index c17ef2daf7..b4d6e5c0cc 100644
--- a/lib/std/crypto/sha1.zig
+++ b/lib/std/crypto/sha1.zig
@@ -297,6 +297,6 @@ test "sha1 aligned final" {
var out: [Sha1.digest_length]u8 = undefined;
var h = Sha1.init();
- h.update(block);
+ h.update(&block);
h.final(out[0..]);
}
diff --git a/lib/std/crypto/sha2.zig b/lib/std/crypto/sha2.zig
index 77698176bd..478cadd03c 100644
--- a/lib/std/crypto/sha2.zig
+++ b/lib/std/crypto/sha2.zig
@@ -343,7 +343,7 @@ test "sha256 aligned final" {
var out: [Sha256.digest_length]u8 = undefined;
var h = Sha256.init();
- h.update(block);
+ h.update(&block);
h.final(out[0..]);
}
@@ -723,6 +723,6 @@ test "sha512 aligned final" {
var out: [Sha512.digest_length]u8 = undefined;
var h = Sha512.init();
- h.update(block);
+ h.update(&block);
h.final(out[0..]);
}
diff --git a/lib/std/crypto/sha3.zig b/lib/std/crypto/sha3.zig
index d417ef07e2..d7b2fbe256 100644
--- a/lib/std/crypto/sha3.zig
+++ b/lib/std/crypto/sha3.zig
@@ -229,7 +229,7 @@ test "sha3-256 aligned final" {
var out: [Sha3_256.digest_length]u8 = undefined;
var h = Sha3_256.init();
- h.update(block);
+ h.update(&block);
h.final(out[0..]);
}
@@ -300,6 +300,6 @@ test "sha3-512 aligned final" {
var out: [Sha3_512.digest_length]u8 = undefined;
var h = Sha3_512.init();
- h.update(block);
+ h.update(&block);
h.final(out[0..]);
}
diff --git a/lib/std/crypto/test.zig b/lib/std/crypto/test.zig
index a0ddad6c83..1ff326cf39 100644
--- a/lib/std/crypto/test.zig
+++ b/lib/std/crypto/test.zig
@@ -8,7 +8,7 @@ pub fn assertEqualHash(comptime Hasher: var, comptime expected: []const u8, inpu
var h: [expected.len / 2]u8 = undefined;
Hasher.hash(input, h[0..]);
- assertEqual(expected, h);
+ assertEqual(expected, &h);
}
// Assert `expected` == `input` where `input` is a bytestring.
@@ -18,5 +18,5 @@ pub fn assertEqual(comptime expected: []const u8, input: []const u8) void {
r.* = fmt.parseInt(u8, expected[2 * i .. 2 * i + 2], 16) catch unreachable;
}
- testing.expectEqualSlices(u8, expected_bytes, input);
+ testing.expectEqualSlices(u8, &expected_bytes, input);
}
diff --git a/lib/std/crypto/x25519.zig b/lib/std/crypto/x25519.zig
index 73e0f033f2..16e3f073f8 100644
--- a/lib/std/crypto/x25519.zig
+++ b/lib/std/crypto/x25519.zig
@@ -63,7 +63,7 @@ pub const X25519 = struct {
var pos: isize = 254;
while (pos >= 0) : (pos -= 1) {
// constant time conditional swap before ladder step
- const b = scalarBit(e, @intCast(usize, pos));
+ const b = scalarBit(&e, @intCast(usize, pos));
swap ^= b; // xor trick avoids swapping at the end of the loop
Fe.cswap(x2, x3, swap);
Fe.cswap(z2, z3, swap);
@@ -117,7 +117,7 @@ pub const X25519 = struct {
pub fn createPublicKey(public_key: []u8, private_key: []const u8) bool {
var base_point = [_]u8{9} ++ [_]u8{0} ** 31;
- return create(public_key, private_key, base_point);
+ return create(public_key, private_key, &base_point);
}
};
@@ -581,8 +581,8 @@ test "x25519 public key calculation from secret key" {
var pk_calculated: [32]u8 = undefined;
try fmt.hexToBytes(sk[0..], "8052030376d47112be7f73ed7a019293dd12ad910b654455798b4667d73de166");
try fmt.hexToBytes(pk_expected[0..], "f1814f0e8ff1043d8a44d25babff3cedcae6c22c3edaa48f857ae70de2baae50");
- std.testing.expect(X25519.createPublicKey(pk_calculated[0..], sk));
- std.testing.expect(std.mem.eql(u8, pk_calculated, pk_expected));
+ std.testing.expect(X25519.createPublicKey(pk_calculated[0..], &sk));
+ std.testing.expect(std.mem.eql(u8, &pk_calculated, &pk_expected));
}
test "x25519 rfc7748 vector1" {
@@ -594,7 +594,7 @@ test "x25519 rfc7748 vector1" {
var output: [32]u8 = undefined;
std.testing.expect(X25519.create(output[0..], secret_key, public_key));
- std.testing.expect(std.mem.eql(u8, output, expected_output));
+ std.testing.expect(std.mem.eql(u8, &output, expected_output));
}
test "x25519 rfc7748 vector2" {
@@ -606,12 +606,12 @@ test "x25519 rfc7748 vector2" {
var output: [32]u8 = undefined;
std.testing.expect(X25519.create(output[0..], secret_key, public_key));
- std.testing.expect(std.mem.eql(u8, output, expected_output));
+ std.testing.expect(std.mem.eql(u8, &output, expected_output));
}
test "x25519 rfc7748 one iteration" {
const initial_value = "\x09\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00".*;
- const expected_output = "\x42\x2c\x8e\x7a\x62\x27\xd7\xbc\xa1\x35\x0b\x3e\x2b\xb7\x27\x9f\x78\x97\xb8\x7b\xb6\x85\x4b\x78\x3c\x60\xe8\x03\x11\xae\x30\x79".*;
+ const expected_output = "\x42\x2c\x8e\x7a\x62\x27\xd7\xbc\xa1\x35\x0b\x3e\x2b\xb7\x27\x9f\x78\x97\xb8\x7b\xb6\x85\x4b\x78\x3c\x60\xe8\x03\x11\xae\x30\x79";
var k: [32]u8 = initial_value;
var u: [32]u8 = initial_value;
@@ -619,7 +619,7 @@ test "x25519 rfc7748 one iteration" {
var i: usize = 0;
while (i < 1) : (i += 1) {
var output: [32]u8 = undefined;
- std.testing.expect(X25519.create(output[0..], k, u));
+ std.testing.expect(X25519.create(output[0..], &k, &u));
std.mem.copy(u8, u[0..], k[0..]);
std.mem.copy(u8, k[0..], output[0..]);
@@ -634,16 +634,16 @@ test "x25519 rfc7748 1,000 iterations" {
return error.SkipZigTest;
}
- const initial_value = "\x09\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00".*;
- const expected_output = "\x68\x4c\xf5\x9b\xa8\x33\x09\x55\x28\x00\xef\x56\x6f\x2f\x4d\x3c\x1c\x38\x87\xc4\x93\x60\xe3\x87\x5f\x2e\xb9\x4d\x99\x53\x2c\x51".*;
+ const initial_value = "\x09\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00";
+ const expected_output = "\x68\x4c\xf5\x9b\xa8\x33\x09\x55\x28\x00\xef\x56\x6f\x2f\x4d\x3c\x1c\x38\x87\xc4\x93\x60\xe3\x87\x5f\x2e\xb9\x4d\x99\x53\x2c\x51";
- var k: [32]u8 = initial_value;
- var u: [32]u8 = initial_value;
+ var k: [32]u8 = initial_value.*;
+ var u: [32]u8 = initial_value.*;
var i: usize = 0;
while (i < 1000) : (i += 1) {
var output: [32]u8 = undefined;
- std.testing.expect(X25519.create(output[0..], k, u));
+ std.testing.expect(X25519.create(output[0..], &k, &u));
std.mem.copy(u8, u[0..], k[0..]);
std.mem.copy(u8, k[0..], output[0..]);
@@ -657,16 +657,16 @@ test "x25519 rfc7748 1,000,000 iterations" {
return error.SkipZigTest;
}
- const initial_value = "\x09\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00".*;
- const expected_output = "\x7c\x39\x11\xe0\xab\x25\x86\xfd\x86\x44\x97\x29\x7e\x57\x5e\x6f\x3b\xc6\x01\xc0\x88\x3c\x30\xdf\x5f\x4d\xd2\xd2\x4f\x66\x54\x24".*;
+ const initial_value = "\x09\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00";
+ const expected_output = "\x7c\x39\x11\xe0\xab\x25\x86\xfd\x86\x44\x97\x29\x7e\x57\x5e\x6f\x3b\xc6\x01\xc0\x88\x3c\x30\xdf\x5f\x4d\xd2\xd2\x4f\x66\x54\x24";
- var k: [32]u8 = initial_value;
- var u: [32]u8 = initial_value;
+ var k: [32]u8 = initial_value.*;
+ var u: [32]u8 = initial_value.*;
var i: usize = 0;
while (i < 1000000) : (i += 1) {
var output: [32]u8 = undefined;
- std.testing.expect(X25519.create(output[0..], k, u));
+ std.testing.expect(X25519.create(output[0..], &k, &u));
std.mem.copy(u8, u[0..], k[0..]);
std.mem.copy(u8, k[0..], output[0..]);
diff --git a/lib/std/debug.zig b/lib/std/debug.zig
index c822cf57df..711f728fa6 100644
--- a/lib/std/debug.zig
+++ b/lib/std/debug.zig
@@ -825,7 +825,7 @@ fn openSelfDebugInfoWindows(allocator: *mem.Allocator) !DebugInfo {
const len = try di.coff.getPdbPath(path_buf[0..]);
const raw_path = path_buf[0..len];
- const path = try fs.path.resolve(allocator, [_][]const u8{raw_path});
+ const path = try fs.path.resolve(allocator, &[_][]const u8{raw_path});
try di.pdb.openFile(di.coff, path);
@@ -834,10 +834,10 @@ fn openSelfDebugInfoWindows(allocator: *mem.Allocator) !DebugInfo {
const signature = try pdb_stream.stream.readIntLittle(u32);
const age = try pdb_stream.stream.readIntLittle(u32);
var guid: [16]u8 = undefined;
- try pdb_stream.stream.readNoEof(guid[0..]);
+ try pdb_stream.stream.readNoEof(&guid);
if (version != 20000404) // VC70, only value observed by LLVM team
return error.UnknownPDBVersion;
- if (!mem.eql(u8, di.coff.guid, guid) or di.coff.age != age)
+ if (!mem.eql(u8, &di.coff.guid, &guid) or di.coff.age != age)
return error.PDBMismatch;
// We validated the executable and pdb match.
@@ -1916,7 +1916,7 @@ const LineNumberProgram = struct {
return error.InvalidDebugInfo;
} else
self.include_dirs[file_entry.dir_index];
- const file_name = try fs.path.join(self.file_entries.allocator, [_][]const u8{ dir_name, file_entry.file_name });
+ const file_name = try fs.path.join(self.file_entries.allocator, &[_][]const u8{ dir_name, file_entry.file_name });
errdefer self.file_entries.allocator.free(file_name);
return LineInfo{
.line = if (self.prev_line >= 0) @intCast(u64, self.prev_line) else 0,
diff --git a/lib/std/elf.zig b/lib/std/elf.zig
index c6a4c0cc0b..dc1638c5cb 100644
--- a/lib/std/elf.zig
+++ b/lib/std/elf.zig
@@ -381,7 +381,7 @@ pub const Elf = struct {
var magic: [4]u8 = undefined;
try in.readNoEof(magic[0..]);
- if (!mem.eql(u8, magic, "\x7fELF")) return error.InvalidFormat;
+ if (!mem.eql(u8, &magic, "\x7fELF")) return error.InvalidFormat;
elf.is_64 = switch (try in.readByte()) {
1 => false,
diff --git a/lib/std/event/fs.zig b/lib/std/event/fs.zig
index 346d0f294a..5986f07ad3 100644
--- a/lib/std/event/fs.zig
+++ b/lib/std/event/fs.zig
@@ -695,7 +695,7 @@ pub fn readFile(allocator: *Allocator, file_path: []const u8, max_size: usize) !
try list.ensureCapacity(list.len + mem.page_size);
const buf = list.items[list.len..];
const buf_array = [_][]u8{buf};
- const amt = try preadv(allocator, fd, buf_array, list.len);
+ const amt = try preadv(allocator, fd, &buf_array, list.len);
list.len += amt;
if (list.len > max_size) {
return error.FileTooBig;
diff --git a/lib/std/event/loop.zig b/lib/std/event/loop.zig
index f47663a511..03478f65d5 100644
--- a/lib/std/event/loop.zig
+++ b/lib/std/event/loop.zig
@@ -237,7 +237,7 @@ pub const Loop = struct {
var extra_thread_index: usize = 0;
errdefer {
// writing 8 bytes to an eventfd cannot fail
- os.write(self.os_data.final_eventfd, wakeup_bytes) catch unreachable;
+ os.write(self.os_data.final_eventfd, &wakeup_bytes) catch unreachable;
while (extra_thread_index != 0) {
extra_thread_index -= 1;
self.extra_threads[extra_thread_index].wait();
@@ -684,7 +684,7 @@ pub const Loop = struct {
.linux => {
self.posixFsRequest(&self.os_data.fs_end_request);
// writing 8 bytes to an eventfd cannot fail
- noasync os.write(self.os_data.final_eventfd, wakeup_bytes) catch unreachable;
+ noasync os.write(self.os_data.final_eventfd, &wakeup_bytes) catch unreachable;
return;
},
.macosx, .freebsd, .netbsd, .dragonfly => {
diff --git a/lib/std/fifo.zig b/lib/std/fifo.zig
index e078abcb2b..fdd746dfcc 100644
--- a/lib/std/fifo.zig
+++ b/lib/std/fifo.zig
@@ -70,7 +70,7 @@ pub fn LinearFifo(
pub fn init(allocator: *Allocator) Self {
return .{
.allocator = allocator,
- .buf = [_]T{},
+ .buf = &[_]T{},
.head = 0,
.count = 0,
};
@@ -143,7 +143,7 @@ pub fn LinearFifo(
/// Returns a writable slice from the 'read' end of the fifo
fn readableSliceMut(self: SliceSelfArg, offset: usize) []T {
- if (offset > self.count) return [_]T{};
+ if (offset > self.count) return &[_]T{};
var start = self.head + offset;
if (start >= self.buf.len) {
@@ -223,7 +223,7 @@ pub fn LinearFifo(
/// Returns the first section of writable buffer
/// Note that this may be of length 0
pub fn writableSlice(self: SliceSelfArg, offset: usize) []T {
- if (offset > self.buf.len) return [_]T{};
+ if (offset > self.buf.len) return &[_]T{};
const tail = self.head + offset + self.count;
if (tail < self.buf.len) {
@@ -357,7 +357,7 @@ test "LinearFifo(u8, .Dynamic)" {
{
var i: usize = 0;
while (i < 5) : (i += 1) {
- try fifo.write([_]u8{try fifo.peekItem(i)});
+ try fifo.write(&[_]u8{try fifo.peekItem(i)});
}
testing.expectEqual(@as(usize, 10), fifo.readableLength());
testing.expectEqualSlices(u8, "HELLOHELLO", fifo.readableSlice(0));
@@ -426,7 +426,7 @@ test "LinearFifo" {
};
defer fifo.deinit();
- try fifo.write([_]T{ 0, 1, 1, 0, 1 });
+ try fifo.write(&[_]T{ 0, 1, 1, 0, 1 });
testing.expectEqual(@as(usize, 5), fifo.readableLength());
{
diff --git a/lib/std/fmt.zig b/lib/std/fmt.zig
index cbb11cba36..4a28daf4b7 100644
--- a/lib/std/fmt.zig
+++ b/lib/std/fmt.zig
@@ -451,13 +451,18 @@ pub fn formatType(
},
},
.Array => |info| {
- if (info.child == u8) {
- return formatText(value, fmt, options, context, Errors, output);
- }
- if (value.len == 0) {
- return format(context, Errors, output, "[0]{}", @typeName(T.Child));
- }
- return format(context, Errors, output, "{}@{x}", @typeName(T.Child), @ptrToInt(&value));
+ const Slice = @Type(builtin.TypeInfo{
+ .Pointer = .{
+ .size = .Slice,
+ .is_const = true,
+ .is_volatile = false,
+ .is_allowzero = false,
+ .alignment = @alignOf(info.child),
+ .child = info.child,
+ .sentinel = null,
+ },
+ });
+ return formatType(@as(Slice, &value), fmt, options, context, Errors, output, max_depth);
},
.Fn => {
return format(context, Errors, output, "{}@{x}", @typeName(T), @ptrToInt(value));
@@ -872,8 +877,8 @@ pub fn formatBytes(
}
const buf = switch (radix) {
- 1000 => [_]u8{ suffix, 'B' },
- 1024 => [_]u8{ suffix, 'i', 'B' },
+ 1000 => &[_]u8{ suffix, 'B' },
+ 1024 => &[_]u8{ suffix, 'i', 'B' },
else => unreachable,
};
return output(context, buf);
@@ -969,7 +974,7 @@ fn formatIntUnsigned(
if (leftover_padding == 0) break;
}
mem.set(u8, buf[0..index], options.fill);
- return output(context, buf);
+ return output(context, &buf);
} else {
const padded_buf = buf[index - padding ..];
mem.set(u8, padded_buf[0..padding], options.fill);
diff --git a/lib/std/fs.zig b/lib/std/fs.zig
index 95060f566f..9e7daf0a9a 100644
--- a/lib/std/fs.zig
+++ b/lib/std/fs.zig
@@ -58,7 +58,7 @@ pub fn atomicSymLink(allocator: *Allocator, existing_path: []const u8, new_path:
tmp_path[dirname.len] = path.sep;
while (true) {
try crypto.randomBytes(rand_buf[0..]);
- b64_fs_encoder.encode(tmp_path[dirname.len + 1 ..], rand_buf);
+ b64_fs_encoder.encode(tmp_path[dirname.len + 1 ..], &rand_buf);
if (symLink(existing_path, tmp_path)) {
return rename(tmp_path, new_path);
@@ -226,7 +226,7 @@ pub const AtomicFile = struct {
while (true) {
try crypto.randomBytes(rand_buf[0..]);
- b64_fs_encoder.encode(tmp_path_buf[dirname_component_len..tmp_path_len], rand_buf);
+ b64_fs_encoder.encode(tmp_path_buf[dirname_component_len..tmp_path_len], &rand_buf);
// TODO https://github.com/ziglang/zig/issues/3770 to clean up this @ptrCast
const file = my_cwd.createFileC(
@@ -292,7 +292,7 @@ pub fn makeDirW(dir_path: [*:0]const u16) !void {
/// have been modified regardless.
/// TODO determine if we can remove the allocator requirement from this function
pub fn makePath(allocator: *Allocator, full_path: []const u8) !void {
- const resolved_path = try path.resolve(allocator, [_][]const u8{full_path});
+ const resolved_path = try path.resolve(allocator, &[_][]const u8{full_path});
defer allocator.free(resolved_path);
var end_index: usize = resolved_path.len;
@@ -611,7 +611,7 @@ pub const Dir = struct {
const name_utf16le = @ptrCast([*]u16, &dir_info.FileName)[0 .. dir_info.FileNameLength / 2];
- if (mem.eql(u16, name_utf16le, [_]u16{'.'}) or mem.eql(u16, name_utf16le, [_]u16{ '.', '.' }))
+ if (mem.eql(u16, name_utf16le, &[_]u16{'.'}) or mem.eql(u16, name_utf16le, &[_]u16{ '.', '.' }))
continue;
// Trust that Windows gives us valid UTF-16LE
const name_utf8_len = std.unicode.utf16leToUtf8(self.name_data[0..], name_utf16le) catch unreachable;
diff --git a/lib/std/fs/get_app_data_dir.zig b/lib/std/fs/get_app_data_dir.zig
index 657971dd90..bbc9c4b7bb 100644
--- a/lib/std/fs/get_app_data_dir.zig
+++ b/lib/std/fs/get_app_data_dir.zig
@@ -31,7 +31,7 @@ pub fn getAppDataDir(allocator: *mem.Allocator, appname: []const u8) GetAppDataD
error.OutOfMemory => return error.OutOfMemory,
};
defer allocator.free(global_dir);
- return fs.path.join(allocator, [_][]const u8{ global_dir, appname });
+ return fs.path.join(allocator, &[_][]const u8{ global_dir, appname });
},
os.windows.E_OUTOFMEMORY => return error.OutOfMemory,
else => return error.AppDataDirUnavailable,
@@ -42,14 +42,14 @@ pub fn getAppDataDir(allocator: *mem.Allocator, appname: []const u8) GetAppDataD
// TODO look in /etc/passwd
return error.AppDataDirUnavailable;
};
- return fs.path.join(allocator, [_][]const u8{ home_dir, "Library", "Application Support", appname });
+ return fs.path.join(allocator, &[_][]const u8{ home_dir, "Library", "Application Support", appname });
},
.linux, .freebsd, .netbsd, .dragonfly => {
const home_dir = os.getenv("HOME") orelse {
// TODO look in /etc/passwd
return error.AppDataDirUnavailable;
};
- return fs.path.join(allocator, [_][]const u8{ home_dir, ".local", "share", appname });
+ return fs.path.join(allocator, &[_][]const u8{ home_dir, ".local", "share", appname });
},
else => @compileError("Unsupported OS"),
}
diff --git a/lib/std/fs/path.zig b/lib/std/fs/path.zig
index b1b3ef6af3..b3ad3e9f7a 100644
--- a/lib/std/fs/path.zig
+++ b/lib/std/fs/path.zig
@@ -15,7 +15,9 @@ pub const sep_windows = '\\';
pub const sep_posix = '/';
pub const sep = if (builtin.os == .windows) sep_windows else sep_posix;
-pub const sep_str = [1]u8{sep};
+pub const sep_str_windows = "\\";
+pub const sep_str_posix = "/";
+pub const sep_str = if (builtin.os == .windows) sep_str_windows else sep_str_posix;
pub const delimiter_windows = ';';
pub const delimiter_posix = ':';
@@ -101,31 +103,31 @@ fn testJoinPosix(paths: []const []const u8, expected: []const u8) void {
}
test "join" {
- testJoinWindows([_][]const u8{ "c:\\a\\b", "c" }, "c:\\a\\b\\c");
- testJoinWindows([_][]const u8{ "c:\\a\\b", "c" }, "c:\\a\\b\\c");
- testJoinWindows([_][]const u8{ "c:\\a\\b\\", "c" }, "c:\\a\\b\\c");
+ testJoinWindows(&[_][]const u8{ "c:\\a\\b", "c" }, "c:\\a\\b\\c");
+ testJoinWindows(&[_][]const u8{ "c:\\a\\b", "c" }, "c:\\a\\b\\c");
+ testJoinWindows(&[_][]const u8{ "c:\\a\\b\\", "c" }, "c:\\a\\b\\c");
- testJoinWindows([_][]const u8{ "c:\\", "a", "b\\", "c" }, "c:\\a\\b\\c");
- testJoinWindows([_][]const u8{ "c:\\a\\", "b\\", "c" }, "c:\\a\\b\\c");
+ testJoinWindows(&[_][]const u8{ "c:\\", "a", "b\\", "c" }, "c:\\a\\b\\c");
+ testJoinWindows(&[_][]const u8{ "c:\\a\\", "b\\", "c" }, "c:\\a\\b\\c");
testJoinWindows(
- [_][]const u8{ "c:\\home\\andy\\dev\\zig\\build\\lib\\zig\\std", "io.zig" },
+ &[_][]const u8{ "c:\\home\\andy\\dev\\zig\\build\\lib\\zig\\std", "io.zig" },
"c:\\home\\andy\\dev\\zig\\build\\lib\\zig\\std\\io.zig",
);
- testJoinPosix([_][]const u8{ "/a/b", "c" }, "/a/b/c");
- testJoinPosix([_][]const u8{ "/a/b/", "c" }, "/a/b/c");
+ testJoinPosix(&[_][]const u8{ "/a/b", "c" }, "/a/b/c");
+ testJoinPosix(&[_][]const u8{ "/a/b/", "c" }, "/a/b/c");
- testJoinPosix([_][]const u8{ "/", "a", "b/", "c" }, "/a/b/c");
- testJoinPosix([_][]const u8{ "/a/", "b/", "c" }, "/a/b/c");
+ testJoinPosix(&[_][]const u8{ "/", "a", "b/", "c" }, "/a/b/c");
+ testJoinPosix(&[_][]const u8{ "/a/", "b/", "c" }, "/a/b/c");
testJoinPosix(
- [_][]const u8{ "/home/andy/dev/zig/build/lib/zig/std", "io.zig" },
+ &[_][]const u8{ "/home/andy/dev/zig/build/lib/zig/std", "io.zig" },
"/home/andy/dev/zig/build/lib/zig/std/io.zig",
);
- testJoinPosix([_][]const u8{ "a", "/c" }, "a/c");
- testJoinPosix([_][]const u8{ "a/", "/c" }, "a/c");
+ testJoinPosix(&[_][]const u8{ "a", "/c" }, "a/c");
+ testJoinPosix(&[_][]const u8{ "a/", "/c" }, "a/c");
}
pub fn isAbsoluteC(path_c: [*:0]const u8) bool {
@@ -277,7 +279,7 @@ pub fn windowsParsePath(path: []const u8) WindowsPath {
}
const relative_path = WindowsPath{
.kind = WindowsPath.Kind.None,
- .disk_designator = [_]u8{},
+ .disk_designator = &[_]u8{},
.is_abs = false,
};
if (path.len < "//a/b".len) {
@@ -286,12 +288,12 @@ pub fn windowsParsePath(path: []const u8) WindowsPath {
inline for ("/\\") |this_sep| {
const two_sep = [_]u8{ this_sep, this_sep };
- if (mem.startsWith(u8, path, two_sep)) {
+ if (mem.startsWith(u8, path, &two_sep)) {
if (path[2] == this_sep) {
return relative_path;
}
- var it = mem.tokenize(path, [_]u8{this_sep});
+ var it = mem.tokenize(path, &[_]u8{this_sep});
_ = (it.next() orelse return relative_path);
_ = (it.next() orelse return relative_path);
return WindowsPath{
@@ -353,8 +355,8 @@ fn networkShareServersEql(ns1: []const u8, ns2: []const u8) bool {
const sep1 = ns1[0];
const sep2 = ns2[0];
- var it1 = mem.tokenize(ns1, [_]u8{sep1});
- var it2 = mem.tokenize(ns2, [_]u8{sep2});
+ var it1 = mem.tokenize(ns1, &[_]u8{sep1});
+ var it2 = mem.tokenize(ns2, &[_]u8{sep2});
// TODO ASCII is wrong, we actually need full unicode support to compare paths.
return asciiEqlIgnoreCase(it1.next().?, it2.next().?);
@@ -374,8 +376,8 @@ fn compareDiskDesignators(kind: WindowsPath.Kind, p1: []const u8, p2: []const u8
const sep1 = p1[0];
const sep2 = p2[0];
- var it1 = mem.tokenize(p1, [_]u8{sep1});
- var it2 = mem.tokenize(p2, [_]u8{sep2});
+ var it1 = mem.tokenize(p1, &[_]u8{sep1});
+ var it2 = mem.tokenize(p2, &[_]u8{sep2});
// TODO ASCII is wrong, we actually need full unicode support to compare paths.
return asciiEqlIgnoreCase(it1.next().?, it2.next().?) and asciiEqlIgnoreCase(it1.next().?, it2.next().?);
@@ -668,10 +670,10 @@ test "resolve" {
if (windowsParsePath(cwd).kind == WindowsPath.Kind.Drive) {
cwd[0] = asciiUpper(cwd[0]);
}
- testing.expect(mem.eql(u8, testResolveWindows([_][]const u8{"."}), cwd));
+ testing.expect(mem.eql(u8, testResolveWindows(&[_][]const u8{"."}), cwd));
} else {
- testing.expect(mem.eql(u8, testResolvePosix([_][]const u8{ "a/b/c/", "../../.." }), cwd));
- testing.expect(mem.eql(u8, testResolvePosix([_][]const u8{"."}), cwd));
+ testing.expect(mem.eql(u8, testResolvePosix(&[_][]const u8{ "a/b/c/", "../../.." }), cwd));
+ testing.expect(mem.eql(u8, testResolvePosix(&[_][]const u8{"."}), cwd));
}
}
@@ -684,8 +686,8 @@ test "resolveWindows" {
const cwd = try process.getCwdAlloc(debug.global_allocator);
const parsed_cwd = windowsParsePath(cwd);
{
- const result = testResolveWindows([_][]const u8{ "/usr/local", "lib\\zig\\std\\array_list.zig" });
- const expected = try join(debug.global_allocator, [_][]const u8{
+ const result = testResolveWindows(&[_][]const u8{ "/usr/local", "lib\\zig\\std\\array_list.zig" });
+ const expected = try join(debug.global_allocator, &[_][]const u8{
parsed_cwd.disk_designator,
"usr\\local\\lib\\zig\\std\\array_list.zig",
});
@@ -695,8 +697,8 @@ test "resolveWindows" {
testing.expect(mem.eql(u8, result, expected));
}
{
- const result = testResolveWindows([_][]const u8{ "usr/local", "lib\\zig" });
- const expected = try join(debug.global_allocator, [_][]const u8{
+ const result = testResolveWindows(&[_][]const u8{ "usr/local", "lib\\zig" });
+ const expected = try join(debug.global_allocator, &[_][]const u8{
cwd,
"usr\\local\\lib\\zig",
});
@@ -707,32 +709,32 @@ test "resolveWindows" {
}
}
- testing.expect(mem.eql(u8, testResolveWindows([_][]const u8{ "c:\\a\\b\\c", "/hi", "ok" }), "C:\\hi\\ok"));
- testing.expect(mem.eql(u8, testResolveWindows([_][]const u8{ "c:/blah\\blah", "d:/games", "c:../a" }), "C:\\blah\\a"));
- testing.expect(mem.eql(u8, testResolveWindows([_][]const u8{ "c:/blah\\blah", "d:/games", "C:../a" }), "C:\\blah\\a"));
- testing.expect(mem.eql(u8, testResolveWindows([_][]const u8{ "c:/ignore", "d:\\a/b\\c/d", "\\e.exe" }), "D:\\e.exe"));
- testing.expect(mem.eql(u8, testResolveWindows([_][]const u8{ "c:/ignore", "c:/some/file" }), "C:\\some\\file"));
- testing.expect(mem.eql(u8, testResolveWindows([_][]const u8{ "d:/ignore", "d:some/dir//" }), "D:\\ignore\\some\\dir"));
- testing.expect(mem.eql(u8, testResolveWindows([_][]const u8{ "//server/share", "..", "relative\\" }), "\\\\server\\share\\relative"));
- testing.expect(mem.eql(u8, testResolveWindows([_][]const u8{ "c:/", "//" }), "C:\\"));
- testing.expect(mem.eql(u8, testResolveWindows([_][]const u8{ "c:/", "//dir" }), "C:\\dir"));
- testing.expect(mem.eql(u8, testResolveWindows([_][]const u8{ "c:/", "//server/share" }), "\\\\server\\share\\"));
- testing.expect(mem.eql(u8, testResolveWindows([_][]const u8{ "c:/", "//server//share" }), "\\\\server\\share\\"));
- testing.expect(mem.eql(u8, testResolveWindows([_][]const u8{ "c:/", "///some//dir" }), "C:\\some\\dir"));
- testing.expect(mem.eql(u8, testResolveWindows([_][]const u8{ "C:\\foo\\tmp.3\\", "..\\tmp.3\\cycles\\root.js" }), "C:\\foo\\tmp.3\\cycles\\root.js"));
+ testing.expect(mem.eql(u8, testResolveWindows(&[_][]const u8{ "c:\\a\\b\\c", "/hi", "ok" }), "C:\\hi\\ok"));
+ testing.expect(mem.eql(u8, testResolveWindows(&[_][]const u8{ "c:/blah\\blah", "d:/games", "c:../a" }), "C:\\blah\\a"));
+ testing.expect(mem.eql(u8, testResolveWindows(&[_][]const u8{ "c:/blah\\blah", "d:/games", "C:../a" }), "C:\\blah\\a"));
+ testing.expect(mem.eql(u8, testResolveWindows(&[_][]const u8{ "c:/ignore", "d:\\a/b\\c/d", "\\e.exe" }), "D:\\e.exe"));
+ testing.expect(mem.eql(u8, testResolveWindows(&[_][]const u8{ "c:/ignore", "c:/some/file" }), "C:\\some\\file"));
+ testing.expect(mem.eql(u8, testResolveWindows(&[_][]const u8{ "d:/ignore", "d:some/dir//" }), "D:\\ignore\\some\\dir"));
+ testing.expect(mem.eql(u8, testResolveWindows(&[_][]const u8{ "//server/share", "..", "relative\\" }), "\\\\server\\share\\relative"));
+ testing.expect(mem.eql(u8, testResolveWindows(&[_][]const u8{ "c:/", "//" }), "C:\\"));
+ testing.expect(mem.eql(u8, testResolveWindows(&[_][]const u8{ "c:/", "//dir" }), "C:\\dir"));
+ testing.expect(mem.eql(u8, testResolveWindows(&[_][]const u8{ "c:/", "//server/share" }), "\\\\server\\share\\"));
+ testing.expect(mem.eql(u8, testResolveWindows(&[_][]const u8{ "c:/", "//server//share" }), "\\\\server\\share\\"));
+ testing.expect(mem.eql(u8, testResolveWindows(&[_][]const u8{ "c:/", "///some//dir" }), "C:\\some\\dir"));
+ testing.expect(mem.eql(u8, testResolveWindows(&[_][]const u8{ "C:\\foo\\tmp.3\\", "..\\tmp.3\\cycles\\root.js" }), "C:\\foo\\tmp.3\\cycles\\root.js"));
}
test "resolvePosix" {
- testing.expect(mem.eql(u8, testResolvePosix([_][]const u8{ "/a/b", "c" }), "/a/b/c"));
- testing.expect(mem.eql(u8, testResolvePosix([_][]const u8{ "/a/b", "c", "//d", "e///" }), "/d/e"));
- testing.expect(mem.eql(u8, testResolvePosix([_][]const u8{ "/a/b/c", "..", "../" }), "/a"));
- testing.expect(mem.eql(u8, testResolvePosix([_][]const u8{ "/", "..", ".." }), "/"));
- testing.expect(mem.eql(u8, testResolvePosix([_][]const u8{"/a/b/c/"}), "/a/b/c"));
-
- testing.expect(mem.eql(u8, testResolvePosix([_][]const u8{ "/var/lib", "../", "file/" }), "/var/file"));
- testing.expect(mem.eql(u8, testResolvePosix([_][]const u8{ "/var/lib", "/../", "file/" }), "/file"));
- testing.expect(mem.eql(u8, testResolvePosix([_][]const u8{ "/some/dir", ".", "/absolute/" }), "/absolute"));
- testing.expect(mem.eql(u8, testResolvePosix([_][]const u8{ "/foo/tmp.3/", "../tmp.3/cycles/root.js" }), "/foo/tmp.3/cycles/root.js"));
+ testing.expect(mem.eql(u8, testResolvePosix(&[_][]const u8{ "/a/b", "c" }), "/a/b/c"));
+ testing.expect(mem.eql(u8, testResolvePosix(&[_][]const u8{ "/a/b", "c", "//d", "e///" }), "/d/e"));
+ testing.expect(mem.eql(u8, testResolvePosix(&[_][]const u8{ "/a/b/c", "..", "../" }), "/a"));
+ testing.expect(mem.eql(u8, testResolvePosix(&[_][]const u8{ "/", "..", ".." }), "/"));
+ testing.expect(mem.eql(u8, testResolvePosix(&[_][]const u8{"/a/b/c/"}), "/a/b/c"));
+
+ testing.expect(mem.eql(u8, testResolvePosix(&[_][]const u8{ "/var/lib", "../", "file/" }), "/var/file"));
+ testing.expect(mem.eql(u8, testResolvePosix(&[_][]const u8{ "/var/lib", "/../", "file/" }), "/file"));
+ testing.expect(mem.eql(u8, testResolvePosix(&[_][]const u8{ "/some/dir", ".", "/absolute/" }), "/absolute"));
+ testing.expect(mem.eql(u8, testResolvePosix(&[_][]const u8{ "/foo/tmp.3/", "../tmp.3/cycles/root.js" }), "/foo/tmp.3/cycles/root.js"));
}
fn testResolveWindows(paths: []const []const u8) []u8 {
@@ -887,12 +889,12 @@ pub fn basename(path: []const u8) []const u8 {
pub fn basenamePosix(path: []const u8) []const u8 {
if (path.len == 0)
- return [_]u8{};
+ return &[_]u8{};
var end_index: usize = path.len - 1;
while (path[end_index] == '/') {
if (end_index == 0)
- return [_]u8{};
+ return &[_]u8{};
end_index -= 1;
}
var start_index: usize = end_index;
@@ -908,19 +910,19 @@ pub fn basenamePosix(path: []const u8) []const u8 {
pub fn basenameWindows(path: []const u8) []const u8 {
if (path.len == 0)
- return [_]u8{};
+ return &[_]u8{};
var end_index: usize = path.len - 1;
while (true) {
const byte = path[end_index];
if (byte == '/' or byte == '\\') {
if (end_index == 0)
- return [_]u8{};
+ return &[_]u8{};
end_index -= 1;
continue;
}
if (byte == ':' and end_index == 1) {
- return [_]u8{};
+ return &[_]u8{};
}
break;
}
@@ -1002,11 +1004,11 @@ pub fn relative(allocator: *Allocator, from: []const u8, to: []const u8) ![]u8 {
}
pub fn relativeWindows(allocator: *Allocator, from: []const u8, to: []const u8) ![]u8 {
- const resolved_from = try resolveWindows(allocator, [_][]const u8{from});
+ const resolved_from = try resolveWindows(allocator, &[_][]const u8{from});
defer allocator.free(resolved_from);
var clean_up_resolved_to = true;
- const resolved_to = try resolveWindows(allocator, [_][]const u8{to});
+ const resolved_to = try resolveWindows(allocator, &[_][]const u8{to});
defer if (clean_up_resolved_to) allocator.free(resolved_to);
const parsed_from = windowsParsePath(resolved_from);
@@ -1075,10 +1077,10 @@ pub fn relativeWindows(allocator: *Allocator, from: []const u8, to: []const u8)
}
pub fn relativePosix(allocator: *Allocator, from: []const u8, to: []const u8) ![]u8 {
- const resolved_from = try resolvePosix(allocator, [_][]const u8{from});
+ const resolved_from = try resolvePosix(allocator, &[_][]const u8{from});
defer allocator.free(resolved_from);
- const resolved_to = try resolvePosix(allocator, [_][]const u8{to});
+ const resolved_to = try resolvePosix(allocator, &[_][]const u8{to});
defer allocator.free(resolved_to);
var from_it = mem.tokenize(resolved_from, "/");
diff --git a/lib/std/hash/cityhash.zig b/lib/std/hash/cityhash.zig
index d31ee17105..5038c3758e 100644
--- a/lib/std/hash/cityhash.zig
+++ b/lib/std/hash/cityhash.zig
@@ -367,7 +367,7 @@ fn SMHasherTest(comptime hash_fn: var, comptime hashbits: u32) u32 {
@memcpy(@ptrCast([*]u8, &hashes[i * hashbytes]), @ptrCast([*]u8, &h), hashbytes);
}
- return @truncate(u32, hash_fn(hashes, 0));
+ return @truncate(u32, hash_fn(&hashes, 0));
}
fn CityHash32hashIgnoreSeed(str: []const u8, seed: u32) u32 {
diff --git a/lib/std/hash/murmur.zig b/lib/std/hash/murmur.zig
index f70190d311..d3379a81f7 100644
--- a/lib/std/hash/murmur.zig
+++ b/lib/std/hash/murmur.zig
@@ -299,7 +299,7 @@ fn SMHasherTest(comptime hash_fn: var, comptime hashbits: u32) u32 {
@memcpy(@ptrCast([*]u8, &hashes[i * hashbytes]), @ptrCast([*]u8, &h), hashbytes);
}
- return @truncate(u32, hash_fn(hashes, 0));
+ return @truncate(u32, hash_fn(&hashes, 0));
}
test "murmur2_32" {
diff --git a/lib/std/hash_map.zig b/lib/std/hash_map.zig
index 8b61531cf2..f08ec4b59e 100644
--- a/lib/std/hash_map.zig
+++ b/lib/std/hash_map.zig
@@ -94,7 +94,7 @@ pub fn HashMap(comptime K: type, comptime V: type, comptime hash: fn (key: K) u3
pub fn init(allocator: *Allocator) Self {
return Self{
- .entries = [_]Entry{},
+ .entries = &[_]Entry{},
.allocator = allocator,
.size = 0,
.max_distance_from_start_index = 0,
diff --git a/lib/std/http/headers.zig b/lib/std/http/headers.zig
index a860186e47..1d573aebc0 100644
--- a/lib/std/http/headers.zig
+++ b/lib/std/http/headers.zig
@@ -514,8 +514,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").?.toSliceConst());
+ testing.expectEqualSlices(usize, &[_]usize{ 1, 2 }, h.getIndices("set-cookie").?.toSliceConst());
}
test "Headers.get" {
diff --git a/lib/std/io.zig b/lib/std/io.zig
index c36fd195ba..8f80fac946 100644
--- a/lib/std/io.zig
+++ b/lib/std/io.zig
@@ -1104,7 +1104,7 @@ pub fn Serializer(comptime endian: builtin.Endian, comptime packing: Packing, co
byte.* = if (t_bit_count < u8_bit_count) v else @truncate(u8, v);
}
- try self.out_stream.write(buffer);
+ try self.out_stream.write(&buffer);
}
/// Serializes the passed value into the stream
diff --git a/lib/std/io/out_stream.zig b/lib/std/io/out_stream.zig
index c0cd6e48a1..77698b333c 100644
--- a/lib/std/io/out_stream.zig
+++ b/lib/std/io/out_stream.zig
@@ -56,32 +56,32 @@ pub fn OutStream(comptime WriteError: type) type {
pub fn writeIntNative(self: *Self, comptime T: type, value: T) Error!void {
var bytes: [(T.bit_count + 7) / 8]u8 = undefined;
mem.writeIntNative(T, &bytes, value);
- return self.writeFn(self, bytes);
+ return self.writeFn(self, &bytes);
}
/// Write a foreign-endian integer.
pub fn writeIntForeign(self: *Self, comptime T: type, value: T) Error!void {
var bytes: [(T.bit_count + 7) / 8]u8 = undefined;
mem.writeIntForeign(T, &bytes, value);
- return self.writeFn(self, bytes);
+ return self.writeFn(self, &bytes);
}
pub fn writeIntLittle(self: *Self, comptime T: type, value: T) Error!void {
var bytes: [(T.bit_count + 7) / 8]u8 = undefined;
mem.writeIntLittle(T, &bytes, value);
- return self.writeFn(self, bytes);
+ return self.writeFn(self, &bytes);
}
pub fn writeIntBig(self: *Self, comptime T: type, value: T) Error!void {
var bytes: [(T.bit_count + 7) / 8]u8 = undefined;
mem.writeIntBig(T, &bytes, value);
- return self.writeFn(self, bytes);
+ return self.writeFn(self, &bytes);
}
pub fn writeInt(self: *Self, comptime T: type, value: T, endian: builtin.Endian) Error!void {
var bytes: [(T.bit_count + 7) / 8]u8 = undefined;
mem.writeInt(T, &bytes, value, endian);
- return self.writeFn(self, bytes);
+ return self.writeFn(self, &bytes);
}
};
}
diff --git a/lib/std/io/test.zig b/lib/std/io/test.zig
index 912a871863..5b189cbe5a 100644
--- a/lib/std/io/test.zig
+++ b/lib/std/io/test.zig
@@ -57,7 +57,7 @@ test "write a file, read it, then delete it" {
defer allocator.free(contents);
expect(mem.eql(u8, contents[0.."begin".len], "begin"));
- expect(mem.eql(u8, contents["begin".len .. contents.len - "end".len], data));
+ expect(mem.eql(u8, contents["begin".len .. contents.len - "end".len], &data));
expect(mem.eql(u8, contents[contents.len - "end".len ..], "end"));
}
try cwd.deleteFile(tmp_file_name);
@@ -79,7 +79,7 @@ test "BufferOutStream" {
test "SliceInStream" {
const bytes = [_]u8{ 1, 2, 3, 4, 5, 6, 7 };
- var ss = io.SliceInStream.init(bytes);
+ var ss = io.SliceInStream.init(&bytes);
var dest: [4]u8 = undefined;
@@ -97,7 +97,7 @@ test "SliceInStream" {
test "PeekStream" {
const bytes = [_]u8{ 1, 2, 3, 4, 5, 6, 7, 8 };
- var ss = io.SliceInStream.init(bytes);
+ var ss = io.SliceInStream.init(&bytes);
var ps = io.PeekStream(2, io.SliceInStream.Error).init(&ss.stream);
var dest: [4]u8 = undefined;
@@ -616,7 +616,7 @@ test "File seek ops" {
fs.cwd().deleteFile(tmp_file_name) catch {};
}
- try file.write([_]u8{0x55} ** 8192);
+ try file.write(&([_]u8{0x55} ** 8192));
// Seek to the end
try file.seekFromEnd(0);
diff --git a/lib/std/mem.zig b/lib/std/mem.zig
index 412bf9b649..cba1f9f177 100644
--- a/lib/std/mem.zig
+++ b/lib/std/mem.zig
@@ -624,23 +624,23 @@ test "comptime read/write int" {
}
test "readIntBig and readIntLittle" {
- testing.expect(readIntSliceBig(u0, [_]u8{}) == 0x0);
- testing.expect(readIntSliceLittle(u0, [_]u8{}) == 0x0);
+ testing.expect(readIntSliceBig(u0, &[_]u8{}) == 0x0);
+ testing.expect(readIntSliceLittle(u0, &[_]u8{}) == 0x0);
- testing.expect(readIntSliceBig(u8, [_]u8{0x32}) == 0x32);
- testing.expect(readIntSliceLittle(u8, [_]u8{0x12}) == 0x12);
+ testing.expect(readIntSliceBig(u8, &[_]u8{0x32}) == 0x32);
+ testing.expect(readIntSliceLittle(u8, &[_]u8{0x12}) == 0x12);
- testing.expect(readIntSliceBig(u16, [_]u8{ 0x12, 0x34 }) == 0x1234);
- testing.expect(readIntSliceLittle(u16, [_]u8{ 0x12, 0x34 }) == 0x3412);
+ testing.expect(readIntSliceBig(u16, &[_]u8{ 0x12, 0x34 }) == 0x1234);
+ testing.expect(readIntSliceLittle(u16, &[_]u8{ 0x12, 0x34 }) == 0x3412);
- testing.expect(readIntSliceBig(u72, [_]u8{ 0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0, 0x24 }) == 0x123456789abcdef024);
- testing.expect(readIntSliceLittle(u72, [_]u8{ 0xec, 0x10, 0x32, 0x54, 0x76, 0x98, 0xba, 0xdc, 0xfe }) == 0xfedcba9876543210ec);
+ testing.expect(readIntSliceBig(u72, &[_]u8{ 0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0, 0x24 }) == 0x123456789abcdef024);
+ testing.expect(readIntSliceLittle(u72, &[_]u8{ 0xec, 0x10, 0x32, 0x54, 0x76, 0x98, 0xba, 0xdc, 0xfe }) == 0xfedcba9876543210ec);
- testing.expect(readIntSliceBig(i8, [_]u8{0xff}) == -1);
- testing.expect(readIntSliceLittle(i8, [_]u8{0xfe}) == -2);
+ testing.expect(readIntSliceBig(i8, &[_]u8{0xff}) == -1);
+ testing.expect(readIntSliceLittle(i8, &[_]u8{0xfe}) == -2);
- testing.expect(readIntSliceBig(i16, [_]u8{ 0xff, 0xfd }) == -3);
- testing.expect(readIntSliceLittle(i16, [_]u8{ 0xfc, 0xff }) == -4);
+ testing.expect(readIntSliceBig(i16, &[_]u8{ 0xff, 0xfd }) == -3);
+ testing.expect(readIntSliceLittle(i16, &[_]u8{ 0xfc, 0xff }) == -4);
}
/// Writes an integer to memory, storing it in twos-complement.
@@ -749,34 +749,34 @@ test "writeIntBig and writeIntLittle" {
var buf9: [9]u8 = undefined;
writeIntBig(u0, &buf0, 0x0);
- testing.expect(eql(u8, buf0[0..], [_]u8{}));
+ testing.expect(eql(u8, buf0[0..], &[_]u8{}));
writeIntLittle(u0, &buf0, 0x0);
- testing.expect(eql(u8, buf0[0..], [_]u8{}));
+ testing.expect(eql(u8, buf0[0..], &[_]u8{}));
writeIntBig(u8, &buf1, 0x12);
- testing.expect(eql(u8, buf1[0..], [_]u8{0x12}));
+ testing.expect(eql(u8, buf1[0..], &[_]u8{0x12}));
writeIntLittle(u8, &buf1, 0x34);
- testing.expect(eql(u8, buf1[0..], [_]u8{0x34}));
+ testing.expect(eql(u8, buf1[0..], &[_]u8{0x34}));
writeIntBig(u16, &buf2, 0x1234);
- testing.expect(eql(u8, buf2[0..], [_]u8{ 0x12, 0x34 }));
+ testing.expect(eql(u8, buf2[0..], &[_]u8{ 0x12, 0x34 }));
writeIntLittle(u16, &buf2, 0x5678);
- testing.expect(eql(u8, buf2[0..], [_]u8{ 0x78, 0x56 }));
+ testing.expect(eql(u8, buf2[0..], &[_]u8{ 0x78, 0x56 }));
writeIntBig(u72, &buf9, 0x123456789abcdef024);
- testing.expect(eql(u8, buf9[0..], [_]u8{ 0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0, 0x24 }));
+ testing.expect(eql(u8, buf9[0..], &[_]u8{ 0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0, 0x24 }));
writeIntLittle(u72, &buf9, 0xfedcba9876543210ec);
- testing.expect(eql(u8, buf9[0..], [_]u8{ 0xec, 0x10, 0x32, 0x54, 0x76, 0x98, 0xba, 0xdc, 0xfe }));
+ testing.expect(eql(u8, buf9[0..], &[_]u8{ 0xec, 0x10, 0x32, 0x54, 0x76, 0x98, 0xba, 0xdc, 0xfe }));
writeIntBig(i8, &buf1, -1);
- testing.expect(eql(u8, buf1[0..], [_]u8{0xff}));
+ testing.expect(eql(u8, buf1[0..], &[_]u8{0xff}));
writeIntLittle(i8, &buf1, -2);
- testing.expect(eql(u8, buf1[0..], [_]u8{0xfe}));
+ testing.expect(eql(u8, buf1[0..], &[_]u8{0xfe}));
writeIntBig(i16, &buf2, -3);
- testing.expect(eql(u8, buf2[0..], [_]u8{ 0xff, 0xfd }));
+ testing.expect(eql(u8, buf2[0..], &[_]u8{ 0xff, 0xfd }));
writeIntLittle(i16, &buf2, -4);
- testing.expect(eql(u8, buf2[0..], [_]u8{ 0xfc, 0xff }));
+ testing.expect(eql(u8, buf2[0..], &[_]u8{ 0xfc, 0xff }));
}
/// Returns an iterator that iterates over the slices of `buffer` that are not
@@ -1004,9 +1004,9 @@ pub fn join(allocator: *Allocator, separator: []const u8, slices: []const []cons
test "mem.join" {
var buf: [1024]u8 = undefined;
const a = &std.heap.FixedBufferAllocator.init(&buf).allocator;
- testing.expect(eql(u8, try join(a, ",", [_][]const u8{ "a", "b", "c" }), "a,b,c"));
- testing.expect(eql(u8, try join(a, ",", [_][]const u8{"a"}), "a"));
- testing.expect(eql(u8, try join(a, ",", [_][]const u8{ "a", "", "b", "", "c" }), "a,,b,,c"));
+ testing.expect(eql(u8, try join(a, ",", &[_][]const u8{ "a", "b", "c" }), "a,b,c"));
+ testing.expect(eql(u8, try join(a, ",", &[_][]const u8{"a"}), "a"));
+ testing.expect(eql(u8, try join(a, ",", &[_][]const u8{ "a", "", "b", "", "c" }), "a,,b,,c"));
}
/// Copies each T from slices into a new slice that exactly holds all the elements.
@@ -1037,13 +1037,13 @@ pub fn concat(allocator: *Allocator, comptime T: type, slices: []const []const T
test "concat" {
var buf: [1024]u8 = undefined;
const a = &std.heap.FixedBufferAllocator.init(&buf).allocator;
- testing.expect(eql(u8, try concat(a, u8, [_][]const u8{ "abc", "def", "ghi" }), "abcdefghi"));
- testing.expect(eql(u32, try concat(a, u32, [_][]const u32{
- [_]u32{ 0, 1 },
- [_]u32{ 2, 3, 4 },
- [_]u32{},
- [_]u32{5},
- }), [_]u32{ 0, 1, 2, 3, 4, 5 }));
+ testing.expect(eql(u8, try concat(a, u8, &[_][]const u8{ "abc", "def", "ghi" }), "abcdefghi"));
+ testing.expect(eql(u32, try concat(a, u32, &[_][]const u32{
+ &[_]u32{ 0, 1 },
+ &[_]u32{ 2, 3, 4 },
+ &[_]u32{},
+ &[_]u32{5},
+ }), &[_]u32{ 0, 1, 2, 3, 4, 5 }));
}
test "testStringEquality" {
@@ -1111,19 +1111,19 @@ fn testWriteIntImpl() void {
var bytes: [8]u8 = undefined;
writeIntSlice(u0, bytes[0..], 0, builtin.Endian.Big);
- testing.expect(eql(u8, bytes, [_]u8{
+ testing.expect(eql(u8, &bytes, &[_]u8{
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
}));
writeIntSlice(u0, bytes[0..], 0, builtin.Endian.Little);
- testing.expect(eql(u8, bytes, [_]u8{
+ testing.expect(eql(u8, &bytes, &[_]u8{
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
}));
writeIntSlice(u64, bytes[0..], 0x12345678CAFEBABE, builtin.Endian.Big);
- testing.expect(eql(u8, bytes, [_]u8{
+ testing.expect(eql(u8, &bytes, &[_]u8{
0x12,
0x34,
0x56,
@@ -1135,7 +1135,7 @@ fn testWriteIntImpl() void {
}));
writeIntSlice(u64, bytes[0..], 0xBEBAFECA78563412, builtin.Endian.Little);
- testing.expect(eql(u8, bytes, [_]u8{
+ testing.expect(eql(u8, &bytes, &[_]u8{
0x12,
0x34,
0x56,
@@ -1147,7 +1147,7 @@ fn testWriteIntImpl() void {
}));
writeIntSlice(u32, bytes[0..], 0x12345678, builtin.Endian.Big);
- testing.expect(eql(u8, bytes, [_]u8{
+ testing.expect(eql(u8, &bytes, &[_]u8{
0x00,
0x00,
0x00,
@@ -1159,7 +1159,7 @@ fn testWriteIntImpl() void {
}));
writeIntSlice(u32, bytes[0..], 0x78563412, builtin.Endian.Little);
- testing.expect(eql(u8, bytes, [_]u8{
+ testing.expect(eql(u8, &bytes, &[_]u8{
0x12,
0x34,
0x56,
@@ -1171,7 +1171,7 @@ fn testWriteIntImpl() void {
}));
writeIntSlice(u16, bytes[0..], 0x1234, builtin.Endian.Big);
- testing.expect(eql(u8, bytes, [_]u8{
+ testing.expect(eql(u8, &bytes, &[_]u8{
0x00,
0x00,
0x00,
@@ -1183,7 +1183,7 @@ fn testWriteIntImpl() void {
}));
writeIntSlice(u16, bytes[0..], 0x1234, builtin.Endian.Little);
- testing.expect(eql(u8, bytes, [_]u8{
+ testing.expect(eql(u8, &bytes, &[_]u8{
0x34,
0x12,
0x00,
@@ -1235,22 +1235,10 @@ pub fn reverse(comptime T: type, items: []T) void {
}
test "reverse" {
- var arr = [_]i32{
- 5,
- 3,
- 1,
- 2,
- 4,
- };
+ var arr = [_]i32{ 5, 3, 1, 2, 4 };
reverse(i32, arr[0..]);
- testing.expect(eql(i32, arr, [_]i32{
- 4,
- 2,
- 1,
- 3,
- 5,
- }));
+ testing.expect(eql(i32, &arr, &[_]i32{ 4, 2, 1, 3, 5 }));
}
/// In-place rotation of the values in an array ([0 1 2 3] becomes [1 2 3 0] if we rotate by 1)
@@ -1262,22 +1250,10 @@ pub fn rotate(comptime T: type, items: []T, amount: usize) void {
}
test "rotate" {
- var arr = [_]i32{
- 5,
- 3,
- 1,
- 2,
- 4,
- };
+ var arr = [_]i32{ 5, 3, 1, 2, 4 };
rotate(i32, arr[0..], 2);
- testing.expect(eql(i32, arr, [_]i32{
- 1,
- 2,
- 4,
- 5,
- 3,
- }));
+ testing.expect(eql(i32, &arr, &[_]i32{ 1, 2, 4, 5, 3 }));
}
/// Converts a little-endian integer to host endianness.
@@ -1394,14 +1370,14 @@ pub fn toBytes(value: var) [@sizeOf(@typeOf(value))]u8 {
test "toBytes" {
var my_bytes = toBytes(@as(u32, 0x12345678));
switch (builtin.endian) {
- builtin.Endian.Big => testing.expect(eql(u8, my_bytes, "\x12\x34\x56\x78")),
- builtin.Endian.Little => testing.expect(eql(u8, my_bytes, "\x78\x56\x34\x12")),
+ builtin.Endian.Big => testing.expect(eql(u8, &my_bytes, "\x12\x34\x56\x78")),
+ builtin.Endian.Little => testing.expect(eql(u8, &my_bytes, "\x78\x56\x34\x12")),
}
my_bytes[0] = '\x99';
switch (builtin.endian) {
- builtin.Endian.Big => testing.expect(eql(u8, my_bytes, "\x99\x34\x56\x78")),
- builtin.Endian.Little => testing.expect(eql(u8, my_bytes, "\x99\x56\x34\x12")),
+ builtin.Endian.Big => testing.expect(eql(u8, &my_bytes, "\x99\x34\x56\x78")),
+ builtin.Endian.Little => testing.expect(eql(u8, &my_bytes, "\x99\x56\x34\x12")),
}
}
@@ -1495,14 +1471,14 @@ pub fn subArrayPtr(ptr: var, comptime start: usize, comptime length: usize) SubA
test "subArrayPtr" {
const a1: [6]u8 = "abcdef".*;
const sub1 = subArrayPtr(&a1, 2, 3);
- testing.expect(eql(u8, sub1.*, "cde"));
+ testing.expect(eql(u8, sub1, "cde"));
var a2: [6]u8 = "abcdef".*;
var sub2 = subArrayPtr(&a2, 2, 3);
testing.expect(eql(u8, sub2, "cde"));
sub2[1] = 'X';
- testing.expect(eql(u8, a2, "abcXef"));
+ testing.expect(eql(u8, &a2, "abcXef"));
}
/// Round an address up to the nearest aligned address
diff --git a/lib/std/meta/trait.zig b/lib/std/meta/trait.zig
index 2388acbeb6..5da6e464b6 100644
--- a/lib/std/meta/trait.zig
+++ b/lib/std/meta/trait.zig
@@ -46,7 +46,7 @@ test "std.meta.trait.multiTrait" {
}
};
- const isVector = multiTrait([_]TraitFn{
+ const isVector = multiTrait(&[_]TraitFn{
hasFn("add"),
hasField("x"),
hasField("y"),
diff --git a/lib/std/net.zig b/lib/std/net.zig
index e18e5d378b..6091564a93 100644
--- a/lib/std/net.zig
+++ b/lib/std/net.zig
@@ -291,7 +291,7 @@ pub const Address = extern union {
},
os.AF_INET6 => {
const port = mem.bigToNative(u16, self.in6.port);
- if (mem.eql(u8, self.in6.addr[0..12], [_]u8{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xff, 0xff })) {
+ if (mem.eql(u8, self.in6.addr[0..12], &[_]u8{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xff, 0xff })) {
try std.fmt.format(
context,
Errors,
@@ -339,7 +339,7 @@ pub const Address = extern union {
unreachable;
}
- try std.fmt.format(context, Errors, output, "{}", self.un.path);
+ try std.fmt.format(context, Errors, output, "{}", &self.un.path);
},
else => unreachable,
}
@@ -894,7 +894,7 @@ fn linuxLookupNameFromDnsSearch(
}
const search = if (rc.search.isNull() or dots >= rc.ndots or mem.endsWith(u8, name, "."))
- [_]u8{}
+ &[_]u8{}
else
rc.search.toSliceConst();
@@ -959,7 +959,7 @@ fn linuxLookupNameFromDns(
for (afrrs) |afrr| {
if (family != afrr.af) {
- const len = os.res_mkquery(0, name, 1, afrr.rr, [_]u8{}, null, &qbuf[nq]);
+ const len = os.res_mkquery(0, name, 1, afrr.rr, &[_]u8{}, null, &qbuf[nq]);
qp[nq] = qbuf[nq][0..len];
nq += 1;
}
diff --git a/lib/std/os.zig b/lib/std/os.zig
index 622aaaf3bd..c06c1dedf5 100644
--- a/lib/std/os.zig
+++ b/lib/std/os.zig
@@ -1571,8 +1571,8 @@ pub fn isCygwinPty(handle: fd_t) bool {
const name_info = @ptrCast(*const windows.FILE_NAME_INFO, &name_info_bytes[0]);
const name_bytes = name_info_bytes[size .. size + @as(usize, name_info.FileNameLength)];
const name_wide = @bytesToSlice(u16, name_bytes);
- return mem.indexOf(u16, name_wide, [_]u16{ 'm', 's', 'y', 's', '-' }) != null or
- mem.indexOf(u16, name_wide, [_]u16{ '-', 'p', 't', 'y' }) != null;
+ return mem.indexOf(u16, name_wide, &[_]u16{ 'm', 's', 'y', 's', '-' }) != null or
+ mem.indexOf(u16, name_wide, &[_]u16{ '-', 'p', 't', 'y' }) != null;
}
pub const SocketError = error{
@@ -2640,7 +2640,7 @@ pub fn realpathW(pathname: [*:0]const u16, out_buffer: *[MAX_PATH_BYTES]u8) Real
// Windows returns \\?\ prepended to the path.
// We strip it to make this function consistent across platforms.
const prefix = [_]u16{ '\\', '\\', '?', '\\' };
- const start_index = if (mem.startsWith(u16, wide_slice, prefix)) prefix.len else 0;
+ const start_index = if (mem.startsWith(u16, wide_slice, &prefix)) prefix.len else 0;
// Trust that Windows gives us valid UTF-16LE.
const end_index = std.unicode.utf16leToUtf8(out_buffer, wide_slice[start_index..]) catch unreachable;
diff --git a/lib/std/os/test.zig b/lib/std/os/test.zig
index c49de1680b..f61e8b4657 100644
--- a/lib/std/os/test.zig
+++ b/lib/std/os/test.zig
@@ -137,7 +137,7 @@ test "getrandom" {
try os.getrandom(&buf_b);
// If this test fails the chance is significantly higher that there is a bug than
// that two sets of 50 bytes were equal.
- expect(!mem.eql(u8, buf_a, buf_b));
+ expect(!mem.eql(u8, &buf_a, &buf_b));
}
test "getcwd" {
diff --git a/lib/std/os/windows.zig b/lib/std/os/windows.zig
index 5fc18accb8..ca3a0126c4 100644
--- a/lib/std/os/windows.zig
+++ b/lib/std/os/windows.zig
@@ -932,9 +932,9 @@ pub fn wToPrefixedFileW(s: []const u16) ![PATH_MAX_WIDE:0]u16 {
// TODO https://github.com/ziglang/zig/issues/2765
var result: [PATH_MAX_WIDE:0]u16 = undefined;
- const start_index = if (mem.startsWith(u16, s, [_]u16{ '\\', '?' })) 0 else blk: {
+ const start_index = if (mem.startsWith(u16, s, &[_]u16{ '\\', '?' })) 0 else blk: {
const prefix = [_]u16{ '\\', '?', '?', '\\' };
- mem.copy(u16, result[0..], prefix);
+ mem.copy(u16, result[0..], &prefix);
break :blk prefix.len;
};
const end_index = start_index + s.len;
@@ -961,7 +961,7 @@ pub fn sliceToPrefixedSuffixedFileW(s: []const u8, comptime suffix: []const u16)
}
const start_index = if (mem.startsWith(u8, s, "\\?") or !std.fs.path.isAbsolute(s)) 0 else blk: {
const prefix = [_]u16{ '\\', '?', '?', '\\' };
- mem.copy(u16, result[0..], prefix);
+ mem.copy(u16, result[0..], &prefix);
break :blk prefix.len;
};
const end_index = start_index + try std.unicode.utf8ToUtf16Le(result[start_index..], s);
diff --git a/lib/std/packed_int_array.zig b/lib/std/packed_int_array.zig
index 57660f23d9..bc29e985b5 100644
--- a/lib/std/packed_int_array.zig
+++ b/lib/std/packed_int_array.zig
@@ -201,7 +201,7 @@ pub fn PackedIntArrayEndian(comptime Int: type, comptime endian: builtin.Endian,
///Return the Int stored at index
pub fn get(self: Self, index: usize) Int {
debug.assert(index < int_count);
- return Io.get(self.bytes, index, 0);
+ return Io.get(&self.bytes, index, 0);
}
///Copy int into the array at index
@@ -528,16 +528,7 @@ test "PackedInt(Array/Slice) sliceCast" {
test "PackedInt(Array/Slice)Endian" {
{
const PackedArrayBe = PackedIntArrayEndian(u4, .Big, 8);
- var packed_array_be = PackedArrayBe.init([_]u4{
- 0,
- 1,
- 2,
- 3,
- 4,
- 5,
- 6,
- 7,
- });
+ var packed_array_be = PackedArrayBe.init([_]u4{ 0, 1, 2, 3, 4, 5, 6, 7 });
testing.expect(packed_array_be.bytes[0] == 0b00000001);
testing.expect(packed_array_be.bytes[1] == 0b00100011);
@@ -563,16 +554,7 @@ test "PackedInt(Array/Slice)Endian" {
{
const PackedArrayBe = PackedIntArrayEndian(u11, .Big, 8);
- var packed_array_be = PackedArrayBe.init([_]u11{
- 0,
- 1,
- 2,
- 3,
- 4,
- 5,
- 6,
- 7,
- });
+ var packed_array_be = PackedArrayBe.init([_]u11{ 0, 1, 2, 3, 4, 5, 6, 7 });
testing.expect(packed_array_be.bytes[0] == 0b00000000);
testing.expect(packed_array_be.bytes[1] == 0b00000000);
testing.expect(packed_array_be.bytes[2] == 0b00000100);
diff --git a/lib/std/pdb.zig b/lib/std/pdb.zig
index 2a21f6c43c..4b9b3a2a65 100644
--- a/lib/std/pdb.zig
+++ b/lib/std/pdb.zig
@@ -501,7 +501,7 @@ const Msf = struct {
const superblock = try in.readStruct(SuperBlock);
// Sanity checks
- if (!mem.eql(u8, superblock.FileMagic, SuperBlock.file_magic))
+ if (!mem.eql(u8, &superblock.FileMagic, SuperBlock.file_magic))
return error.InvalidDebugInfo;
if (superblock.FreeBlockMapBlock != 1 and superblock.FreeBlockMapBlock != 2)
return error.InvalidDebugInfo;
@@ -547,7 +547,7 @@ const Msf = struct {
const size = stream_sizes[i];
if (size == 0) {
stream.* = MsfStream{
- .blocks = [_]u32{},
+ .blocks = &[_]u32{},
};
} else {
var blocks = try allocator.alloc(u32, size);
diff --git a/lib/std/priority_queue.zig b/lib/std/priority_queue.zig
index bf54f6937f..3351ac994b 100644
--- a/lib/std/priority_queue.zig
+++ b/lib/std/priority_queue.zig
@@ -22,7 +22,7 @@ pub fn PriorityQueue(comptime T: type) type {
/// `fn lessThan(a: T, b: T) bool { return a < b; }`
pub fn init(allocator: *Allocator, compareFn: fn (a: T, b: T) bool) Self {
return Self{
- .items = [_]T{},
+ .items = &[_]T{},
.len = 0,
.allocator = allocator,
.compareFn = compareFn,
diff --git a/lib/std/process.zig b/lib/std/process.zig
index e432be213f..0ce3cabc19 100644
--- a/lib/std/process.zig
+++ b/lib/std/process.zig
@@ -473,14 +473,14 @@ pub fn argsFree(allocator: *mem.Allocator, args_alloc: []const []u8) void {
}
test "windows arg parsing" {
- testWindowsCmdLine("a b\tc d", [_][]const u8{ "a", "b", "c", "d" });
- testWindowsCmdLine("\"abc\" d e", [_][]const u8{ "abc", "d", "e" });
- testWindowsCmdLine("a\\\\\\b d\"e f\"g h", [_][]const u8{ "a\\\\\\b", "de fg", "h" });
- testWindowsCmdLine("a\\\\\\\"b c d", [_][]const u8{ "a\\\"b", "c", "d" });
- testWindowsCmdLine("a\\\\\\\\\"b c\" d e", [_][]const u8{ "a\\\\b c", "d", "e" });
- testWindowsCmdLine("a b\tc \"d f", [_][]const u8{ "a", "b", "c", "\"d", "f" });
-
- testWindowsCmdLine("\".\\..\\zig-cache\\build\" \"bin\\zig.exe\" \".\\..\" \".\\..\\zig-cache\" \"--help\"", [_][]const u8{
+ testWindowsCmdLine("a b\tc d", &[_][]const u8{ "a", "b", "c", "d" });
+ testWindowsCmdLine("\"abc\" d e", &[_][]const u8{ "abc", "d", "e" });
+ testWindowsCmdLine("a\\\\\\b d\"e f\"g h", &[_][]const u8{ "a\\\\\\b", "de fg", "h" });
+ testWindowsCmdLine("a\\\\\\\"b c d", &[_][]const u8{ "a\\\"b", "c", "d" });
+ testWindowsCmdLine("a\\\\\\\\\"b c\" d e", &[_][]const u8{ "a\\\\b c", "d", "e" });
+ testWindowsCmdLine("a b\tc \"d f", &[_][]const u8{ "a", "b", "c", "\"d", "f" });
+
+ testWindowsCmdLine("\".\\..\\zig-cache\\build\" \"bin\\zig.exe\" \".\\..\" \".\\..\\zig-cache\" \"--help\"", &[_][]const u8{
".\\..\\zig-cache\\build",
"bin\\zig.exe",
".\\..",
diff --git a/lib/std/rand.zig b/lib/std/rand.zig
index 1fea0526ed..f9fa4a2d66 100644
--- a/lib/std/rand.zig
+++ b/lib/std/rand.zig
@@ -54,7 +54,7 @@ pub const Random = struct {
// use LE instead of native endian for better portability maybe?
// TODO: endian portability is pointless if the underlying prng isn't endian portable.
// TODO: document the endian portability of this library.
- const byte_aligned_result = mem.readIntSliceLittle(ByteAlignedT, rand_bytes);
+ const byte_aligned_result = mem.readIntSliceLittle(ByteAlignedT, &rand_bytes);
const unsigned_result = @truncate(UnsignedT, byte_aligned_result);
return @bitCast(T, unsigned_result);
}
diff --git a/lib/std/segmented_list.zig b/lib/std/segmented_list.zig
index e74b17dd5c..8c5ded3647 100644
--- a/lib/std/segmented_list.zig
+++ b/lib/std/segmented_list.zig
@@ -112,7 +112,7 @@ pub fn SegmentedList(comptime T: type, comptime prealloc_item_count: usize) type
.allocator = allocator,
.len = 0,
.prealloc_segment = undefined,
- .dynamic_segments = [_][*]T{},
+ .dynamic_segments = &[_][*]T{},
};
}
@@ -192,7 +192,7 @@ pub fn SegmentedList(comptime T: type, comptime prealloc_item_count: usize) type
const len = @intCast(ShelfIndex, self.dynamic_segments.len);
self.freeShelves(len, 0);
self.allocator.free(self.dynamic_segments);
- self.dynamic_segments = [_][*]T{};
+ self.dynamic_segments = &[_][*]T{};
return;
}
@@ -385,18 +385,14 @@ fn testSegmentedList(comptime prealloc: usize, allocator: *Allocator) !void {
testing.expect(list.pop().? == 100);
testing.expect(list.len == 99);
- try list.pushMany([_]i32{
- 1,
- 2,
- 3,
- });
+ try list.pushMany(&[_]i32{ 1, 2, 3 });
testing.expect(list.len == 102);
testing.expect(list.pop().? == 3);
testing.expect(list.pop().? == 2);
testing.expect(list.pop().? == 1);
testing.expect(list.len == 99);
- try list.pushMany([_]i32{});
+ try list.pushMany(&[_]i32{});
testing.expect(list.len == 99);
var i: i32 = 99;
diff --git a/lib/std/sort.zig b/lib/std/sort.zig
index 790fd46756..f8b8a39134 100644
--- a/lib/std/sort.zig
+++ b/lib/std/sort.zig
@@ -1043,27 +1043,27 @@ fn cmpByValue(a: IdAndValue, b: IdAndValue) bool {
test "std.sort" {
const u8cases = [_][]const []const u8{
- [_][]const u8{
+ &[_][]const u8{
"",
"",
},
- [_][]const u8{
+ &[_][]const u8{
"a",
"a",
},
- [_][]const u8{
+ &[_][]const u8{
"az",
"az",
},
- [_][]const u8{
+ &[_][]const u8{
"za",
"az",
},
- [_][]const u8{
+ &[_][]const u8{
"asdf",
"adfs",
},
- [_][]const u8{
+ &[_][]const u8{
"one",
"eno",
},
@@ -1078,29 +1078,29 @@ test "std.sort" {
}
const i32cases = [_][]const []const i32{
- [_][]const i32{
- [_]i32{},
- [_]i32{},
+ &[_][]const i32{
+ &[_]i32{},
+ &[_]i32{},
},
- [_][]const i32{
- [_]i32{1},
- [_]i32{1},
+ &[_][]const i32{
+ &[_]i32{1},
+ &[_]i32{1},
},
- [_][]const i32{
- [_]i32{ 0, 1 },
- [_]i32{ 0, 1 },
+ &[_][]const i32{
+ &[_]i32{ 0, 1 },
+ &[_]i32{ 0, 1 },
},
- [_][]const i32{
- [_]i32{ 1, 0 },
- [_]i32{ 0, 1 },
+ &[_][]const i32{
+ &[_]i32{ 1, 0 },
+ &[_]i32{ 0, 1 },
},
- [_][]const i32{
- [_]i32{ 1, -1, 0 },
- [_]i32{ -1, 0, 1 },
+ &[_][]const i32{
+ &[_]i32{ 1, -1, 0 },
+ &[_]i32{ -1, 0, 1 },
},
- [_][]const i32{
- [_]i32{ 2, 1, 3 },
- [_]i32{ 1, 2, 3 },
+ &[_][]const i32{
+ &[_]i32{ 2, 1, 3 },
+ &[_]i32{ 1, 2, 3 },
},
};
@@ -1115,29 +1115,29 @@ test "std.sort" {
test "std.sort descending" {
const rev_cases = [_][]const []const i32{
- [_][]const i32{
- [_]i32{},
- [_]i32{},
+ &[_][]const i32{
+ &[_]i32{},
+ &[_]i32{},
},
- [_][]const i32{
- [_]i32{1},
- [_]i32{1},
+ &[_][]const i32{
+ &[_]i32{1},
+ &[_]i32{1},
},
- [_][]const i32{
- [_]i32{ 0, 1 },
- [_]i32{ 1, 0 },
+ &[_][]const i32{
+ &[_]i32{ 0, 1 },
+ &[_]i32{ 1, 0 },
},
- [_][]const i32{
- [_]i32{ 1, 0 },
- [_]i32{ 1, 0 },
+ &[_][]const i32{
+ &[_]i32{ 1, 0 },
+ &[_]i32{ 1, 0 },
},
- [_][]const i32{
- [_]i32{ 1, -1, 0 },
- [_]i32{ 1, 0, -1 },
+ &[_][]const i32{
+ &[_]i32{ 1, -1, 0 },
+ &[_]i32{ 1, 0, -1 },
},
- [_][]const i32{
- [_]i32{ 2, 1, 3 },
- [_]i32{ 3, 2, 1 },
+ &[_][]const i32{
+ &[_]i32{ 2, 1, 3 },
+ &[_]i32{ 3, 2, 1 },
},
};
@@ -1154,7 +1154,7 @@ test "another sort case" {
var arr = [_]i32{ 5, 3, 1, 2, 4 };
sort(i32, arr[0..], asc(i32));
- testing.expect(mem.eql(i32, arr, [_]i32{ 1, 2, 3, 4, 5 }));
+ testing.expect(mem.eql(i32, &arr, &[_]i32{ 1, 2, 3, 4, 5 }));
}
test "sort fuzz testing" {
diff --git a/lib/std/unicode.zig b/lib/std/unicode.zig
index 726b84f125..4af1b63a69 100644
--- a/lib/std/unicode.zig
+++ b/lib/std/unicode.zig
@@ -499,14 +499,14 @@ test "utf16leToUtf8" {
{
mem.writeIntSliceLittle(u16, utf16le_as_bytes[0..], 'A');
mem.writeIntSliceLittle(u16, utf16le_as_bytes[2..], 'a');
- const utf8 = try utf16leToUtf8Alloc(std.debug.global_allocator, utf16le);
+ const utf8 = try utf16leToUtf8Alloc(std.debug.global_allocator, &utf16le);
testing.expect(mem.eql(u8, utf8, "Aa"));
}
{
mem.writeIntSliceLittle(u16, utf16le_as_bytes[0..], 0x80);
mem.writeIntSliceLittle(u16, utf16le_as_bytes[2..], 0xffff);
- const utf8 = try utf16leToUtf8Alloc(std.debug.global_allocator, utf16le);
+ const utf8 = try utf16leToUtf8Alloc(std.debug.global_allocator, &utf16le);
testing.expect(mem.eql(u8, utf8, "\xc2\x80" ++ "\xef\xbf\xbf"));
}
@@ -514,7 +514,7 @@ test "utf16leToUtf8" {
// the values just outside the surrogate half range
mem.writeIntSliceLittle(u16, utf16le_as_bytes[0..], 0xd7ff);
mem.writeIntSliceLittle(u16, utf16le_as_bytes[2..], 0xe000);
- const utf8 = try utf16leToUtf8Alloc(std.debug.global_allocator, utf16le);
+ const utf8 = try utf16leToUtf8Alloc(std.debug.global_allocator, &utf16le);
testing.expect(mem.eql(u8, utf8, "\xed\x9f\xbf" ++ "\xee\x80\x80"));
}
@@ -522,7 +522,7 @@ test "utf16leToUtf8" {
// smallest surrogate pair
mem.writeIntSliceLittle(u16, utf16le_as_bytes[0..], 0xd800);
mem.writeIntSliceLittle(u16, utf16le_as_bytes[2..], 0xdc00);
- const utf8 = try utf16leToUtf8Alloc(std.debug.global_allocator, utf16le);
+ const utf8 = try utf16leToUtf8Alloc(std.debug.global_allocator, &utf16le);
testing.expect(mem.eql(u8, utf8, "\xf0\x90\x80\x80"));
}
@@ -530,14 +530,14 @@ test "utf16leToUtf8" {
// largest surrogate pair
mem.writeIntSliceLittle(u16, utf16le_as_bytes[0..], 0xdbff);
mem.writeIntSliceLittle(u16, utf16le_as_bytes[2..], 0xdfff);
- const utf8 = try utf16leToUtf8Alloc(std.debug.global_allocator, utf16le);
+ const utf8 = try utf16leToUtf8Alloc(std.debug.global_allocator, &utf16le);
testing.expect(mem.eql(u8, utf8, "\xf4\x8f\xbf\xbf"));
}
{
mem.writeIntSliceLittle(u16, utf16le_as_bytes[0..], 0xdbff);
mem.writeIntSliceLittle(u16, utf16le_as_bytes[2..], 0xdc00);
- const utf8 = try utf16leToUtf8Alloc(std.debug.global_allocator, utf16le);
+ const utf8 = try utf16leToUtf8Alloc(std.debug.global_allocator, &utf16le);
testing.expect(mem.eql(u8, utf8, "\xf4\x8f\xb0\x80"));
}
}
diff --git a/lib/std/zig/tokenizer.zig b/lib/std/zig/tokenizer.zig
index 0b2aea4cf6..e7d2b41784 100644
--- a/lib/std/zig/tokenizer.zig
+++ b/lib/std/zig/tokenizer.zig
@@ -1313,14 +1313,14 @@ pub const Tokenizer = struct {
};
test "tokenizer" {
- testTokenize("test", [_]Token.Id{Token.Id.Keyword_test});
+ testTokenize("test", &[_]Token.Id{Token.Id.Keyword_test});
}
test "tokenizer - unknown length pointer and then c pointer" {
testTokenize(
\\[*]u8
\\[*c]u8
- , [_]Token.Id{
+ , &[_]Token.Id{
Token.Id.LBracket,
Token.Id.Asterisk,
Token.Id.RBracket,
@@ -1336,70 +1336,70 @@ test "tokenizer - unknown length pointer and then c pointer" {
test "tokenizer - char literal with hex escape" {
testTokenize(
\\'\x1b'
- , [_]Token.Id{.CharLiteral});
+ , &[_]Token.Id{.CharLiteral});
testTokenize(
\\'\x1'
- , [_]Token.Id{ .Invalid, .Invalid });
+ , &[_]Token.Id{ .Invalid, .Invalid });
}
test "tokenizer - char literal with unicode escapes" {
// Valid unicode escapes
testTokenize(
\\'\u{3}'
- , [_]Token.Id{.CharLiteral});
+ , &[_]Token.Id{.CharLiteral});
testTokenize(
\\'\u{01}'
- , [_]Token.Id{.CharLiteral});
+ , &[_]Token.Id{.CharLiteral});
testTokenize(
\\'\u{2a}'
- , [_]Token.Id{.CharLiteral});
+ , &[_]Token.Id{.CharLiteral});
testTokenize(
\\'\u{3f9}'
- , [_]Token.Id{.CharLiteral});
+ , &[_]Token.Id{.CharLiteral});
testTokenize(
\\'\u{6E09aBc1523}'
- , [_]Token.Id{.CharLiteral});
+ , &[_]Token.Id{.CharLiteral});
testTokenize(
\\"\u{440}"
- , [_]Token.Id{.StringLiteral});
+ , &[_]Token.Id{.StringLiteral});
// Invalid unicode escapes
testTokenize(
\\'\u'
- , [_]Token.Id{.Invalid});
+ , &[_]Token.Id{.Invalid});
testTokenize(
\\'\u{{'
- , [_]Token.Id{ .Invalid, .Invalid });
+ , &[_]Token.Id{ .Invalid, .Invalid });
testTokenize(
\\'\u{}'
- , [_]Token.Id{ .Invalid, .Invalid });
+ , &[_]Token.Id{ .Invalid, .Invalid });
testTokenize(
\\'\u{s}'
- , [_]Token.Id{ .Invalid, .Invalid });
+ , &[_]Token.Id{ .Invalid, .Invalid });
testTokenize(
\\'\u{2z}'
- , [_]Token.Id{ .Invalid, .Invalid });
+ , &[_]Token.Id{ .Invalid, .Invalid });
testTokenize(
\\'\u{4a'
- , [_]Token.Id{.Invalid});
+ , &[_]Token.Id{.Invalid});
// Test old-style unicode literals
testTokenize(
\\'\u0333'
- , [_]Token.Id{ .Invalid, .Invalid });
+ , &[_]Token.Id{ .Invalid, .Invalid });
testTokenize(
\\'\U0333'
- , [_]Token.Id{ .Invalid, .IntegerLiteral, .Invalid });
+ , &[_]Token.Id{ .Invalid, .IntegerLiteral, .Invalid });
}
test "tokenizer - char literal with unicode code point" {
testTokenize(
\\'💩'
- , [_]Token.Id{.CharLiteral});
+ , &[_]Token.Id{.CharLiteral});
}
test "tokenizer - float literal e exponent" {
- testTokenize("a = 4.94065645841246544177e-324;\n", [_]Token.Id{
+ testTokenize("a = 4.94065645841246544177e-324;\n", &[_]Token.Id{
Token.Id.Identifier,
Token.Id.Equal,
Token.Id.FloatLiteral,
@@ -1408,7 +1408,7 @@ test "tokenizer - float literal e exponent" {
}
test "tokenizer - float literal p exponent" {
- testTokenize("a = 0x1.a827999fcef32p+1022;\n", [_]Token.Id{
+ testTokenize("a = 0x1.a827999fcef32p+1022;\n", &[_]Token.Id{
Token.Id.Identifier,
Token.Id.Equal,
Token.Id.FloatLiteral,
@@ -1417,71 +1417,71 @@ test "tokenizer - float literal p exponent" {
}
test "tokenizer - chars" {
- testTokenize("'c'", [_]Token.Id{Token.Id.CharLiteral});
+ testTokenize("'c'", &[_]Token.Id{Token.Id.CharLiteral});
}
test "tokenizer - invalid token characters" {
- testTokenize("#", [_]Token.Id{Token.Id.Invalid});
- testTokenize("`", [_]Token.Id{Token.Id.Invalid});
- testTokenize("'c", [_]Token.Id{Token.Id.Invalid});
- testTokenize("'", [_]Token.Id{Token.Id.Invalid});
- testTokenize("''", [_]Token.Id{ Token.Id.Invalid, Token.Id.Invalid });
+ testTokenize("#", &[_]Token.Id{Token.Id.Invalid});
+ testTokenize("`", &[_]Token.Id{Token.Id.Invalid});
+ testTokenize("'c", &[_]Token.Id{Token.Id.Invalid});
+ testTokenize("'", &[_]Token.Id{Token.Id.Invalid});
+ testTokenize("''", &[_]Token.Id{ Token.Id.Invalid, Token.Id.Invalid });
}
test "tokenizer - invalid literal/comment characters" {
- testTokenize("\"\x00\"", [_]Token.Id{
+ testTokenize("\"\x00\"", &[_]Token.Id{
Token.Id.StringLiteral,
Token.Id.Invalid,
});
- testTokenize("//\x00", [_]Token.Id{
+ testTokenize("//\x00", &[_]Token.Id{
Token.Id.LineComment,
Token.Id.Invalid,
});
- testTokenize("//\x1f", [_]Token.Id{
+ testTokenize("//\x1f", &[_]Token.Id{
Token.Id.LineComment,
Token.Id.Invalid,
});
- testTokenize("//\x7f", [_]Token.Id{
+ testTokenize("//\x7f", &[_]Token.Id{
Token.Id.LineComment,
Token.Id.Invalid,
});
}
test "tokenizer - utf8" {
- testTokenize("//\xc2\x80", [_]Token.Id{Token.Id.LineComment});
- testTokenize("//\xf4\x8f\xbf\xbf", [_]Token.Id{Token.Id.LineComment});
+ testTokenize("//\xc2\x80", &[_]Token.Id{Token.Id.LineComment});
+ testTokenize("//\xf4\x8f\xbf\xbf", &[_]Token.Id{Token.Id.LineComment});
}
test "tokenizer - invalid utf8" {
- testTokenize("//\x80", [_]Token.Id{
+ testTokenize("//\x80", &[_]Token.Id{
Token.Id.LineComment,
Token.Id.Invalid,
});
- testTokenize("//\xbf", [_]Token.Id{
+ testTokenize("//\xbf", &[_]Token.Id{
Token.Id.LineComment,
Token.Id.Invalid,
});
- testTokenize("//\xf8", [_]Token.Id{
+ testTokenize("//\xf8", &[_]Token.Id{
Token.Id.LineComment,
Token.Id.Invalid,
});
- testTokenize("//\xff", [_]Token.Id{
+ testTokenize("//\xff", &[_]Token.Id{
Token.Id.LineComment,
Token.Id.Invalid,
});
- testTokenize("//\xc2\xc0", [_]Token.Id{
+ testTokenize("//\xc2\xc0", &[_]Token.Id{
Token.Id.LineComment,
Token.Id.Invalid,
});
- testTokenize("//\xe0", [_]Token.Id{
+ testTokenize("//\xe0", &[_]Token.Id{
Token.Id.LineComment,
Token.Id.Invalid,
});
- testTokenize("//\xf0", [_]Token.Id{
+ testTokenize("//\xf0", &[_]Token.Id{
Token.Id.LineComment,
Token.Id.Invalid,
});
- testTokenize("//\xf0\x90\x80\xc0", [_]Token.Id{
+ testTokenize("//\xf0\x90\x80\xc0", &[_]Token.Id{
Token.Id.LineComment,
Token.Id.Invalid,
});
@@ -1489,28 +1489,28 @@ test "tokenizer - invalid utf8" {
test "tokenizer - illegal unicode codepoints" {
// unicode newline characters.U+0085, U+2028, U+2029
- testTokenize("//\xc2\x84", [_]Token.Id{Token.Id.LineComment});
- testTokenize("//\xc2\x85", [_]Token.Id{
+ testTokenize("//\xc2\x84", &[_]Token.Id{Token.Id.LineComment});
+ testTokenize("//\xc2\x85", &[_]Token.Id{
Token.Id.LineComment,
Token.Id.Invalid,
});
- testTokenize("//\xc2\x86", [_]Token.Id{Token.Id.LineComment});
- testTokenize("//\xe2\x80\xa7", [_]Token.Id{Token.Id.LineComment});
- testTokenize("//\xe2\x80\xa8", [_]Token.Id{
+ testTokenize("//\xc2\x86", &[_]Token.Id{Token.Id.LineComment});
+ testTokenize("//\xe2\x80\xa7", &[_]Token.Id{Token.Id.LineComment});
+ testTokenize("//\xe2\x80\xa8", &[_]Token.Id{
Token.Id.LineComment,
Token.Id.Invalid,
});
- testTokenize("//\xe2\x80\xa9", [_]Token.Id{
+ testTokenize("//\xe2\x80\xa9", &[_]Token.Id{
Token.Id.LineComment,
Token.Id.Invalid,
});
- testTokenize("//\xe2\x80\xaa", [_]Token.Id{Token.Id.LineComment});
+ testTokenize("//\xe2\x80\xaa", &[_]Token.Id{Token.Id.LineComment});
}
test "tokenizer - string identifier and builtin fns" {
testTokenize(
\\const @"if" = @import("std");
- , [_]Token.Id{
+ , &[_]Token.Id{
Token.Id.Keyword_const,
Token.Id.Identifier,
Token.Id.Equal,
@@ -1523,21 +1523,21 @@ test "tokenizer - string identifier and builtin fns" {
}
test "tokenizer - pipe and then invalid" {
- testTokenize("||=", [_]Token.Id{
+ testTokenize("||=", &[_]Token.Id{
Token.Id.PipePipe,
Token.Id.Equal,
});
}
test "tokenizer - line comment and doc comment" {
- testTokenize("//", [_]Token.Id{Token.Id.LineComment});
- testTokenize("// a / b", [_]Token.Id{Token.Id.LineComment});
- testTokenize("// /", [_]Token.Id{Token.Id.LineComment});
- testTokenize("/// a", [_]Token.Id{Token.Id.DocComment});
- testTokenize("///", [_]Token.Id{Token.Id.DocComment});
- testTokenize("////", [_]Token.Id{Token.Id.LineComment});
- testTokenize("//!", [_]Token.Id{Token.Id.ContainerDocComment});
- testTokenize("//!!", [_]Token.Id{Token.Id.ContainerDocComment});
+ testTokenize("//", &[_]Token.Id{Token.Id.LineComment});
+ testTokenize("// a / b", &[_]Token.Id{Token.Id.LineComment});
+ testTokenize("// /", &[_]Token.Id{Token.Id.LineComment});
+ testTokenize("/// a", &[_]Token.Id{Token.Id.DocComment});
+ testTokenize("///", &[_]Token.Id{Token.Id.DocComment});
+ testTokenize("////", &[_]Token.Id{Token.Id.LineComment});
+ testTokenize("//!", &[_]Token.Id{Token.Id.ContainerDocComment});
+ testTokenize("//!!", &[_]Token.Id{Token.Id.ContainerDocComment});
}
test "tokenizer - line comment followed by identifier" {
@@ -1545,7 +1545,7 @@ test "tokenizer - line comment followed by identifier" {
\\ Unexpected,
\\ // another
\\ Another,
- , [_]Token.Id{
+ , &[_]Token.Id{
Token.Id.Identifier,
Token.Id.Comma,
Token.Id.LineComment,
@@ -1555,14 +1555,14 @@ test "tokenizer - line comment followed by identifier" {
}
test "tokenizer - UTF-8 BOM is recognized and skipped" {
- testTokenize("\xEF\xBB\xBFa;\n", [_]Token.Id{
+ testTokenize("\xEF\xBB\xBFa;\n", &[_]Token.Id{
Token.Id.Identifier,
Token.Id.Semicolon,
});
}
test "correctly parse pointer assignment" {
- testTokenize("b.*=3;\n", [_]Token.Id{
+ testTokenize("b.*=3;\n", &[_]Token.Id{
Token.Id.Identifier,
Token.Id.PeriodAsterisk,
Token.Id.Equal,