Skip to content

Commit fecd540

Browse files
authored
Merge pull request #3787 from ziglang/remove-array-type-coercion
Remove array type coercion and fix result location bugs
2 parents 4b6740e + e7ee664 commit fecd540

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

96 files changed

+1230
-1148
lines changed

build.zig

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ pub fn build(b: *Builder) !void {
2020
const rel_zig_exe = try fs.path.relative(b.allocator, b.build_root, b.zig_exe);
2121
const langref_out_path = fs.path.join(
2222
b.allocator,
23-
[_][]const u8{ b.cache_root, "langref.html" },
23+
&[_][]const u8{ b.cache_root, "langref.html" },
2424
) catch unreachable;
2525
var docgen_cmd = docgen_exe.run();
26-
docgen_cmd.addArgs([_][]const u8{
26+
docgen_cmd.addArgs(&[_][]const u8{
2727
rel_zig_exe,
2828
"doc" ++ fs.path.sep_str ++ "langref.html.in",
2929
langref_out_path,
@@ -36,7 +36,7 @@ pub fn build(b: *Builder) !void {
3636
const test_step = b.step("test", "Run all the tests");
3737

3838
// find the stage0 build artifacts because we're going to re-use config.h and zig_cpp library
39-
const build_info = try b.exec([_][]const u8{
39+
const build_info = try b.exec(&[_][]const u8{
4040
b.zig_exe,
4141
"BUILD_INFO",
4242
});
@@ -56,7 +56,7 @@ pub fn build(b: *Builder) !void {
5656
test_stage2.setBuildMode(builtin.Mode.Debug);
5757
test_stage2.addPackagePath("stage2_tests", "test/stage2/test.zig");
5858

59-
const fmt_build_zig = b.addFmt([_][]const u8{"build.zig"});
59+
const fmt_build_zig = b.addFmt(&[_][]const u8{"build.zig"});
6060

6161
var exe = b.addExecutable("zig", "src-self-hosted/main.zig");
6262
exe.setBuildMode(mode);
@@ -88,7 +88,7 @@ pub fn build(b: *Builder) !void {
8888
.source_dir = "lib",
8989
.install_dir = .Lib,
9090
.install_subdir = "zig",
91-
.exclude_extensions = [_][]const u8{ "test.zig", "README.md" },
91+
.exclude_extensions = &[_][]const u8{ "test.zig", "README.md" },
9292
});
9393

9494
const test_filter = b.option([]const u8, "test-filter", "Skip tests that do not match filter");
@@ -148,7 +148,7 @@ fn dependOnLib(b: *Builder, lib_exe_obj: var, dep: LibraryDep) void {
148148
}
149149
const lib_dir = fs.path.join(
150150
b.allocator,
151-
[_][]const u8{ dep.prefix, "lib" },
151+
&[_][]const u8{ dep.prefix, "lib" },
152152
) catch unreachable;
153153
for (dep.system_libs.toSliceConst()) |lib| {
154154
const static_bare_name = if (mem.eql(u8, lib, "curses"))
@@ -157,7 +157,7 @@ fn dependOnLib(b: *Builder, lib_exe_obj: var, dep: LibraryDep) void {
157157
b.fmt("lib{}.a", lib);
158158
const static_lib_name = fs.path.join(
159159
b.allocator,
160-
[_][]const u8{ lib_dir, static_bare_name },
160+
&[_][]const u8{ lib_dir, static_bare_name },
161161
) catch unreachable;
162162
const have_static = fileExists(static_lib_name) catch unreachable;
163163
if (have_static) {
@@ -183,7 +183,7 @@ fn fileExists(filename: []const u8) !bool {
183183
}
184184

185185
fn addCppLib(b: *Builder, lib_exe_obj: var, cmake_binary_dir: []const u8, lib_name: []const u8) void {
186-
lib_exe_obj.addObjectFile(fs.path.join(b.allocator, [_][]const u8{
186+
lib_exe_obj.addObjectFile(fs.path.join(b.allocator, &[_][]const u8{
187187
cmake_binary_dir,
188188
"zig_cpp",
189189
b.fmt("{}{}{}", lib_exe_obj.target.libPrefix(), lib_name, lib_exe_obj.target.staticLibSuffix()),
@@ -199,22 +199,22 @@ const LibraryDep = struct {
199199
};
200200

201201
fn findLLVM(b: *Builder, llvm_config_exe: []const u8) !LibraryDep {
202-
const shared_mode = try b.exec([_][]const u8{ llvm_config_exe, "--shared-mode" });
202+
const shared_mode = try b.exec(&[_][]const u8{ llvm_config_exe, "--shared-mode" });
203203
const is_static = mem.startsWith(u8, shared_mode, "static");
204204
const libs_output = if (is_static)
205-
try b.exec([_][]const u8{
205+
try b.exec(&[_][]const u8{
206206
llvm_config_exe,
207207
"--libfiles",
208208
"--system-libs",
209209
})
210210
else
211-
try b.exec([_][]const u8{
211+
try b.exec(&[_][]const u8{
212212
llvm_config_exe,
213213
"--libs",
214214
});
215-
const includes_output = try b.exec([_][]const u8{ llvm_config_exe, "--includedir" });
216-
const libdir_output = try b.exec([_][]const u8{ llvm_config_exe, "--libdir" });
217-
const prefix_output = try b.exec([_][]const u8{ llvm_config_exe, "--prefix" });
215+
const includes_output = try b.exec(&[_][]const u8{ llvm_config_exe, "--includedir" });
216+
const libdir_output = try b.exec(&[_][]const u8{ llvm_config_exe, "--libdir" });
217+
const prefix_output = try b.exec(&[_][]const u8{ llvm_config_exe, "--prefix" });
218218

219219
var result = LibraryDep{
220220
.prefix = mem.tokenize(prefix_output, " \r\n").next().?,
@@ -341,7 +341,7 @@ fn addCxxKnownPath(
341341
objname: []const u8,
342342
errtxt: ?[]const u8,
343343
) !void {
344-
const path_padded = try b.exec([_][]const u8{
344+
const path_padded = try b.exec(&[_][]const u8{
345345
ctx.cxx_compiler,
346346
b.fmt("-print-file-name={}", objname),
347347
});

doc/docgen.zig

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1039,7 +1039,7 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: var
10391039
const name_plus_ext = try std.fmt.allocPrint(allocator, "{}.zig", code.name);
10401040
const tmp_source_file_name = try fs.path.join(
10411041
allocator,
1042-
[_][]const u8{ tmp_dir_name, name_plus_ext },
1042+
&[_][]const u8{ tmp_dir_name, name_plus_ext },
10431043
);
10441044
try io.writeFile(tmp_source_file_name, trimmed_raw_source);
10451045

@@ -1048,7 +1048,7 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: var
10481048
const name_plus_bin_ext = try std.fmt.allocPrint(allocator, "{}{}", code.name, exe_ext);
10491049
var build_args = std.ArrayList([]const u8).init(allocator);
10501050
defer build_args.deinit();
1051-
try build_args.appendSlice([_][]const u8{
1051+
try build_args.appendSlice(&[_][]const u8{
10521052
zig_exe,
10531053
"build-exe",
10541054
tmp_source_file_name,
@@ -1079,7 +1079,7 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: var
10791079
const name_with_ext = try std.fmt.allocPrint(allocator, "{}{}", link_object, obj_ext);
10801080
const full_path_object = try fs.path.join(
10811081
allocator,
1082-
[_][]const u8{ tmp_dir_name, name_with_ext },
1082+
&[_][]const u8{ tmp_dir_name, name_with_ext },
10831083
);
10841084
try build_args.append("--object");
10851085
try build_args.append(full_path_object);
@@ -1090,7 +1090,7 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: var
10901090
try out.print(" -lc");
10911091
}
10921092
if (code.target_str) |triple| {
1093-
try build_args.appendSlice([_][]const u8{ "-target", triple });
1093+
try build_args.appendSlice(&[_][]const u8{ "-target", triple });
10941094
if (!code.is_inline) {
10951095
try out.print(" -target {}", triple);
10961096
}
@@ -1143,7 +1143,7 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: var
11431143
}
11441144

11451145
const path_to_exe = mem.trim(u8, exec_result.stdout, " \r\n");
1146-
const run_args = [_][]const u8{path_to_exe};
1146+
const run_args = &[_][]const u8{path_to_exe};
11471147

11481148
var exited_with_signal = false;
11491149

@@ -1184,7 +1184,7 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: var
11841184
var test_args = std.ArrayList([]const u8).init(allocator);
11851185
defer test_args.deinit();
11861186

1187-
try test_args.appendSlice([_][]const u8{
1187+
try test_args.appendSlice(&[_][]const u8{
11881188
zig_exe,
11891189
"test",
11901190
tmp_source_file_name,
@@ -1212,7 +1212,7 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: var
12121212
try out.print(" -lc");
12131213
}
12141214
if (code.target_str) |triple| {
1215-
try test_args.appendSlice([_][]const u8{ "-target", triple });
1215+
try test_args.appendSlice(&[_][]const u8{ "-target", triple });
12161216
try out.print(" -target {}", triple);
12171217
}
12181218
const result = exec(allocator, &env_map, test_args.toSliceConst()) catch return parseError(tokenizer, code.source_token, "test failed");
@@ -1224,7 +1224,7 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: var
12241224
var test_args = std.ArrayList([]const u8).init(allocator);
12251225
defer test_args.deinit();
12261226

1227-
try test_args.appendSlice([_][]const u8{
1227+
try test_args.appendSlice(&[_][]const u8{
12281228
zig_exe,
12291229
"test",
12301230
"--color",
@@ -1283,7 +1283,7 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: var
12831283
var test_args = std.ArrayList([]const u8).init(allocator);
12841284
defer test_args.deinit();
12851285

1286-
try test_args.appendSlice([_][]const u8{
1286+
try test_args.appendSlice(&[_][]const u8{
12871287
zig_exe,
12881288
"test",
12891289
tmp_source_file_name,
@@ -1345,18 +1345,18 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: var
13451345
const name_plus_obj_ext = try std.fmt.allocPrint(allocator, "{}{}", code.name, obj_ext);
13461346
const tmp_obj_file_name = try fs.path.join(
13471347
allocator,
1348-
[_][]const u8{ tmp_dir_name, name_plus_obj_ext },
1348+
&[_][]const u8{ tmp_dir_name, name_plus_obj_ext },
13491349
);
13501350
var build_args = std.ArrayList([]const u8).init(allocator);
13511351
defer build_args.deinit();
13521352

13531353
const name_plus_h_ext = try std.fmt.allocPrint(allocator, "{}.h", code.name);
13541354
const output_h_file_name = try fs.path.join(
13551355
allocator,
1356-
[_][]const u8{ tmp_dir_name, name_plus_h_ext },
1356+
&[_][]const u8{ tmp_dir_name, name_plus_h_ext },
13571357
);
13581358

1359-
try build_args.appendSlice([_][]const u8{
1359+
try build_args.appendSlice(&[_][]const u8{
13601360
zig_exe,
13611361
"build-obj",
13621362
tmp_source_file_name,
@@ -1395,7 +1395,7 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: var
13951395
}
13961396

13971397
if (code.target_str) |triple| {
1398-
try build_args.appendSlice([_][]const u8{ "-target", triple });
1398+
try build_args.appendSlice(&[_][]const u8{ "-target", triple });
13991399
try out.print(" -target {}", triple);
14001400
}
14011401

@@ -1442,7 +1442,7 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: var
14421442
var test_args = std.ArrayList([]const u8).init(allocator);
14431443
defer test_args.deinit();
14441444

1445-
try test_args.appendSlice([_][]const u8{
1445+
try test_args.appendSlice(&[_][]const u8{
14461446
zig_exe,
14471447
"build-lib",
14481448
tmp_source_file_name,
@@ -1466,7 +1466,7 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: var
14661466
},
14671467
}
14681468
if (code.target_str) |triple| {
1469-
try test_args.appendSlice([_][]const u8{ "-target", triple });
1469+
try test_args.appendSlice(&[_][]const u8{ "-target", triple });
14701470
try out.print(" -target {}", triple);
14711471
}
14721472
const result = exec(allocator, &env_map, test_args.toSliceConst()) catch return parseError(tokenizer, code.source_token, "test failed");
@@ -1507,7 +1507,7 @@ fn exec(allocator: *mem.Allocator, env_map: *std.BufMap, args: []const []const u
15071507
}
15081508

15091509
fn getBuiltinCode(allocator: *mem.Allocator, env_map: *std.BufMap, zig_exe: []const u8) ![]const u8 {
1510-
const result = try exec(allocator, env_map, [_][]const u8{
1510+
const result = try exec(allocator, env_map, &[_][]const u8{
15111511
zig_exe,
15121512
"builtin",
15131513
});

0 commit comments

Comments
 (0)