diff options
Diffstat (limited to 'src-self-hosted')
| -rw-r--r-- | src-self-hosted/arg.zig | 8 | ||||
| -rw-r--r-- | src-self-hosted/c_int.zig | 2 | ||||
| -rw-r--r-- | src-self-hosted/compilation.zig | 26 | ||||
| -rw-r--r-- | src-self-hosted/dep_tokenizer.zig | 11 | ||||
| -rw-r--r-- | src-self-hosted/introspect.zig | 4 | ||||
| -rw-r--r-- | src-self-hosted/libc_installation.zig | 16 | ||||
| -rw-r--r-- | src-self-hosted/link.zig | 4 | ||||
| -rw-r--r-- | src-self-hosted/main.zig | 20 | ||||
| -rw-r--r-- | src-self-hosted/stage1.zig | 2 | ||||
| -rw-r--r-- | src-self-hosted/value.zig | 4 |
10 files changed, 48 insertions, 49 deletions
diff --git a/src-self-hosted/arg.zig b/src-self-hosted/arg.zig index 7bbd233a75..8f95e2d7ef 100644 --- a/src-self-hosted/arg.zig +++ b/src-self-hosted/arg.zig @@ -178,7 +178,7 @@ pub const Args = struct { else => @panic("attempted to retrieve flag with wrong type"), } } else { - return []const []const u8{}; + return [_][]const u8{}; } } }; @@ -238,11 +238,11 @@ pub const Flag = struct { }; test "parse arguments" { - const spec1 = comptime []const Flag{ + const spec1 = comptime [_]Flag{ Flag.Bool("--help"), Flag.Bool("--init"), Flag.Arg1("--build-file"), - Flag.Option("--color", []const []const u8{ + Flag.Option("--color", [_][]const u8{ "on", "off", "auto", @@ -252,7 +252,7 @@ test "parse arguments" { Flag.ArgN("--library", 1), }; - const cliargs = []const []const u8{ + const cliargs = [_][]const u8{ "build", "--help", "pos1", diff --git a/src-self-hosted/c_int.zig b/src-self-hosted/c_int.zig index 10ce54da05..33d2faa5c1 100644 --- a/src-self-hosted/c_int.zig +++ b/src-self-hosted/c_int.zig @@ -15,7 +15,7 @@ pub const CInt = struct { ULongLong, }; - pub const list = []CInt{ + pub const list = [_]CInt{ CInt{ .id = Id.Short, .zig_name = "c_short", diff --git a/src-self-hosted/compilation.zig b/src-self-hosted/compilation.zig index 450fde7219..bd20442d4b 100644 --- a/src-self-hosted/compilation.zig +++ b/src-self-hosted/compilation.zig @@ -102,8 +102,8 @@ pub const ZigCompiler = struct { /// Must be called only once, ever. Sets global state. pub fn setLlvmArgv(allocator: *Allocator, llvm_argv: []const []const u8) !void { if (llvm_argv.len != 0) { - var c_compatible_args = try std.cstr.NullTerminated2DArray.fromSlices(allocator, [][]const []const u8{ - [][]const u8{"zig (LLVM option parsing)"}, + var c_compatible_args = try std.cstr.NullTerminated2DArray.fromSlices(allocator, [_][]const []const u8{ + [_][]const u8{"zig (LLVM option parsing)"}, llvm_argv, }); defer c_compatible_args.deinit(); @@ -160,7 +160,7 @@ pub const Compilation = struct { /// it uses an optional pointer so that tombstone removals are possible fn_link_set: event.Locked(FnLinkSet), - pub const FnLinkSet = std.LinkedList(?*Value.Fn); + pub const FnLinkSet = std.TailQueue(?*Value.Fn); windows_subsystem_windows: bool, windows_subsystem_console: bool, @@ -421,20 +421,20 @@ pub const Compilation = struct { .strip = false, .is_static = is_static, .linker_rdynamic = false, - .clang_argv = [][]const u8{}, - .lib_dirs = [][]const u8{}, - .rpath_list = [][]const u8{}, - .assembly_files = [][]const u8{}, - .link_objects = [][]const u8{}, + .clang_argv = [_][]const u8{}, + .lib_dirs = [_][]const u8{}, + .rpath_list = [_][]const u8{}, + .assembly_files = [_][]const u8{}, + .link_objects = [_][]const u8{}, .fn_link_set = event.Locked(FnLinkSet).init(loop, FnLinkSet.init()), .windows_subsystem_windows = false, .windows_subsystem_console = false, .link_libs_list = undefined, .libc_link_lib = null, .err_color = errmsg.Color.Auto, - .darwin_frameworks = [][]const u8{}, + .darwin_frameworks = [_][]const u8{}, .darwin_version_min = DarwinVersionMin.None, - .test_filters = [][]const u8{}, + .test_filters = [_][]const u8{}, .test_name_prefix = null, .emit_file_type = Emit.Binary, .link_out_file = null, @@ -487,7 +487,7 @@ pub const Compilation = struct { comp.name = try Buffer.init(comp.arena(), name); comp.llvm_triple = try target.getTriple(comp.arena()); comp.llvm_target = try Target.llvmTargetFromTriple(comp.llvm_triple); - comp.zig_std_dir = try std.fs.path.join(comp.arena(), [][]const u8{ zig_lib_dir, "std" }); + comp.zig_std_dir = try std.fs.path.join(comp.arena(), [_][]const u8{ zig_lib_dir, "std" }); const opt_level = switch (build_mode) { builtin.Mode.Debug => llvm.CodeGenLevelNone, @@ -1196,7 +1196,7 @@ pub const Compilation = struct { const file_name = try std.fmt.allocPrint(self.gpa(), "{}{}", file_prefix[0..], suffix); defer self.gpa().free(file_name); - const full_path = try std.fs.path.join(self.gpa(), [][]const u8{ tmp_dir, file_name[0..] }); + const full_path = try std.fs.path.join(self.gpa(), [_][]const u8{ tmp_dir, file_name[0..] }); errdefer self.gpa().free(full_path); return Buffer.fromOwnedSlice(self.gpa(), full_path); @@ -1217,7 +1217,7 @@ pub const Compilation = struct { const zig_dir_path = try getZigDir(self.gpa()); defer self.gpa().free(zig_dir_path); - const tmp_dir = try std.fs.path.join(self.arena(), [][]const u8{ zig_dir_path, comp_dir_name[0..] }); + const tmp_dir = try std.fs.path.join(self.arena(), [_][]const u8{ zig_dir_path, comp_dir_name[0..] }); try std.fs.makePath(self.gpa(), tmp_dir); return tmp_dir; } diff --git a/src-self-hosted/dep_tokenizer.zig b/src-self-hosted/dep_tokenizer.zig index 0dde6da71c..2721944451 100644 --- a/src-self-hosted/dep_tokenizer.zig +++ b/src-self-hosted/dep_tokenizer.zig @@ -837,12 +837,11 @@ test "error prereq - continuation expecting end-of-line" { // - tokenize input, emit textual representation, and compare to expect fn depTokenizer(input: []const u8, expect: []const u8) !void { - var direct_allocator = std.heap.DirectAllocator.init(); - var arena_allocator = std.heap.ArenaAllocator.init(&direct_allocator.allocator); + var arena_allocator = std.heap.ArenaAllocator.init(std.heap.direct_allocator); const arena = &arena_allocator.allocator; defer arena_allocator.deinit(); - var it = Tokenizer.init(&direct_allocator.allocator, input); + var it = Tokenizer.init(arena, input); var buffer = try std.Buffer.initSize(arena, 0); var i: usize = 0; while (true) { @@ -900,7 +899,7 @@ fn printLabel(out: var, label: []const u8, bytes: []const u8) !void { var i: usize = text.len; const end = 79; while (i < 79) : (i += 1) { - try out.write([]const u8{label[0]}); + try out.write([_]u8{label[0]}); } try out.write("\n"); } @@ -993,7 +992,7 @@ fn printHexValue(out: var, value: u64, width: u8) !void { fn printCharValues(out: var, bytes: []const u8) !void { for (bytes) |b| { - try out.write([]const u8{printable_char_tab[b]}); + try out.write([_]u8{printable_char_tab[b]}); } } @@ -1002,7 +1001,7 @@ fn printUnderstandableChar(out: var, char: u8) !void { std.fmt.format(out.context, anyerror, out.output, "\\x{X2}", char) catch {}; } else { try out.write("'"); - try out.write([]const u8{printable_char_tab[char]}); + try out.write([_]u8{printable_char_tab[char]}); try out.write("'"); } } diff --git a/src-self-hosted/introspect.zig b/src-self-hosted/introspect.zig index 538232e620..d5204f031e 100644 --- a/src-self-hosted/introspect.zig +++ b/src-self-hosted/introspect.zig @@ -8,10 +8,10 @@ const warn = std.debug.warn; /// Caller must free result pub fn testZigInstallPrefix(allocator: *mem.Allocator, test_path: []const u8) ![]u8 { - const test_zig_dir = try fs.path.join(allocator, [][]const u8{ test_path, "lib", "zig" }); + const test_zig_dir = try fs.path.join(allocator, [_][]const u8{ test_path, "lib", "zig" }); errdefer allocator.free(test_zig_dir); - const test_index_file = try fs.path.join(allocator, [][]const u8{ test_zig_dir, "std", "std.zig" }); + const test_index_file = try fs.path.join(allocator, [_][]const u8{ test_zig_dir, "std", "std.zig" }); defer allocator.free(test_index_file); var file = try fs.File.openRead(test_index_file); diff --git a/src-self-hosted/libc_installation.zig b/src-self-hosted/libc_installation.zig index 7ca849d10c..e6236c567a 100644 --- a/src-self-hosted/libc_installation.zig +++ b/src-self-hosted/libc_installation.zig @@ -35,7 +35,7 @@ pub const LibCInstallation = struct { ) !void { self.initEmpty(); - const keys = []const []const u8{ + const keys = [_][]const u8{ "include_dir", "lib_dir", "static_lib_dir", @@ -183,7 +183,7 @@ pub const LibCInstallation = struct { async fn findNativeIncludeDirLinux(self: *LibCInstallation, loop: *event.Loop) !void { const cc_exe = std.os.getenv("CC") orelse "cc"; - const argv = []const []const u8{ + const argv = [_][]const u8{ cc_exe, "-E", "-Wp,-v", @@ -231,7 +231,7 @@ pub const LibCInstallation = struct { while (path_i < search_paths.len) : (path_i += 1) { const search_path_untrimmed = search_paths.at(search_paths.len - path_i - 1); const search_path = std.mem.trimLeft(u8, search_path_untrimmed, " "); - const stdlib_path = try fs.path.join(loop.allocator, [][]const u8{ search_path, "stdlib.h" }); + const stdlib_path = try fs.path.join(loop.allocator, [_][]const u8{ search_path, "stdlib.h" }); defer loop.allocator.free(stdlib_path); if (try fileExists(stdlib_path)) { @@ -257,7 +257,7 @@ pub const LibCInstallation = struct { const stdlib_path = try fs.path.join( loop.allocator, - [][]const u8{ result_buf.toSliceConst(), "stdlib.h" }, + [_][]const u8{ result_buf.toSliceConst(), "stdlib.h" }, ); defer loop.allocator.free(stdlib_path); @@ -289,7 +289,7 @@ pub const LibCInstallation = struct { } const ucrt_lib_path = try fs.path.join( loop.allocator, - [][]const u8{ result_buf.toSliceConst(), "ucrt.lib" }, + [_][]const u8{ result_buf.toSliceConst(), "ucrt.lib" }, ); defer loop.allocator.free(ucrt_lib_path); if (try fileExists(ucrt_lib_path)) { @@ -309,7 +309,7 @@ pub const LibCInstallation = struct { } async fn findNativeDynamicLinker(self: *LibCInstallation, loop: *event.Loop) FindError!void { - var dyn_tests = []DynTest{ + var dyn_tests = [_]DynTest{ DynTest{ .name = "ld-linux-x86-64.so.2", .result = null, @@ -367,7 +367,7 @@ pub const LibCInstallation = struct { } const kernel32_path = try fs.path.join( loop.allocator, - [][]const u8{ result_buf.toSliceConst(), "kernel32.lib" }, + [_][]const u8{ result_buf.toSliceConst(), "kernel32.lib" }, ); defer loop.allocator.free(kernel32_path); if (try fileExists(kernel32_path)) { @@ -395,7 +395,7 @@ async fn ccPrintFileName(loop: *event.Loop, o_file: []const u8, want_dirname: bo const cc_exe = std.os.getenv("CC") orelse "cc"; const arg1 = try std.fmt.allocPrint(loop.allocator, "-print-file-name={}", o_file); defer loop.allocator.free(arg1); - const argv = []const []const u8{ cc_exe, arg1 }; + const argv = [_][]const u8{ cc_exe, arg1 }; // TODO This simulates evented I/O for the child process exec await (async loop.yield() catch unreachable); diff --git a/src-self-hosted/link.zig b/src-self-hosted/link.zig index 838cbbc480..95b71a55c9 100644 --- a/src-self-hosted/link.zig +++ b/src-self-hosted/link.zig @@ -311,7 +311,7 @@ fn constructLinkerArgsElf(ctx: *Context) !void { } fn addPathJoin(ctx: *Context, dirname: []const u8, basename: []const u8) !void { - const full_path = try std.fs.path.join(&ctx.arena.allocator, [][]const u8{ dirname, basename }); + const full_path = try std.fs.path.join(&ctx.arena.allocator, [_][]const u8{ dirname, basename }); const full_path_with_null = try std.cstr.addNullByte(&ctx.arena.allocator, full_path); try ctx.args.append(full_path_with_null.ptr); } @@ -722,7 +722,7 @@ fn darwinGetReleaseVersion(str: []const u8, major: *u32, minor: *u32, micro: *u3 return error.InvalidDarwinVersionString; var start_pos: usize = 0; - for ([]*u32{ major, minor, micro }) |v| { + for ([_]*u32{ major, minor, micro }) |v| { const dot_pos = mem.indexOfScalarPos(u8, str, start_pos, '.'); const end_pos = dot_pos orelse str.len; v.* = std.fmt.parseUnsigned(u32, str[start_pos..end_pos], 10) catch return error.InvalidDarwinVersionString; diff --git a/src-self-hosted/main.zig b/src-self-hosted/main.zig index 4095caa8c4..8917809533 100644 --- a/src-self-hosted/main.zig +++ b/src-self-hosted/main.zig @@ -74,7 +74,7 @@ pub fn main() !void { process.exit(1); } - const commands = []Command{ + const commands = [_]Command{ Command{ .name = "build-exe", .exec = cmdBuildExe, @@ -190,14 +190,14 @@ const usage_build_generic = \\ ; -const args_build_generic = []Flag{ +const args_build_generic = [_]Flag{ Flag.Bool("--help"), - Flag.Option("--color", []const []const u8{ + Flag.Option("--color", [_][]const u8{ "auto", "off", "on", }), - Flag.Option("--mode", []const []const u8{ + Flag.Option("--mode", [_][]const u8{ "debug", "release-fast", "release-safe", @@ -205,7 +205,7 @@ const args_build_generic = []Flag{ }), Flag.ArgMergeN("--assembly", 1), - Flag.Option("--emit", []const []const u8{ + Flag.Option("--emit", [_][]const u8{ "asm", "bin", "llvm-ir", @@ -525,10 +525,10 @@ pub const usage_fmt = \\ ; -pub const args_fmt_spec = []Flag{ +pub const args_fmt_spec = [_]Flag{ Flag.Bool("--help"), Flag.Bool("--check"), - Flag.Option("--color", []const []const u8{ + Flag.Option("--color", [_][]const u8{ "auto", "off", "on", @@ -756,7 +756,7 @@ async fn fmtPath(fmt: *Fmt, file_path_ref: []const u8, check_mode: bool) FmtErro var group = event.Group(FmtError!void).init(fmt.loop); while (try dir.next()) |entry| { if (entry.kind == fs.Dir.Entry.Kind.Directory or mem.endsWith(u8, entry.name, ".zig")) { - const full_path = try fs.path.join(fmt.loop.allocator, [][]const u8{ file_path, entry.name }); + const full_path = try fs.path.join(fmt.loop.allocator, [_][]const u8{ file_path, entry.name }); try group.call(fmtPath, fmt, full_path, check_mode); } } @@ -855,7 +855,7 @@ fn cmdVersion(allocator: *Allocator, args: []const []const u8) !void { try stdout.print("{}\n", std.mem.toSliceConst(u8, c.ZIG_VERSION_STRING)); } -const args_test_spec = []Flag{Flag.Bool("--help")}; +const args_test_spec = [_]Flag{Flag.Bool("--help")}; fn cmdHelp(allocator: *Allocator, args: []const []const u8) !void { try stdout.write(usage); @@ -897,7 +897,7 @@ fn cmdInternal(allocator: *Allocator, args: []const []const u8) !void { process.exit(1); } - const sub_commands = []Command{Command{ + const sub_commands = [_]Command{Command{ .name = "build-info", .exec = cmdInternalBuildInfo, }}; diff --git a/src-self-hosted/stage1.zig b/src-self-hosted/stage1.zig index bc1a746154..9acc45c99a 100644 --- a/src-self-hosted/stage1.zig +++ b/src-self-hosted/stage1.zig @@ -287,7 +287,7 @@ fn fmtPath(fmt: *Fmt, file_path_ref: []const u8, check_mode: bool) FmtError!void while (try dir.next()) |entry| { if (entry.kind == fs.Dir.Entry.Kind.Directory or mem.endsWith(u8, entry.name, ".zig")) { - const full_path = try fs.path.join(fmt.allocator, [][]const u8{ file_path, entry.name }); + const full_path = try fs.path.join(fmt.allocator, [_][]const u8{ file_path, entry.name }); try fmtPath(fmt, full_path, check_mode); } } diff --git a/src-self-hosted/value.zig b/src-self-hosted/value.zig index f1c7fc0b50..6908307c56 100644 --- a/src-self-hosted/value.zig +++ b/src-self-hosted/value.zig @@ -186,7 +186,7 @@ pub const Value = struct { /// Path to the object file that contains this function containing_object: Buffer, - link_set_node: *std.LinkedList(?*Value.Fn).Node, + link_set_node: *std.TailQueue(?*Value.Fn).Node, /// Creates a Fn value with 1 ref /// Takes ownership of symbol_name @@ -391,7 +391,7 @@ pub const Value = struct { const array_llvm_value = (try base_array.val.getLlvmConst(ofile)).?; const ptr_bit_count = ofile.comp.target_ptr_bits; const usize_llvm_type = llvm.IntTypeInContext(ofile.context, ptr_bit_count) orelse return error.OutOfMemory; - const indices = []*llvm.Value{ + const indices = [_]*llvm.Value{ llvm.ConstNull(usize_llvm_type) orelse return error.OutOfMemory, llvm.ConstInt(usize_llvm_type, base_array.elem_index, 0) orelse return error.OutOfMemory, }; |
