From a867b43366c7fb132ec44a03f9b40ead888900fb Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Sun, 19 Jan 2020 02:40:35 -0500 Subject: progress towards merging see BRANCH_TODO file --- lib/std/buffer.zig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/std/buffer.zig') diff --git a/lib/std/buffer.zig b/lib/std/buffer.zig index 6313d693b7..21f73112fa 100644 --- a/lib/std/buffer.zig +++ b/lib/std/buffer.zig @@ -57,11 +57,11 @@ pub const Buffer = struct { /// The caller owns the returned memory. The Buffer becomes null and /// is safe to `deinit`. - pub fn toOwnedSlice(self: *Buffer) []u8 { + pub fn toOwnedSlice(self: *Buffer) [:0]u8 { const allocator = self.list.allocator; const result = allocator.shrink(self.list.items, self.len()); self.* = initNull(allocator); - return result; + return result[0 .. result.len - 1 :0]; } pub fn allocPrint(allocator: *Allocator, comptime format: []const u8, args: var) !Buffer { -- cgit v1.2.3 From 20af858601e015ba76f23033d0af1d672db097ac Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Sun, 19 Jan 2020 21:06:41 -0500 Subject: some fixes --- lib/std/buffer.zig | 2 +- src-self-hosted/stage1.zig | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'lib/std/buffer.zig') diff --git a/lib/std/buffer.zig b/lib/std/buffer.zig index 21f73112fa..42bf8e8142 100644 --- a/lib/std/buffer.zig +++ b/lib/std/buffer.zig @@ -59,7 +59,7 @@ pub const Buffer = struct { /// is safe to `deinit`. pub fn toOwnedSlice(self: *Buffer) [:0]u8 { const allocator = self.list.allocator; - const result = allocator.shrink(self.list.items, self.len()); + const result = self.list.toOwnedSlice(); self.* = initNull(allocator); return result[0 .. result.len - 1 :0]; } diff --git a/src-self-hosted/stage1.zig b/src-self-hosted/stage1.zig index f0593f8fce..85a6951827 100644 --- a/src-self-hosted/stage1.zig +++ b/src-self-hosted/stage1.zig @@ -542,14 +542,14 @@ export fn stage2_list_features_for_arch(arch_name_ptr: [*]const u8, arch_name_le fn printFeaturesForArch(arch_name: []const u8, show_dependencies: bool) !void { const stdout_stream = &std.io.getStdOut().outStream().stream; - const arch = Target.parseArchTag(arch_name) catch { + const arch = Target.parseArchSub(arch_name) catch { std.debug.warn("Failed to parse arch '{}'\nInvoke 'zig targets' for a list of valid architectures\n", .{arch_name}); return; }; try stdout_stream.print("Available features for {}:\n", .{@tagName(arch)}); - const features = std.target.getFeaturesForArch(arch); + const features = arch.allFeaturesList(); var longest_len: usize = 0; for (features) |feature| { @@ -568,7 +568,7 @@ fn printFeaturesForArch(arch_name: []const u8, show_dependencies: bool) !void { try stdout_stream.print(" - {}\n", .{feature.description}); - if (show_dependencies and feature.dependencies.len > 0) { + if (show_dependencies and feature.dependencies != 0) { for (feature.dependencies) |dependency| { try stdout_stream.print(" {}\n", .{dependency.name}); } @@ -622,7 +622,7 @@ fn printCpusForArch(arch_name: []const u8, show_dependencies: bool) !void { const Stage2CpuFeatures = struct { allocator: *mem.Allocator, - cpu_features: Target.CpuFeatures, + cpu_features: Target.Cross.CpuFeatures, llvm_cpu_name: ?[:0]const u8, llvm_features_str: ?[:0]const u8, -- cgit v1.2.3