Commit 37caa56fbc

Andrew Kelley <andrew@ziglang.org>
2019-12-02 03:27:55
fix docs regressions
1 parent c32e50f
Changed files (3)
doc/docgen.zig
@@ -1039,7 +1039,7 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: var
                 const name_plus_ext = try std.fmt.allocPrint(allocator, "{}.zig", code.name);
                 const tmp_source_file_name = try fs.path.join(
                     allocator,
-                    [_][]const u8{ tmp_dir_name, name_plus_ext },
+                    &[_][]const u8{ tmp_dir_name, name_plus_ext },
                 );
                 try io.writeFile(tmp_source_file_name, trimmed_raw_source);
 
@@ -1048,7 +1048,7 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: var
                         const name_plus_bin_ext = try std.fmt.allocPrint(allocator, "{}{}", code.name, exe_ext);
                         var build_args = std.ArrayList([]const u8).init(allocator);
                         defer build_args.deinit();
-                        try build_args.appendSlice([_][]const u8{
+                        try build_args.appendSlice(&[_][]const u8{
                             zig_exe,
                             "build-exe",
                             tmp_source_file_name,
@@ -1079,7 +1079,7 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: var
                             const name_with_ext = try std.fmt.allocPrint(allocator, "{}{}", link_object, obj_ext);
                             const full_path_object = try fs.path.join(
                                 allocator,
-                                [_][]const u8{ tmp_dir_name, name_with_ext },
+                                &[_][]const u8{ tmp_dir_name, name_with_ext },
                             );
                             try build_args.append("--object");
                             try build_args.append(full_path_object);
@@ -1090,7 +1090,7 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: var
                             try out.print(" -lc");
                         }
                         if (code.target_str) |triple| {
-                            try build_args.appendSlice([_][]const u8{ "-target", triple });
+                            try build_args.appendSlice(&[_][]const u8{ "-target", triple });
                             if (!code.is_inline) {
                                 try out.print(" -target {}", triple);
                             }
@@ -1143,7 +1143,7 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: var
                         }
 
                         const path_to_exe = mem.trim(u8, exec_result.stdout, " \r\n");
-                        const run_args = [_][]const u8{path_to_exe};
+                        const run_args = &[_][]const u8{path_to_exe};
 
                         var exited_with_signal = false;
 
@@ -1184,7 +1184,7 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: var
                         var test_args = std.ArrayList([]const u8).init(allocator);
                         defer test_args.deinit();
 
-                        try test_args.appendSlice([_][]const u8{
+                        try test_args.appendSlice(&[_][]const u8{
                             zig_exe,
                             "test",
                             tmp_source_file_name,
@@ -1212,7 +1212,7 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: var
                             try out.print(" -lc");
                         }
                         if (code.target_str) |triple| {
-                            try test_args.appendSlice([_][]const u8{ "-target", triple });
+                            try test_args.appendSlice(&[_][]const u8{ "-target", triple });
                             try out.print(" -target {}", triple);
                         }
                         const result = exec(allocator, &env_map, test_args.toSliceConst()) catch return parseError(tokenizer, code.source_token, "test failed");
@@ -1224,7 +1224,7 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: var
                         var test_args = std.ArrayList([]const u8).init(allocator);
                         defer test_args.deinit();
 
-                        try test_args.appendSlice([_][]const u8{
+                        try test_args.appendSlice(&[_][]const u8{
                             zig_exe,
                             "test",
                             "--color",
@@ -1283,7 +1283,7 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: var
                         var test_args = std.ArrayList([]const u8).init(allocator);
                         defer test_args.deinit();
 
-                        try test_args.appendSlice([_][]const u8{
+                        try test_args.appendSlice(&[_][]const u8{
                             zig_exe,
                             "test",
                             tmp_source_file_name,
@@ -1345,7 +1345,7 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: var
                         const name_plus_obj_ext = try std.fmt.allocPrint(allocator, "{}{}", code.name, obj_ext);
                         const tmp_obj_file_name = try fs.path.join(
                             allocator,
-                            [_][]const u8{ tmp_dir_name, name_plus_obj_ext },
+                            &[_][]const u8{ tmp_dir_name, name_plus_obj_ext },
                         );
                         var build_args = std.ArrayList([]const u8).init(allocator);
                         defer build_args.deinit();
@@ -1353,10 +1353,10 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: var
                         const name_plus_h_ext = try std.fmt.allocPrint(allocator, "{}.h", code.name);
                         const output_h_file_name = try fs.path.join(
                             allocator,
-                            [_][]const u8{ tmp_dir_name, name_plus_h_ext },
+                            &[_][]const u8{ tmp_dir_name, name_plus_h_ext },
                         );
 
-                        try build_args.appendSlice([_][]const u8{
+                        try build_args.appendSlice(&[_][]const u8{
                             zig_exe,
                             "build-obj",
                             tmp_source_file_name,
@@ -1395,7 +1395,7 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: var
                         }
 
                         if (code.target_str) |triple| {
-                            try build_args.appendSlice([_][]const u8{ "-target", triple });
+                            try build_args.appendSlice(&[_][]const u8{ "-target", triple });
                             try out.print(" -target {}", triple);
                         }
 
@@ -1442,7 +1442,7 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: var
                         var test_args = std.ArrayList([]const u8).init(allocator);
                         defer test_args.deinit();
 
-                        try test_args.appendSlice([_][]const u8{
+                        try test_args.appendSlice(&[_][]const u8{
                             zig_exe,
                             "build-lib",
                             tmp_source_file_name,
@@ -1466,7 +1466,7 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: var
                             },
                         }
                         if (code.target_str) |triple| {
-                            try test_args.appendSlice([_][]const u8{ "-target", triple });
+                            try test_args.appendSlice(&[_][]const u8{ "-target", triple });
                             try out.print(" -target {}", triple);
                         }
                         const result = exec(allocator, &env_map, test_args.toSliceConst()) catch return parseError(tokenizer, code.source_token, "test failed");
@@ -1507,7 +1507,7 @@ fn exec(allocator: *mem.Allocator, env_map: *std.BufMap, args: []const []const u
 }
 
 fn getBuiltinCode(allocator: *mem.Allocator, env_map: *std.BufMap, zig_exe: []const u8) ![]const u8 {
-    const result = try exec(allocator, env_map, [_][]const u8{
+    const result = try exec(allocator, env_map, &[_][]const u8{
         zig_exe,
         "builtin",
     });
doc/langref.html.in
@@ -1518,7 +1518,7 @@ value == null{#endsyntax#}</pre>
 const array1 = [_]u32{1,2};
 const array2 = [_]u32{3,4};
 const together = array1 ++ array2;
-mem.eql(u32, together, [_]u32{1,2,3,4}){#endsyntax#}</pre>
+mem.eql(u32, together, &[_]u32{1,2,3,4}){#endsyntax#}</pre>
           </td>
         </tr>
         <tr>
@@ -1621,10 +1621,10 @@ comptime {
 }
 
 // A string literal is a pointer to an array literal.
-const same_message = "hello".*;
+const same_message = "hello";
 
 comptime {
-    assert(mem.eql(u8, message, same_message));
+    assert(mem.eql(u8, &message, same_message));
 }
 
 test "iterate over an array" {
@@ -1652,7 +1652,7 @@ const part_one = [_]i32{ 1, 2, 3, 4 };
 const part_two = [_]i32{ 5, 6, 7, 8 };
 const all_of_it = part_one ++ part_two;
 comptime {
-    assert(mem.eql(i32, all_of_it, [_]i32{ 1, 2, 3, 4, 5, 6, 7, 8 }));
+    assert(mem.eql(i32, &all_of_it, &[_]i32{ 1, 2, 3, 4, 5, 6, 7, 8 }));
 }
 
 // remember that string literals are arrays
@@ -4915,30 +4915,30 @@ const assert = std.debug.assert;
 // https://github.com/ziglang/zig/issues/265 is implemented.
 test "[N]T to []const T" {
     var x1: []const u8 = "hello";
-    var x2: []const u8 = [5]u8{ 'h', 'e', 'l', 'l', 111 };
+    var x2: []const u8 = &[5]u8{ 'h', 'e', 'l', 'l', 111 };
     assert(std.mem.eql(u8, x1, x2));
 
-    var y: []const f32 = [2]f32{ 1.2, 3.4 };
+    var y: []const f32 = &[2]f32{ 1.2, 3.4 };
     assert(y[0] == 1.2);
 }
 
 // Likewise, it works when the destination type is an error union.
 test "[N]T to E![]const T" {
     var x1: anyerror![]const u8 = "hello";
-    var x2: anyerror![]const u8 = [5]u8{ 'h', 'e', 'l', 'l', 111 };
+    var x2: anyerror![]const u8 = &[5]u8{ 'h', 'e', 'l', 'l', 111 };
     assert(std.mem.eql(u8, try x1, try x2));
 
-    var y: anyerror![]const f32 = [2]f32{ 1.2, 3.4 };
+    var y: anyerror![]const f32 = &[2]f32{ 1.2, 3.4 };
     assert((try y)[0] == 1.2);
 }
 
 // Likewise, it works when the destination type is an optional.
 test "[N]T to ?[]const T" {
     var x1: ?[]const u8 = "hello";
-    var x2: ?[]const u8 = [5]u8{ 'h', 'e', 'l', 'l', 111 };
+    var x2: ?[]const u8 = &[5]u8{ 'h', 'e', 'l', 'l', 111 };
     assert(std.mem.eql(u8, x1.?, x2.?));
 
-    var y: ?[]const f32 = [2]f32{ 1.2, 3.4 };
+    var y: ?[]const f32 = &[2]f32{ 1.2, 3.4 };
     assert(y.?[0] == 1.2);
 }
 
@@ -4950,7 +4950,7 @@ test "*[N]T to []T" {
 
     const buf2 = [2]f32{ 1.2, 3.4 };
     const x2: []const f32 = &buf2;
-    assert(std.mem.eql(f32, x2, [2]f32{ 1.2, 3.4 }));
+    assert(std.mem.eql(f32, x2, &[2]f32{ 1.2, 3.4 }));
 }
 
 // Single-item pointers to arrays can be coerced to
@@ -5185,7 +5185,7 @@ fn peerTypeTAndOptionalT(c: bool, b: bool) ?usize {
     return @as(usize, 3);
 }
 
-test "peer type resolution: [0]u8 and []const u8" {
+test "peer type resolution: *[0]u8 and []const u8" {
     assert(peerTypeEmptyArrayAndSlice(true, "hi").len == 0);
     assert(peerTypeEmptyArrayAndSlice(false, "hi").len == 1);
     comptime {
@@ -5195,12 +5195,12 @@ test "peer type resolution: [0]u8 and []const u8" {
 }
 fn peerTypeEmptyArrayAndSlice(a: bool, slice: []const u8) []const u8 {
     if (a) {
-        return [_]u8{};
+        return &[_]u8{};
     }
 
     return slice[0..1];
 }
-test "peer type resolution: [0]u8, []const u8, and anyerror![]u8" {
+test "peer type resolution: *[0]u8, []const u8, and anyerror![]u8" {
     {
         var data = "hi".*;
         const slice = data[0..];
@@ -5216,7 +5216,7 @@ test "peer type resolution: [0]u8, []const u8, and anyerror![]u8" {
 }
 fn peerTypeEmptyArrayAndSliceAndError(a: bool, slice: []u8) anyerror![]u8 {
     if (a) {
-        return [_]u8{};
+        return &[_]u8{};
     }
 
     return slice[0..1];
@@ -5746,7 +5746,7 @@ test "fibonacci" {
       </p>
       {#code_begin|test#}
 const first_25_primes = firstNPrimes(25);
-const sum_of_first_25_primes = sum(first_25_primes);
+const sum_of_first_25_primes = sum(&first_25_primes);
 
 fn firstNPrimes(comptime n: usize) [n]i32 {
     var prime_list: [n]i32 = undefined;
@@ -6364,7 +6364,7 @@ test "async function await" {
     resume the_frame;
     seq('i');
     assert(final_result == 1234);
-    assert(std.mem.eql(u8, seq_points, "abcdefghi"));
+    assert(std.mem.eql(u8, &seq_points, "abcdefghi"));
 }
 fn amain() void {
     seq('b');
@@ -8014,7 +8014,7 @@ test "vector @splat" {
     const scalar: u32 = 5;
     const result = @splat(4, scalar);
     comptime assert(@typeOf(result) == @Vector(4, u32));
-    assert(std.mem.eql(u32, @as([4]u32, result), [_]u32{ 5, 5, 5, 5 }));
+    assert(std.mem.eql(u32, &@as([4]u32, result), &[_]u32{ 5, 5, 5, 5 }));
 }
       {#code_end#}
       <p>
@@ -8948,7 +8948,7 @@ pub fn main() void {
       {#code_begin|test_err|unable to convert#}
 comptime {
     var bytes = [5]u8{ 1, 2, 3, 4, 5 };
-    var slice = @bytesToSlice(u32, bytes);
+    var slice = @bytesToSlice(u32, bytes[0..]);
 }
       {#code_end#}
       <p>At runtime:</p>
@@ -9760,7 +9760,7 @@ pub fn build(b: *Builder) void {
     const lib = b.addSharedLibrary("mathtest", "mathtest.zig", b.version(1, 0, 0));
 
     const exe = b.addExecutable("test", null);
-    exe.addCSourceFile("test.c", [_][]const u8{"-std=c99"});
+    exe.addCSourceFile("test.c", &[_][]const u8{"-std=c99"});
     exe.linkLibrary(lib);
     exe.linkSystemLibrary("c");
 
@@ -9825,7 +9825,7 @@ pub fn build(b: *Builder) void {
     const obj = b.addObject("base64", "base64.zig");
 
     const exe = b.addExecutable("test", null);
-    exe.addCSourceFile("test.c", [_][]const u8{"-std=c99"});
+    exe.addCSourceFile("test.c", &[_][]const u8{"-std=c99"});
     exe.addObject(obj);
     exe.linkSystemLibrary("c");
     exe.install();
src/ir.cpp
@@ -23646,6 +23646,7 @@ static IrInstruction *ir_analyze_instruction_from_bytes(IrAnalyze *ira, IrInstru
     }
 
     if (target->value->type->id == ZigTypeIdPointer &&
+        target->value->type->data.pointer.ptr_len == PtrLenSingle &&
         target->value->type->data.pointer.child_type->id == ZigTypeIdArray)
     {
         known_len = target->value->type->data.pointer.child_type->data.array.len;