diff --git a/lib/std/hash.zig b/lib/std/hash.zig index f96d331d0f..2680a8e263 100644 --- a/lib/std/hash.zig +++ b/lib/std/hash.zig @@ -33,11 +33,11 @@ const wyhash = @import("hash/wyhash.zig"); pub const Wyhash = wyhash.Wyhash; test "hash" { - _ = @import("hash/adler.zig"); - _ = @import("hash/auto_hash.zig"); - _ = @import("hash/crc.zig"); - _ = @import("hash/fnv.zig"); - _ = @import("hash/murmur.zig"); - _ = @import("hash/cityhash.zig"); - _ = @import("hash/wyhash.zig"); + _ = adler; + _ = auto_hash; + _ = crc; + _ = fnv; + _ = murmur; + _ = cityhash; + _ = wyhash; } diff --git a/lib/std/special/compiler_rt/int.zig b/lib/std/special/compiler_rt/int.zig index e4d9df7a22..0f3400d37e 100644 --- a/lib/std/special/compiler_rt/int.zig +++ b/lib/std/special/compiler_rt/int.zig @@ -1,8 +1,9 @@ // Builtin functions that operate on integer types const builtin = @import("builtin"); -const testing = @import("std").testing; -const maxInt = @import("std").math.maxInt; -const minInt = @import("std").math.minInt; +const std = @import("std"); +const testing = std.testing; +const maxInt = std.math.maxInt; +const minInt = std.math.minInt; const udivmod = @import("udivmod.zig").udivmod; diff --git a/lib/std/special/compiler_rt/multi3.zig b/lib/std/special/compiler_rt/multi3.zig index a05fb3bd6d..4e5c49730a 100644 --- a/lib/std/special/compiler_rt/multi3.zig +++ b/lib/std/special/compiler_rt/multi3.zig @@ -17,7 +17,7 @@ pub fn __multi3(a: i128, b: i128) callconv(.C) i128 { return r.all; } -const v128 = @import("std").meta.Vector(2, u64); +const v128 = std.meta.Vector(2, u64); pub fn __multi3_windows_x86_64(a: v128, b: v128) callconv(.C) v128 { return @bitCast(v128, @call(.{ .modifier = .always_inline }, __multi3, .{ @bitCast(i128, a), diff --git a/lib/std/special/compiler_rt/negsi2_test.zig b/lib/std/special/compiler_rt/negsi2_test.zig index 9458ea995c..608a44c12f 100644 --- a/lib/std/special/compiler_rt/negsi2_test.zig +++ b/lib/std/special/compiler_rt/negsi2_test.zig @@ -1,7 +1,8 @@ +const std = @import("std"); const neg = @import("negXi2.zig"); -const testing = @import("std").testing; +const testing = std.testing; -const print = @import("std").debug.print; +const print = std.debug.print; fn test__negsi2(a: i32, expected: i32) !void { var result = neg.__negsi2(a); diff --git a/lib/std/special/compiler_rt/paritydi2_test.zig b/lib/std/special/compiler_rt/paritydi2_test.zig index 7c481bbaef..a13abda5fe 100644 --- a/lib/std/special/compiler_rt/paritydi2_test.zig +++ b/lib/std/special/compiler_rt/paritydi2_test.zig @@ -1,5 +1,6 @@ +const std = @import("std"); const parity = @import("parity.zig"); -const testing = @import("std").testing; +const testing = std.testing; fn paritydi2Naive(a: i64) i32 { var x = @bitCast(u64, a); @@ -25,7 +26,7 @@ test "paritydi2" { try test__paritydi2(@bitCast(i64, @as(u64, 0xffffffff_fffffffe))); try test__paritydi2(@bitCast(i64, @as(u64, 0xffffffff_ffffffff))); - const RndGen = @import("std").rand.DefaultPrng; + const RndGen = std.rand.DefaultPrng; var rnd = RndGen.init(42); var i: u32 = 0; while (i < 10_000) : (i += 1) { diff --git a/lib/std/special/compiler_rt/paritysi2_test.zig b/lib/std/special/compiler_rt/paritysi2_test.zig index c4386bcf1f..f63854e34f 100644 --- a/lib/std/special/compiler_rt/paritysi2_test.zig +++ b/lib/std/special/compiler_rt/paritysi2_test.zig @@ -1,5 +1,6 @@ +const std = @import("std"); const parity = @import("parity.zig"); -const testing = @import("std").testing; +const testing = std.testing; fn paritysi2Naive(a: i32) i32 { var x = @bitCast(u32, a); @@ -25,7 +26,7 @@ test "paritysi2" { try test__paritysi2(@bitCast(i32, @as(u32, 0xfffffffe))); try test__paritysi2(@bitCast(i32, @as(u32, 0xffffffff))); - const RndGen = @import("std").rand.DefaultPrng; + const RndGen = std.rand.DefaultPrng; var rnd = RndGen.init(42); var i: u32 = 0; while (i < 10_000) : (i += 1) { diff --git a/lib/std/special/compiler_rt/parityti2_test.zig b/lib/std/special/compiler_rt/parityti2_test.zig index 0de07df31a..e018932555 100644 --- a/lib/std/special/compiler_rt/parityti2_test.zig +++ b/lib/std/special/compiler_rt/parityti2_test.zig @@ -1,5 +1,6 @@ +const std = @import("std"); const parity = @import("parity.zig"); -const testing = @import("std").testing; +const testing = std.testing; fn parityti2Naive(a: i128) i32 { var x = @bitCast(u128, a); @@ -25,7 +26,7 @@ test "parityti2" { try test__parityti2(@bitCast(i128, @as(u128, 0xffffffff_ffffffff_ffffffff_fffffffe))); try test__parityti2(@bitCast(i128, @as(u128, 0xffffffff_ffffffff_ffffffff_ffffffff))); - const RndGen = @import("std").rand.DefaultPrng; + const RndGen = std.rand.DefaultPrng; var rnd = RndGen.init(42); var i: u32 = 0; while (i < 10_000) : (i += 1) { diff --git a/lib/std/special/compiler_rt/popcountdi2_test.zig b/lib/std/special/compiler_rt/popcountdi2_test.zig index e20693987a..e02628e636 100644 --- a/lib/std/special/compiler_rt/popcountdi2_test.zig +++ b/lib/std/special/compiler_rt/popcountdi2_test.zig @@ -1,5 +1,6 @@ +const std = @import("std"); const popcount = @import("popcount.zig"); -const testing = @import("std").testing; +const testing = std.testing; fn popcountdi2Naive(a: i64) i32 { var x = a; @@ -24,7 +25,7 @@ test "popcountdi2" { try test__popcountdi2(@bitCast(i64, @as(u64, 0xffffffff_fffffffe))); try test__popcountdi2(@bitCast(i64, @as(u64, 0xffffffff_ffffffff))); - const RndGen = @import("std").rand.DefaultPrng; + const RndGen = std.rand.DefaultPrng; var rnd = RndGen.init(42); var i: u32 = 0; while (i < 10_000) : (i += 1) { diff --git a/lib/std/special/compiler_rt/popcountsi2_test.zig b/lib/std/special/compiler_rt/popcountsi2_test.zig index c0c92e396e..7606b1a97e 100644 --- a/lib/std/special/compiler_rt/popcountsi2_test.zig +++ b/lib/std/special/compiler_rt/popcountsi2_test.zig @@ -1,5 +1,6 @@ +const std = @import("std"); const popcount = @import("popcount.zig"); -const testing = @import("std").testing; +const testing = std.testing; fn popcountsi2Naive(a: i32) i32 { var x = a; @@ -24,7 +25,7 @@ test "popcountsi2" { try test__popcountsi2(@bitCast(i32, @as(u32, 0xfffffffe))); try test__popcountsi2(@bitCast(i32, @as(u32, 0xffffffff))); - const RndGen = @import("std").rand.DefaultPrng; + const RndGen = std.rand.DefaultPrng; var rnd = RndGen.init(42); var i: u32 = 0; while (i < 10_000) : (i += 1) { diff --git a/lib/std/special/compiler_rt/popcountti2_test.zig b/lib/std/special/compiler_rt/popcountti2_test.zig index 83f2a18e7d..fae2beccd4 100644 --- a/lib/std/special/compiler_rt/popcountti2_test.zig +++ b/lib/std/special/compiler_rt/popcountti2_test.zig @@ -1,5 +1,6 @@ +const std = @import("std"); const popcount = @import("popcount.zig"); -const testing = @import("std").testing; +const testing = std.testing; fn popcountti2Naive(a: i128) i32 { var x = a; @@ -24,7 +25,7 @@ test "popcountti2" { try test__popcountti2(@bitCast(i128, @as(u128, 0xffffffff_ffffffff_ffffffff_fffffffe))); try test__popcountti2(@bitCast(i128, @as(u128, 0xffffffff_ffffffff_ffffffff_ffffffff))); - const RndGen = @import("std").rand.DefaultPrng; + const RndGen = std.rand.DefaultPrng; var rnd = RndGen.init(42); var i: u32 = 0; while (i < 10_000) : (i += 1) { diff --git a/lib/std/special/compiler_rt/truncXfYf2_test.zig b/lib/std/special/compiler_rt/truncXfYf2_test.zig index 1464c3bfcb..3f11dd0380 100644 --- a/lib/std/special/compiler_rt/truncXfYf2_test.zig +++ b/lib/std/special/compiler_rt/truncXfYf2_test.zig @@ -1,3 +1,4 @@ +const std = @import("std"); const __truncsfhf2 = @import("truncXfYf2.zig").__truncsfhf2; fn test__truncsfhf2(a: u32, expected: u16) !void { @@ -217,7 +218,7 @@ fn test__truncdfsf2(a: f64, expected: u32) void { } } - @import("std").debug.print("got 0x{x} wanted 0x{x}\n", .{ rep, expected }); + std.debug.print("got 0x{x} wanted 0x{x}\n", .{ rep, expected }); @panic("__trunctfsf2 test failure"); } @@ -248,7 +249,7 @@ fn test__trunctfhf2(a: f128, expected: u16) void { return; } - @import("std").debug.print("got 0x{x} wanted 0x{x}\n", .{ rep, expected }); + std.debug.print("got 0x{x} wanted 0x{x}\n", .{ rep, expected }); @panic("__trunctfhf2 test failure"); } diff --git a/lib/std/special/compiler_rt/udivmod.zig b/lib/std/special/compiler_rt/udivmod.zig index b2fe2048d4..d941c242d2 100644 --- a/lib/std/special/compiler_rt/udivmod.zig +++ b/lib/std/special/compiler_rt/udivmod.zig @@ -1,6 +1,7 @@ const builtin = @import("builtin"); const is_test = builtin.is_test; const native_endian = builtin.cpu.arch.endian(); +const std = @import("std"); const low = switch (native_endian) { .Big => 1, @@ -13,9 +14,9 @@ pub fn udivmod(comptime DoubleInt: type, a: DoubleInt, b: DoubleInt, maybe_rem: const double_int_bits = @typeInfo(DoubleInt).Int.bits; const single_int_bits = @divExact(double_int_bits, 2); - const SingleInt = @import("std").meta.Int(.unsigned, single_int_bits); - const SignedDoubleInt = @import("std").meta.Int(.signed, double_int_bits); - const Log2SingleInt = @import("std").math.Log2Int(SingleInt); + const SingleInt = std.meta.Int(.unsigned, single_int_bits); + const SignedDoubleInt = std.meta.Int(.signed, double_int_bits); + const Log2SingleInt = std.math.Log2Int(SingleInt); const n = @ptrCast(*const [2]SingleInt, &a).*; // TODO issue #421 const d = @ptrCast(*const [2]SingleInt, &b).*; // TODO issue #421 diff --git a/lib/std/time.zig b/lib/std/time.zig index b9580f5f3e..e8e1d1010c 100644 --- a/lib/std/time.zig +++ b/lib/std/time.zig @@ -287,5 +287,5 @@ test "Timer" { } test { - _ = @import("time/epoch.zig"); + _ = epoch; } diff --git a/lib/std/valgrind.zig b/lib/std/valgrind.zig index 91034fa03e..7532e73e49 100644 --- a/lib/std/valgrind.zig +++ b/lib/std/valgrind.zig @@ -258,6 +258,6 @@ pub const memcheck = @import("valgrind/memcheck.zig"); pub const callgrind = @import("valgrind/callgrind.zig"); test { - _ = @import("valgrind/memcheck.zig"); - _ = @import("valgrind/callgrind.zig"); + _ = memcheck; + _ = callgrind; } diff --git a/lib/std/zig/system/darwin.zig b/lib/std/zig/system/darwin.zig index c20607440d..52abddc06a 100644 --- a/lib/std/zig/system/darwin.zig +++ b/lib/std/zig/system/darwin.zig @@ -88,5 +88,5 @@ pub const DarwinSDK = struct { }; test "" { - _ = @import("darwin/macos.zig"); + _ = macos; } diff --git a/src/Compilation.zig b/src/Compilation.zig index 40aabcae36..ea243dd73d 100644 --- a/src/Compilation.zig +++ b/src/Compilation.zig @@ -34,6 +34,7 @@ const ThreadPool = @import("ThreadPool.zig"); const WaitGroup = @import("WaitGroup.zig"); const libtsan = @import("libtsan.zig"); const Zir = @import("Zir.zig"); +const Color = @import("main.zig").Color; /// General-purpose allocator. Used for both temporary and long-term storage. gpa: Allocator, @@ -148,7 +149,7 @@ owned_link_dir: ?std.fs.Dir, /// This is for stage1 and should be deleted upon completion of self-hosting. /// Don't use this for anything other than stage1 compatibility. -color: @import("main.zig").Color = .auto, +color: Color = .auto, /// This mutex guards all `Compilation` mutable state. mutex: std.Thread.Mutex = .{}, @@ -790,7 +791,7 @@ pub const InitOptions = struct { machine_code_model: std.builtin.CodeModel = .default, clang_preprocessor_mode: ClangPreprocessorMode = .no, /// This is for stage1 and should be deleted upon completion of self-hosting. - color: @import("main.zig").Color = .auto, + color: Color = .auto, test_filter: ?[]const u8 = null, test_name_prefix: ?[]const u8 = null, subsystem: ?std.Target.SubSystem = null, diff --git a/src/mingw.zig b/src/mingw.zig index 264740c333..f555634459 100644 --- a/src/mingw.zig +++ b/src/mingw.zig @@ -408,7 +408,7 @@ pub fn buildImportLib(comp: *Compilation, lib_name: []const u8) !void { errdefer comp.gpa.free(lib_final_path); const llvm = @import("codegen/llvm/bindings.zig"); - const arch_type = @import("target.zig").archToLLVM(target.cpu.arch); + const arch_type = target_util.archToLLVM(target.cpu.arch); const def_final_path_z = try arena.dupeZ(u8, def_final_path); const lib_final_path_z = try arena.dupeZ(u8, lib_final_path); if (llvm.WriteImportLibrary(def_final_path_z.ptr, arch_type, lib_final_path_z.ptr, true)) { diff --git a/src/tracy.zig b/src/tracy.zig index 033cf1bcf0..4ecae74481 100644 --- a/src/tracy.zig +++ b/src/tracy.zig @@ -1,9 +1,10 @@ const std = @import("std"); const builtin = @import("builtin"); +const build_options = @import("build_options"); -pub const enable = if (builtin.is_test) false else @import("build_options").enable_tracy; -pub const enable_allocation = enable and @import("build_options").enable_tracy_allocation; -pub const enable_callstack = enable and @import("build_options").enable_tracy_callstack; +pub const enable = if (builtin.is_test) false else build_options.enable_tracy; +pub const enable_allocation = enable and build_options.enable_tracy_allocation; +pub const enable_callstack = enable and build_options.enable_tracy_callstack; // TODO: make this configurable const callstack_depth = 10; diff --git a/src/translate_c.zig b/src/translate_c.zig index 79d68ff51b..4d993e62ea 100644 --- a/src/translate_c.zig +++ b/src/translate_c.zig @@ -820,7 +820,7 @@ fn visitVarDecl(c: *Context, var_decl: *const clang.VarDecl, mangled_name: ?[]co // The C language specification states that variables with static or threadlocal // storage without an initializer are initialized to a zero value. - // @import("std").mem.zeroes(T) + // std.mem.zeroes(T) init_node = try Tag.std_mem_zeroes.create(c.arena, type_node); } @@ -5211,7 +5211,7 @@ const MacroSlicer = struct { // mapped function exists in `std.zig.c_translation.Macros` test "Macro matching" { const helper = struct { - const MacroFunctions = @import("std").zig.c_translation.Macros; + const MacroFunctions = std.zig.c_translation.Macros; fn checkMacro(allocator: mem.Allocator, pattern_list: PatternList, source: []const u8, comptime expected_match: ?[]const u8) !void { var tok_list = std.ArrayList(CToken).init(allocator); defer tok_list.deinit(); diff --git a/test/behavior/cast.zig b/test/behavior/cast.zig index d1edefeb2d..e84eed60d4 100644 --- a/test/behavior/cast.zig +++ b/test/behavior/cast.zig @@ -2,6 +2,7 @@ const std = @import("std"); const expect = std.testing.expect; const mem = std.mem; const maxInt = std.math.maxInt; +const builtin = @import("builtin"); test "int to ptr cast" { const x = @as(usize, 13); @@ -252,10 +253,7 @@ test "array coersion to undefined at runtime" { @setRuntimeSafety(true); // TODO implement @setRuntimeSafety in stage2 - if (@import("builtin").zig_is_stage2 and - @import("builtin").mode != .Debug and - @import("builtin").mode != .ReleaseSafe) - { + if (builtin.zig_is_stage2 and builtin.mode != .Debug and builtin.mode != .ReleaseSafe) { return error.SkipZigTest; } diff --git a/test/behavior/enum_stage1.zig b/test/behavior/enum_stage1.zig index c9658918f8..f8d9d0a1b2 100644 --- a/test/behavior/enum_stage1.zig +++ b/test/behavior/enum_stage1.zig @@ -1,6 +1,7 @@ -const expect = @import("std").testing.expect; -const mem = @import("std").mem; -const Tag = @import("std").meta.Tag; +const std = @import("std"); +const expect = std.testing.expect; +const mem = std.mem; +const Tag = std.meta.Tag; test "enum value allocation" { const LargeEnum = enum(u32) { diff --git a/test/behavior/import.zig b/test/behavior/import.zig index e6c3d81111..c36aea7d2a 100644 --- a/test/behavior/import.zig +++ b/test/behavior/import.zig @@ -1,5 +1,6 @@ -const expect = @import("std").testing.expect; -const expectEqual = @import("std").testing.expectEqual; +const std = @import("std"); +const expect = std.testing.expect; +const expectEqual = std.testing.expectEqual; const a_namespace = @import("import/a_namespace.zig"); test "call fn via namespace lookup" { diff --git a/test/behavior/int128.zig b/test/behavior/int128.zig index 12367b2e9c..6bf0eca11e 100644 --- a/test/behavior/int128.zig +++ b/test/behavior/int128.zig @@ -2,6 +2,7 @@ const std = @import("std"); const expect = std.testing.expect; const maxInt = std.math.maxInt; const minInt = std.math.minInt; +const builtin = @import("builtin"); test "uint128" { var buff: u128 = maxInt(u128); @@ -21,10 +22,7 @@ test "undefined 128 bit int" { @setRuntimeSafety(true); // TODO implement @setRuntimeSafety in stage2 - if (@import("builtin").zig_is_stage2 and - @import("builtin").mode != .Debug and - @import("builtin").mode != .ReleaseSafe) - { + if (builtin.zig_is_stage2 and builtin.mode != .Debug and builtin.mode != .ReleaseSafe) { return error.SkipZigTest; } diff --git a/test/behavior/ref_var_in_if_after_if_2nd_switch_prong.zig b/test/behavior/ref_var_in_if_after_if_2nd_switch_prong.zig index 488bc1a232..df116c0565 100644 --- a/test/behavior/ref_var_in_if_after_if_2nd_switch_prong.zig +++ b/test/behavior/ref_var_in_if_after_if_2nd_switch_prong.zig @@ -1,5 +1,6 @@ -const expect = @import("std").testing.expect; -const mem = @import("std").mem; +const std = @import("std"); +const expect = std.testing.expect; +const mem = std.mem; var ok: bool = false; test "reference a variable in an if after an if in the 2nd switch prong" { diff --git a/test/behavior/reflection.zig b/test/behavior/reflection.zig index e8596c2844..18ee9d5c8b 100644 --- a/test/behavior/reflection.zig +++ b/test/behavior/reflection.zig @@ -1,5 +1,6 @@ -const expect = @import("std").testing.expect; -const mem = @import("std").mem; +const std = @import("std"); +const expect = std.testing.expect; +const mem = std.mem; const reflection = @This(); test "reflection: function return type, var args, and param types" { diff --git a/test/behavior/translate_c_macros.zig b/test/behavior/translate_c_macros.zig index 0baaf24283..0e4841020e 100644 --- a/test/behavior/translate_c_macros.zig +++ b/test/behavior/translate_c_macros.zig @@ -1,5 +1,6 @@ -const expect = @import("std").testing.expect; -const expectEqual = @import("std").testing.expectEqual; +const std = @import("std"); +const expect = std.testing.expect; +const expectEqual = std.testing.expectEqual; const h = @cImport(@cInclude("behavior/translate_c_macros.h")); diff --git a/test/behavior/translate_c_macros_stage1.zig b/test/behavior/translate_c_macros_stage1.zig index 40fbbf5263..c380508a37 100644 --- a/test/behavior/translate_c_macros_stage1.zig +++ b/test/behavior/translate_c_macros_stage1.zig @@ -1,5 +1,6 @@ -const expect = @import("std").testing.expect; -const expectEqual = @import("std").testing.expectEqual; +const std = @import("std"); +const expect = std.testing.expect; +const expectEqual = std.testing.expectEqual; const h = @cImport(@cInclude("behavior/translate_c_macros.h")); diff --git a/test/behavior/widening.zig b/test/behavior/widening.zig index 3074e96e61..afca1ae143 100644 --- a/test/behavior/widening.zig +++ b/test/behavior/widening.zig @@ -1,6 +1,7 @@ const std = @import("std"); const expect = std.testing.expect; const mem = std.mem; +const builtin = @import("builtin"); test "integer widening" { var a: u8 = 250; @@ -30,8 +31,8 @@ test "float widening" { test "float widening f16 to f128" { // TODO https://github.com/ziglang/zig/issues/3282 - if (@import("builtin").cpu.arch == .aarch64) return error.SkipZigTest; - if (@import("builtin").cpu.arch == .powerpc64le) return error.SkipZigTest; + if (builtin.cpu.arch == .aarch64) return error.SkipZigTest; + if (builtin.cpu.arch == .powerpc64le) return error.SkipZigTest; var x: f16 = 12.34; var y: f128 = x; diff --git a/test/standalone/install_raw_hex/build.zig b/test/standalone/install_raw_hex/build.zig index 9a0cba7ae8..901cff11f0 100644 --- a/test/standalone/install_raw_hex/build.zig +++ b/test/standalone/install_raw_hex/build.zig @@ -1,9 +1,8 @@ -const Builder = @import("std").build.Builder; const builtin = @import("builtin"); const std = @import("std"); const CheckFileStep = std.build.CheckFileStep; -pub fn build(b: *Builder) void { +pub fn build(b: *std.build.Builder) void { const target = .{ .cpu_arch = .thumb, .cpu_model = .{ .explicit = &std.Target.arm.cpu.cortex_m4 },