authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-12-01 21:27:55-05:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-12-01 21:27:55-05:00
log37caa56fbc04d314aa8fe5df6bc80c42d879dd7e
treef1b64879d38563b2cc49ec742d33b95d24427e40
parentc32e50f5058dd3720db24706391c994545d13640
signaturelock-open Commit is signed but in an unrecognized format.

fix docs regressions


3 files changed, 38 insertions(+), 37 deletions(-)

doc/docgen.zig+16-16
......@@ -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,7 +1345,7 @@ 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();
......@@ -1353,10 +1353,10 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: var
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
15091509fn 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 });
doc/langref.html.in+21-21
......@@ -1518,7 +1518,7 @@ value == null{#endsyntax#}</pre>
15181518const array1 = [_]u32{1,2};
15191519const array2 = [_]u32{3,4};
15201520const together = array1 ++ array2;
1521mem.eql(u32, together, [_]u32{1,2,3,4}){#endsyntax#}</pre>
1521mem.eql(u32, together, &[_]u32{1,2,3,4}){#endsyntax#}</pre>
15221522 </td>
15231523 </tr>
15241524 <tr>
......@@ -1621,10 +1621,10 @@ comptime {
16211621}
16221622
16231623// A string literal is a pointer to an array literal.
1624const same_message = "hello".*;
1624const same_message = "hello";
16251625
16261626comptime {
1627 assert(mem.eql(u8, message, same_message));
1627 assert(mem.eql(u8, &message, same_message));
16281628}
16291629
16301630test "iterate over an array" {
......@@ -1652,7 +1652,7 @@ const part_one = [_]i32{ 1, 2, 3, 4 };
16521652const part_two = [_]i32{ 5, 6, 7, 8 };
16531653const all_of_it = part_one ++ part_two;
16541654comptime {
1655 assert(mem.eql(i32, all_of_it, [_]i32{ 1, 2, 3, 4, 5, 6, 7, 8 }));
1655 assert(mem.eql(i32, &all_of_it, &[_]i32{ 1, 2, 3, 4, 5, 6, 7, 8 }));
16561656}
16571657
16581658// remember that string literals are arrays
......@@ -4915,30 +4915,30 @@ const assert = std.debug.assert;
49154915// https://github.com/ziglang/zig/issues/265 is implemented.
49164916test "[N]T to []const T" {
49174917 var x1: []const u8 = "hello";
4918 var x2: []const u8 = [5]u8{ 'h', 'e', 'l', 'l', 111 };
4918 var x2: []const u8 = &[5]u8{ 'h', 'e', 'l', 'l', 111 };
49194919 assert(std.mem.eql(u8, x1, x2));
49204920
4921 var y: []const f32 = [2]f32{ 1.2, 3.4 };
4921 var y: []const f32 = &[2]f32{ 1.2, 3.4 };
49224922 assert(y[0] == 1.2);
49234923}
49244924
49254925// Likewise, it works when the destination type is an error union.
49264926test "[N]T to E![]const T" {
49274927 var x1: anyerror![]const u8 = "hello";
4928 var x2: anyerror![]const u8 = [5]u8{ 'h', 'e', 'l', 'l', 111 };
4928 var x2: anyerror![]const u8 = &[5]u8{ 'h', 'e', 'l', 'l', 111 };
49294929 assert(std.mem.eql(u8, try x1, try x2));
49304930
4931 var y: anyerror![]const f32 = [2]f32{ 1.2, 3.4 };
4931 var y: anyerror![]const f32 = &[2]f32{ 1.2, 3.4 };
49324932 assert((try y)[0] == 1.2);
49334933}
49344934
49354935// Likewise, it works when the destination type is an optional.
49364936test "[N]T to ?[]const T" {
49374937 var x1: ?[]const u8 = "hello";
4938 var x2: ?[]const u8 = [5]u8{ 'h', 'e', 'l', 'l', 111 };
4938 var x2: ?[]const u8 = &[5]u8{ 'h', 'e', 'l', 'l', 111 };
49394939 assert(std.mem.eql(u8, x1.?, x2.?));
49404940
4941 var y: ?[]const f32 = [2]f32{ 1.2, 3.4 };
4941 var y: ?[]const f32 = &[2]f32{ 1.2, 3.4 };
49424942 assert(y.?[0] == 1.2);
49434943}
49444944
......@@ -4950,7 +4950,7 @@ test "*[N]T to []T" {
49504950
49514951 const buf2 = [2]f32{ 1.2, 3.4 };
49524952 const x2: []const f32 = &buf2;
4953 assert(std.mem.eql(f32, x2, [2]f32{ 1.2, 3.4 }));
4953 assert(std.mem.eql(f32, x2, &[2]f32{ 1.2, 3.4 }));
49544954}
49554955
49564956// Single-item pointers to arrays can be coerced to
......@@ -5185,7 +5185,7 @@ fn peerTypeTAndOptionalT(c: bool, b: bool) ?usize {
51855185 return @as(usize, 3);
51865186}
51875187
5188test "peer type resolution: [0]u8 and []const u8" {
5188test "peer type resolution: *[0]u8 and []const u8" {
51895189 assert(peerTypeEmptyArrayAndSlice(true, "hi").len == 0);
51905190 assert(peerTypeEmptyArrayAndSlice(false, "hi").len == 1);
51915191 comptime {
......@@ -5195,12 +5195,12 @@ test "peer type resolution: [0]u8 and []const u8" {
51955195}
51965196fn peerTypeEmptyArrayAndSlice(a: bool, slice: []const u8) []const u8 {
51975197 if (a) {
5198 return [_]u8{};
5198 return &[_]u8{};
51995199 }
52005200
52015201 return slice[0..1];
52025202}
5203test "peer type resolution: [0]u8, []const u8, and anyerror![]u8" {
5203test "peer type resolution: *[0]u8, []const u8, and anyerror![]u8" {
52045204 {
52055205 var data = "hi".*;
52065206 const slice = data[0..];
......@@ -5216,7 +5216,7 @@ test "peer type resolution: [0]u8, []const u8, and anyerror![]u8" {
52165216}
52175217fn peerTypeEmptyArrayAndSliceAndError(a: bool, slice: []u8) anyerror![]u8 {
52185218 if (a) {
5219 return [_]u8{};
5219 return &[_]u8{};
52205220 }
52215221
52225222 return slice[0..1];
......@@ -5746,7 +5746,7 @@ test "fibonacci" {
57465746 </p>
57475747 {#code_begin|test#}
57485748const first_25_primes = firstNPrimes(25);
5749const sum_of_first_25_primes = sum(first_25_primes);
5749const sum_of_first_25_primes = sum(&first_25_primes);
57505750
57515751fn firstNPrimes(comptime n: usize) [n]i32 {
57525752 var prime_list: [n]i32 = undefined;
......@@ -6364,7 +6364,7 @@ test "async function await" {
63646364 resume the_frame;
63656365 seq('i');
63666366 assert(final_result == 1234);
6367 assert(std.mem.eql(u8, seq_points, "abcdefghi"));
6367 assert(std.mem.eql(u8, &seq_points, "abcdefghi"));
63686368}
63696369fn amain() void {
63706370 seq('b');
......@@ -8014,7 +8014,7 @@ test "vector @splat" {
80148014 const scalar: u32 = 5;
80158015 const result = @splat(4, scalar);
80168016 comptime assert(@typeOf(result) == @Vector(4, u32));
8017 assert(std.mem.eql(u32, @as([4]u32, result), [_]u32{ 5, 5, 5, 5 }));
8017 assert(std.mem.eql(u32, &@as([4]u32, result), &[_]u32{ 5, 5, 5, 5 }));
80188018}
80198019 {#code_end#}
80208020 <p>
......@@ -8948,7 +8948,7 @@ pub fn main() void {
89488948 {#code_begin|test_err|unable to convert#}
89498949comptime {
89508950 var bytes = [5]u8{ 1, 2, 3, 4, 5 };
8951 var slice = @bytesToSlice(u32, bytes);
8951 var slice = @bytesToSlice(u32, bytes[0..]);
89528952}
89538953 {#code_end#}
89548954 <p>At runtime:</p>
......@@ -9760,7 +9760,7 @@ pub fn build(b: *Builder) void {
97609760 const lib = b.addSharedLibrary("mathtest", "mathtest.zig", b.version(1, 0, 0));
97619761
97629762 const exe = b.addExecutable("test", null);
9763 exe.addCSourceFile("test.c", [_][]const u8{"-std=c99"});
9763 exe.addCSourceFile("test.c", &[_][]const u8{"-std=c99"});
97649764 exe.linkLibrary(lib);
97659765 exe.linkSystemLibrary("c");
97669766
......@@ -9825,7 +9825,7 @@ pub fn build(b: *Builder) void {
98259825 const obj = b.addObject("base64", "base64.zig");
98269826
98279827 const exe = b.addExecutable("test", null);
9828 exe.addCSourceFile("test.c", [_][]const u8{"-std=c99"});
9828 exe.addCSourceFile("test.c", &[_][]const u8{"-std=c99"});
98299829 exe.addObject(obj);
98309830 exe.linkSystemLibrary("c");
98319831 exe.install();
src/ir.cpp+1
......@@ -23646,6 +23646,7 @@ static IrInstruction *ir_analyze_instruction_from_bytes(IrAnalyze *ira, IrInstru
2364623646 }
2364723647
2364823648 if (target->value->type->id == ZigTypeIdPointer &&
23649 target->value->type->data.pointer.ptr_len == PtrLenSingle &&
2364923650 target->value->type->data.pointer.child_type->id == ZigTypeIdArray)
2365023651 {
2365123652 known_len = target->value->type->data.pointer.child_type->data.array.len;