Commit c08b190c69

Meghan <hello@nektro.net>
2022-01-07 06:06:06
lint: duplicate import (#10519)
1 parent 7f4fdcc
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;
 
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),
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);
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) {
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) {
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) {
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) {
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) {
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) {
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");
 }
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
lib/std/zig/system/darwin.zig
@@ -88,5 +88,5 @@ pub const DarwinSDK = struct {
 };
 
 test "" {
-    _ = @import("darwin/macos.zig");
+    _ = macos;
 }
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;
 }
lib/std/time.zig
@@ -287,5 +287,5 @@ test "Timer" {
 }
 
 test {
-    _ = @import("time/epoch.zig");
+    _ = epoch;
 }
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;
 }
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,
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)) {
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;
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();
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;
     }
 
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) {
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" {
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;
     }
 
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" {
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" {
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"));
 
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"));
 
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;
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 },