aboutsummaryrefslogtreecommitdiff
path: root/lib/std
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2019-11-23 04:45:35 -0500
committerAndrew Kelley <andrew@ziglang.org>2019-11-23 04:45:35 -0500
commit7597735badd1f6aa6750f354a7e9c85fec705c55 (patch)
tree69e5e1b3795afcf065b0a40203ba4f678a4532d7 /lib/std
parent6b623b5ea2a811b54a2391f17081a8981fa733a5 (diff)
downloadzig-7597735badd1f6aa6750f354a7e9c85fec705c55.tar.gz
zig-7597735badd1f6aa6750f354a7e9c85fec705c55.zip
update the stage1 implementation to the new proposal
See #3731
Diffstat (limited to 'lib/std')
-rw-r--r--lib/std/builtin.zig14
-rw-r--r--lib/std/c.zig2
-rw-r--r--lib/std/mem.zig2
-rw-r--r--lib/std/zig/parser_test.zig6
4 files changed, 17 insertions, 7 deletions
diff --git a/lib/std/builtin.zig b/lib/std/builtin.zig
index 56c3426d8b..64fc68e4cc 100644
--- a/lib/std/builtin.zig
+++ b/lib/std/builtin.zig
@@ -144,7 +144,12 @@ pub const TypeInfo = union(enum) {
alignment: comptime_int,
child: type,
is_allowzero: bool,
- is_null_terminated: bool,
+ /// The type of the sentinel is the element type of the pointer, which is
+ /// the value of the `child` field in this struct. However there is no way
+ /// to refer to that type here, so this is a pointer to an opaque value.
+ /// It will be known at compile-time to be the correct type. Dereferencing
+ /// this pointer will work at compile-time.
+ sentinel: ?*const c_void,
/// This data structure is used by the Zig language code generation and
/// therefore must be kept in sync with the compiler implementation.
@@ -161,7 +166,12 @@ pub const TypeInfo = union(enum) {
pub const Array = struct {
len: comptime_int,
child: type,
- is_null_terminated: bool,
+ /// The type of the sentinel is the element type of the array, which is
+ /// the value of the `child` field in this struct. However there is no way
+ /// to refer to that type here, so this is a pointer to an opaque value.
+ /// It will be known at compile-time to be the correct type. Dereferencing
+ /// this pointer will work at compile-time.
+ sentinel: ?*const c_void,
};
/// This data structure is used by the Zig language code generation and
diff --git a/lib/std/c.zig b/lib/std/c.zig
index 1faf45a489..fac13efc69 100644
--- a/lib/std/c.zig
+++ b/lib/std/c.zig
@@ -63,7 +63,7 @@ pub extern "c" fn fclose(stream: *FILE) c_int;
pub extern "c" fn fwrite(ptr: [*]const u8, size_of_type: usize, item_count: usize, stream: *FILE) usize;
pub extern "c" fn fread(ptr: [*]u8, size_of_type: usize, item_count: usize, stream: *FILE) usize;
-pub extern "c" fn printf(format: [*]null const u8, ...) c_int;
+pub extern "c" fn printf(format: [*:0]const u8, ...) c_int;
pub extern "c" fn abort() noreturn;
pub extern "c" fn exit(code: c_int) noreturn;
pub extern "c" fn isatty(fd: fd_t) c_int;
diff --git a/lib/std/mem.zig b/lib/std/mem.zig
index 160b8e6e5e..f790dd683b 100644
--- a/lib/std/mem.zig
+++ b/lib/std/mem.zig
@@ -1409,7 +1409,7 @@ fn BytesAsValueReturnType(comptime T: type, comptime B: type) type {
const size = @as(usize, @sizeOf(T));
if (comptime !trait.is(builtin.TypeId.Pointer)(B) or
- (meta.Child(B) != [size]u8 and meta.Child(B) != [size]null u8))
+ (meta.Child(B) != [size]u8 and meta.Child(B) != [size:0]u8))
{
@compileError("expected *[N]u8 " ++ ", passed " ++ @typeName(B));
}
diff --git a/lib/std/zig/parser_test.zig b/lib/std/zig/parser_test.zig
index ebe396e145..ce19588722 100644
--- a/lib/std/zig/parser_test.zig
+++ b/lib/std/zig/parser_test.zig
@@ -1552,7 +1552,7 @@ test "zig fmt: pointer attributes" {
\\extern fn f2(s: **align(1) *const *volatile u8) c_int;
\\extern fn f3(s: *align(1) const *align(1) volatile *const volatile u8) c_int;
\\extern fn f4(s: *align(1) const volatile u8) c_int;
- \\extern fn f5(s: [*]null align(1) const volatile u8) c_int;
+ \\extern fn f5(s: [*:0]align(1) const volatile u8) c_int;
\\
);
}
@@ -1563,7 +1563,7 @@ test "zig fmt: slice attributes" {
\\extern fn f2(s: **align(1) *const *volatile u8) c_int;
\\extern fn f3(s: *align(1) const *align(1) volatile *const volatile u8) c_int;
\\extern fn f4(s: *align(1) const volatile u8) c_int;
- \\extern fn f5(s: [*]null align(1) const volatile u8) c_int;
+ \\extern fn f5(s: [*:0]align(1) const volatile u8) c_int;
\\
);
}
@@ -1885,7 +1885,7 @@ test "zig fmt: arrays" {
\\ 2,
\\ };
\\ const a: [0]u8 = []u8{};
- \\ const x: [4]null u8 = undefined;
+ \\ const x: [4:0]u8 = undefined;
\\}
\\
);