Skip to content

Commit c08b190

Browse files
authored
lint: duplicate import (#10519)
1 parent 7f4fdcc commit c08b190

29 files changed

+81
-67
lines changed

lib/std/hash.zig

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@ const wyhash = @import("hash/wyhash.zig");
3333
pub const Wyhash = wyhash.Wyhash;
3434

3535
test "hash" {
36-
_ = @import("hash/adler.zig");
37-
_ = @import("hash/auto_hash.zig");
38-
_ = @import("hash/crc.zig");
39-
_ = @import("hash/fnv.zig");
40-
_ = @import("hash/murmur.zig");
41-
_ = @import("hash/cityhash.zig");
42-
_ = @import("hash/wyhash.zig");
36+
_ = adler;
37+
_ = auto_hash;
38+
_ = crc;
39+
_ = fnv;
40+
_ = murmur;
41+
_ = cityhash;
42+
_ = wyhash;
4343
}

lib/std/special/compiler_rt/int.zig

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
// Builtin functions that operate on integer types
22
const builtin = @import("builtin");
3-
const testing = @import("std").testing;
4-
const maxInt = @import("std").math.maxInt;
5-
const minInt = @import("std").math.minInt;
3+
const std = @import("std");
4+
const testing = std.testing;
5+
const maxInt = std.math.maxInt;
6+
const minInt = std.math.minInt;
67

78
const udivmod = @import("udivmod.zig").udivmod;
89

lib/std/special/compiler_rt/multi3.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ pub fn __multi3(a: i128, b: i128) callconv(.C) i128 {
1717
return r.all;
1818
}
1919

20-
const v128 = @import("std").meta.Vector(2, u64);
20+
const v128 = std.meta.Vector(2, u64);
2121
pub fn __multi3_windows_x86_64(a: v128, b: v128) callconv(.C) v128 {
2222
return @bitCast(v128, @call(.{ .modifier = .always_inline }, __multi3, .{
2323
@bitCast(i128, a),

lib/std/special/compiler_rt/negsi2_test.zig

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1+
const std = @import("std");
12
const neg = @import("negXi2.zig");
2-
const testing = @import("std").testing;
3+
const testing = std.testing;
34

4-
const print = @import("std").debug.print;
5+
const print = std.debug.print;
56

67
fn test__negsi2(a: i32, expected: i32) !void {
78
var result = neg.__negsi2(a);

lib/std/special/compiler_rt/paritydi2_test.zig

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1+
const std = @import("std");
12
const parity = @import("parity.zig");
2-
const testing = @import("std").testing;
3+
const testing = std.testing;
34

45
fn paritydi2Naive(a: i64) i32 {
56
var x = @bitCast(u64, a);
@@ -25,7 +26,7 @@ test "paritydi2" {
2526
try test__paritydi2(@bitCast(i64, @as(u64, 0xffffffff_fffffffe)));
2627
try test__paritydi2(@bitCast(i64, @as(u64, 0xffffffff_ffffffff)));
2728

28-
const RndGen = @import("std").rand.DefaultPrng;
29+
const RndGen = std.rand.DefaultPrng;
2930
var rnd = RndGen.init(42);
3031
var i: u32 = 0;
3132
while (i < 10_000) : (i += 1) {

lib/std/special/compiler_rt/paritysi2_test.zig

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1+
const std = @import("std");
12
const parity = @import("parity.zig");
2-
const testing = @import("std").testing;
3+
const testing = std.testing;
34

45
fn paritysi2Naive(a: i32) i32 {
56
var x = @bitCast(u32, a);
@@ -25,7 +26,7 @@ test "paritysi2" {
2526
try test__paritysi2(@bitCast(i32, @as(u32, 0xfffffffe)));
2627
try test__paritysi2(@bitCast(i32, @as(u32, 0xffffffff)));
2728

28-
const RndGen = @import("std").rand.DefaultPrng;
29+
const RndGen = std.rand.DefaultPrng;
2930
var rnd = RndGen.init(42);
3031
var i: u32 = 0;
3132
while (i < 10_000) : (i += 1) {

lib/std/special/compiler_rt/parityti2_test.zig

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1+
const std = @import("std");
12
const parity = @import("parity.zig");
2-
const testing = @import("std").testing;
3+
const testing = std.testing;
34

45
fn parityti2Naive(a: i128) i32 {
56
var x = @bitCast(u128, a);
@@ -25,7 +26,7 @@ test "parityti2" {
2526
try test__parityti2(@bitCast(i128, @as(u128, 0xffffffff_ffffffff_ffffffff_fffffffe)));
2627
try test__parityti2(@bitCast(i128, @as(u128, 0xffffffff_ffffffff_ffffffff_ffffffff)));
2728

28-
const RndGen = @import("std").rand.DefaultPrng;
29+
const RndGen = std.rand.DefaultPrng;
2930
var rnd = RndGen.init(42);
3031
var i: u32 = 0;
3132
while (i < 10_000) : (i += 1) {

lib/std/special/compiler_rt/popcountdi2_test.zig

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1+
const std = @import("std");
12
const popcount = @import("popcount.zig");
2-
const testing = @import("std").testing;
3+
const testing = std.testing;
34

45
fn popcountdi2Naive(a: i64) i32 {
56
var x = a;
@@ -24,7 +25,7 @@ test "popcountdi2" {
2425
try test__popcountdi2(@bitCast(i64, @as(u64, 0xffffffff_fffffffe)));
2526
try test__popcountdi2(@bitCast(i64, @as(u64, 0xffffffff_ffffffff)));
2627

27-
const RndGen = @import("std").rand.DefaultPrng;
28+
const RndGen = std.rand.DefaultPrng;
2829
var rnd = RndGen.init(42);
2930
var i: u32 = 0;
3031
while (i < 10_000) : (i += 1) {

lib/std/special/compiler_rt/popcountsi2_test.zig

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1+
const std = @import("std");
12
const popcount = @import("popcount.zig");
2-
const testing = @import("std").testing;
3+
const testing = std.testing;
34

45
fn popcountsi2Naive(a: i32) i32 {
56
var x = a;
@@ -24,7 +25,7 @@ test "popcountsi2" {
2425
try test__popcountsi2(@bitCast(i32, @as(u32, 0xfffffffe)));
2526
try test__popcountsi2(@bitCast(i32, @as(u32, 0xffffffff)));
2627

27-
const RndGen = @import("std").rand.DefaultPrng;
28+
const RndGen = std.rand.DefaultPrng;
2829
var rnd = RndGen.init(42);
2930
var i: u32 = 0;
3031
while (i < 10_000) : (i += 1) {

lib/std/special/compiler_rt/popcountti2_test.zig

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1+
const std = @import("std");
12
const popcount = @import("popcount.zig");
2-
const testing = @import("std").testing;
3+
const testing = std.testing;
34

45
fn popcountti2Naive(a: i128) i32 {
56
var x = a;
@@ -24,7 +25,7 @@ test "popcountti2" {
2425
try test__popcountti2(@bitCast(i128, @as(u128, 0xffffffff_ffffffff_ffffffff_fffffffe)));
2526
try test__popcountti2(@bitCast(i128, @as(u128, 0xffffffff_ffffffff_ffffffff_ffffffff)));
2627

27-
const RndGen = @import("std").rand.DefaultPrng;
28+
const RndGen = std.rand.DefaultPrng;
2829
var rnd = RndGen.init(42);
2930
var i: u32 = 0;
3031
while (i < 10_000) : (i += 1) {

lib/std/special/compiler_rt/truncXfYf2_test.zig

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
const std = @import("std");
12
const __truncsfhf2 = @import("truncXfYf2.zig").__truncsfhf2;
23

34
fn test__truncsfhf2(a: u32, expected: u16) !void {
@@ -217,7 +218,7 @@ fn test__truncdfsf2(a: f64, expected: u32) void {
217218
}
218219
}
219220

220-
@import("std").debug.print("got 0x{x} wanted 0x{x}\n", .{ rep, expected });
221+
std.debug.print("got 0x{x} wanted 0x{x}\n", .{ rep, expected });
221222

222223
@panic("__trunctfsf2 test failure");
223224
}
@@ -248,7 +249,7 @@ fn test__trunctfhf2(a: f128, expected: u16) void {
248249
return;
249250
}
250251

251-
@import("std").debug.print("got 0x{x} wanted 0x{x}\n", .{ rep, expected });
252+
std.debug.print("got 0x{x} wanted 0x{x}\n", .{ rep, expected });
252253

253254
@panic("__trunctfhf2 test failure");
254255
}

lib/std/special/compiler_rt/udivmod.zig

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
const builtin = @import("builtin");
22
const is_test = builtin.is_test;
33
const native_endian = builtin.cpu.arch.endian();
4+
const std = @import("std");
45

56
const low = switch (native_endian) {
67
.Big => 1,
@@ -13,9 +14,9 @@ pub fn udivmod(comptime DoubleInt: type, a: DoubleInt, b: DoubleInt, maybe_rem:
1314

1415
const double_int_bits = @typeInfo(DoubleInt).Int.bits;
1516
const single_int_bits = @divExact(double_int_bits, 2);
16-
const SingleInt = @import("std").meta.Int(.unsigned, single_int_bits);
17-
const SignedDoubleInt = @import("std").meta.Int(.signed, double_int_bits);
18-
const Log2SingleInt = @import("std").math.Log2Int(SingleInt);
17+
const SingleInt = std.meta.Int(.unsigned, single_int_bits);
18+
const SignedDoubleInt = std.meta.Int(.signed, double_int_bits);
19+
const Log2SingleInt = std.math.Log2Int(SingleInt);
1920

2021
const n = @ptrCast(*const [2]SingleInt, &a).*; // TODO issue #421
2122
const d = @ptrCast(*const [2]SingleInt, &b).*; // TODO issue #421

lib/std/time.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,5 +287,5 @@ test "Timer" {
287287
}
288288

289289
test {
290-
_ = @import("time/epoch.zig");
290+
_ = epoch;
291291
}

lib/std/valgrind.zig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,6 @@ pub const memcheck = @import("valgrind/memcheck.zig");
258258
pub const callgrind = @import("valgrind/callgrind.zig");
259259

260260
test {
261-
_ = @import("valgrind/memcheck.zig");
262-
_ = @import("valgrind/callgrind.zig");
261+
_ = memcheck;
262+
_ = callgrind;
263263
}

lib/std/zig/system/darwin.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,5 +88,5 @@ pub const DarwinSDK = struct {
8888
};
8989

9090
test "" {
91-
_ = @import("darwin/macos.zig");
91+
_ = macos;
9292
}

src/Compilation.zig

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ const ThreadPool = @import("ThreadPool.zig");
3434
const WaitGroup = @import("WaitGroup.zig");
3535
const libtsan = @import("libtsan.zig");
3636
const Zir = @import("Zir.zig");
37+
const Color = @import("main.zig").Color;
3738

3839
/// General-purpose allocator. Used for both temporary and long-term storage.
3940
gpa: Allocator,
@@ -148,7 +149,7 @@ owned_link_dir: ?std.fs.Dir,
148149

149150
/// This is for stage1 and should be deleted upon completion of self-hosting.
150151
/// Don't use this for anything other than stage1 compatibility.
151-
color: @import("main.zig").Color = .auto,
152+
color: Color = .auto,
152153

153154
/// This mutex guards all `Compilation` mutable state.
154155
mutex: std.Thread.Mutex = .{},
@@ -790,7 +791,7 @@ pub const InitOptions = struct {
790791
machine_code_model: std.builtin.CodeModel = .default,
791792
clang_preprocessor_mode: ClangPreprocessorMode = .no,
792793
/// This is for stage1 and should be deleted upon completion of self-hosting.
793-
color: @import("main.zig").Color = .auto,
794+
color: Color = .auto,
794795
test_filter: ?[]const u8 = null,
795796
test_name_prefix: ?[]const u8 = null,
796797
subsystem: ?std.Target.SubSystem = null,

src/mingw.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@ pub fn buildImportLib(comp: *Compilation, lib_name: []const u8) !void {
408408
errdefer comp.gpa.free(lib_final_path);
409409

410410
const llvm = @import("codegen/llvm/bindings.zig");
411-
const arch_type = @import("target.zig").archToLLVM(target.cpu.arch);
411+
const arch_type = target_util.archToLLVM(target.cpu.arch);
412412
const def_final_path_z = try arena.dupeZ(u8, def_final_path);
413413
const lib_final_path_z = try arena.dupeZ(u8, lib_final_path);
414414
if (llvm.WriteImportLibrary(def_final_path_z.ptr, arch_type, lib_final_path_z.ptr, true)) {

src/tracy.zig

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
const std = @import("std");
22
const builtin = @import("builtin");
3+
const build_options = @import("build_options");
34

4-
pub const enable = if (builtin.is_test) false else @import("build_options").enable_tracy;
5-
pub const enable_allocation = enable and @import("build_options").enable_tracy_allocation;
6-
pub const enable_callstack = enable and @import("build_options").enable_tracy_callstack;
5+
pub const enable = if (builtin.is_test) false else build_options.enable_tracy;
6+
pub const enable_allocation = enable and build_options.enable_tracy_allocation;
7+
pub const enable_callstack = enable and build_options.enable_tracy_callstack;
78

89
// TODO: make this configurable
910
const callstack_depth = 10;

src/translate_c.zig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -820,7 +820,7 @@ fn visitVarDecl(c: *Context, var_decl: *const clang.VarDecl, mangled_name: ?[]co
820820
// The C language specification states that variables with static or threadlocal
821821
// storage without an initializer are initialized to a zero value.
822822

823-
// @import("std").mem.zeroes(T)
823+
// std.mem.zeroes(T)
824824
init_node = try Tag.std_mem_zeroes.create(c.arena, type_node);
825825
}
826826

@@ -5211,7 +5211,7 @@ const MacroSlicer = struct {
52115211
// mapped function exists in `std.zig.c_translation.Macros`
52125212
test "Macro matching" {
52135213
const helper = struct {
5214-
const MacroFunctions = @import("std").zig.c_translation.Macros;
5214+
const MacroFunctions = std.zig.c_translation.Macros;
52155215
fn checkMacro(allocator: mem.Allocator, pattern_list: PatternList, source: []const u8, comptime expected_match: ?[]const u8) !void {
52165216
var tok_list = std.ArrayList(CToken).init(allocator);
52175217
defer tok_list.deinit();

test/behavior/cast.zig

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ const std = @import("std");
22
const expect = std.testing.expect;
33
const mem = std.mem;
44
const maxInt = std.math.maxInt;
5+
const builtin = @import("builtin");
56

67
test "int to ptr cast" {
78
const x = @as(usize, 13);
@@ -252,10 +253,7 @@ test "array coersion to undefined at runtime" {
252253
@setRuntimeSafety(true);
253254

254255
// TODO implement @setRuntimeSafety in stage2
255-
if (@import("builtin").zig_is_stage2 and
256-
@import("builtin").mode != .Debug and
257-
@import("builtin").mode != .ReleaseSafe)
258-
{
256+
if (builtin.zig_is_stage2 and builtin.mode != .Debug and builtin.mode != .ReleaseSafe) {
259257
return error.SkipZigTest;
260258
}
261259

test/behavior/enum_stage1.zig

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
const expect = @import("std").testing.expect;
2-
const mem = @import("std").mem;
3-
const Tag = @import("std").meta.Tag;
1+
const std = @import("std");
2+
const expect = std.testing.expect;
3+
const mem = std.mem;
4+
const Tag = std.meta.Tag;
45

56
test "enum value allocation" {
67
const LargeEnum = enum(u32) {

test/behavior/import.zig

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
const expect = @import("std").testing.expect;
2-
const expectEqual = @import("std").testing.expectEqual;
1+
const std = @import("std");
2+
const expect = std.testing.expect;
3+
const expectEqual = std.testing.expectEqual;
34
const a_namespace = @import("import/a_namespace.zig");
45

56
test "call fn via namespace lookup" {

test/behavior/int128.zig

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ const std = @import("std");
22
const expect = std.testing.expect;
33
const maxInt = std.math.maxInt;
44
const minInt = std.math.minInt;
5+
const builtin = @import("builtin");
56

67
test "uint128" {
78
var buff: u128 = maxInt(u128);
@@ -21,10 +22,7 @@ test "undefined 128 bit int" {
2122
@setRuntimeSafety(true);
2223

2324
// TODO implement @setRuntimeSafety in stage2
24-
if (@import("builtin").zig_is_stage2 and
25-
@import("builtin").mode != .Debug and
26-
@import("builtin").mode != .ReleaseSafe)
27-
{
25+
if (builtin.zig_is_stage2 and builtin.mode != .Debug and builtin.mode != .ReleaseSafe) {
2826
return error.SkipZigTest;
2927
}
3028

test/behavior/ref_var_in_if_after_if_2nd_switch_prong.zig

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
const expect = @import("std").testing.expect;
2-
const mem = @import("std").mem;
1+
const std = @import("std");
2+
const expect = std.testing.expect;
3+
const mem = std.mem;
34

45
var ok: bool = false;
56
test "reference a variable in an if after an if in the 2nd switch prong" {

test/behavior/reflection.zig

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
const expect = @import("std").testing.expect;
2-
const mem = @import("std").mem;
1+
const std = @import("std");
2+
const expect = std.testing.expect;
3+
const mem = std.mem;
34
const reflection = @This();
45

56
test "reflection: function return type, var args, and param types" {

test/behavior/translate_c_macros.zig

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
const expect = @import("std").testing.expect;
2-
const expectEqual = @import("std").testing.expectEqual;
1+
const std = @import("std");
2+
const expect = std.testing.expect;
3+
const expectEqual = std.testing.expectEqual;
34

45
const h = @cImport(@cInclude("behavior/translate_c_macros.h"));
56

test/behavior/translate_c_macros_stage1.zig

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
const expect = @import("std").testing.expect;
2-
const expectEqual = @import("std").testing.expectEqual;
1+
const std = @import("std");
2+
const expect = std.testing.expect;
3+
const expectEqual = std.testing.expectEqual;
34

45
const h = @cImport(@cInclude("behavior/translate_c_macros.h"));
56

0 commit comments

Comments
 (0)