From cc3e9ca1641bf93fb51ff20bf546a34e7cf1862a Mon Sep 17 00:00:00 2001 From: narimiran Date: Wed, 6 Nov 2019 12:01:00 +0100 Subject: [PATCH 1/2] remove unused imports --- compiler/injectdestructors.nim | 2 +- compiler/pragmas.nim | 2 +- compiler/sempass2.nim | 3 --- compiler/sigmatch.nim | 3 --- lib/pure/concurrency/cpuinfo.nim | 5 +---- lib/pure/includes/osenv.nim | 3 ++- lib/pure/osproc.nim | 3 --- lib/pure/parseopt.nim | 3 +-- nimsuggest/nimsuggest.nim | 7 +++---- tools/dochack/fuzzysearch.nim | 1 - tools/nimfind.nim | 8 +++----- 11 files changed, 12 insertions(+), 28 deletions(-) diff --git a/compiler/injectdestructors.nim b/compiler/injectdestructors.nim index 78ab2daefd..247a71d33a 100644 --- a/compiler/injectdestructors.nim +++ b/compiler/injectdestructors.nim @@ -15,7 +15,7 @@ import - intsets, ast, astalgo, msgs, renderer, magicsys, types, idents, + intsets, ast, msgs, renderer, magicsys, types, idents, strutils, options, dfa, lowerings, tables, modulegraphs, msgs, lineinfos, parampatterns, sighashes diff --git a/compiler/pragmas.nim b/compiler/pragmas.nim index 383eaacedd..d4f0eecfd8 100644 --- a/compiler/pragmas.nim +++ b/compiler/pragmas.nim @@ -10,7 +10,7 @@ # This module implements semantic checking for pragmas import - os, platform, condsyms, ast, astalgo, idents, semdata, msgs, renderer, + os, condsyms, ast, astalgo, idents, semdata, msgs, renderer, wordrecg, ropes, options, strutils, extccomp, math, magicsys, trees, types, lookups, lineinfos, pathutils, linter diff --git a/compiler/sempass2.nim b/compiler/sempass2.nim index 88890921cd..a67da53b20 100644 --- a/compiler/sempass2.nim +++ b/compiler/sempass2.nim @@ -12,9 +12,6 @@ import wordrecg, strutils, options, guards, lineinfos, semfold, semdata, modulegraphs -when not defined(leanCompiler): - import writetracking - when defined(useDfa): import dfa diff --git a/compiler/sigmatch.nim b/compiler/sigmatch.nim index 95e292187a..c3245ca1a4 100644 --- a/compiler/sigmatch.nim +++ b/compiler/sigmatch.nim @@ -15,9 +15,6 @@ import magicsys, idents, lexer, options, parampatterns, strutils, trees, linter, lineinfos, lowerings, modulegraphs -when (defined(booting) or defined(nimsuggest)) and not defined(leanCompiler): - import docgen - type MismatchKind* = enum kUnknown, kAlreadyGiven, kUnknownNamedParam, kTypeMismatch, kVarNeeded, diff --git a/lib/pure/concurrency/cpuinfo.nim b/lib/pure/concurrency/cpuinfo.nim index 415b9a7872..a3d78db61f 100644 --- a/lib/pure/concurrency/cpuinfo.nim +++ b/lib/pure/concurrency/cpuinfo.nim @@ -12,10 +12,7 @@ include "system/inclrtl" when not defined(windows): - import strutils, posix, os - -when defined(linux): - import linux + import posix when defined(freebsd) or defined(macosx): {.emit:"#include ".} diff --git a/lib/pure/includes/osenv.nim b/lib/pure/includes/osenv.nim index 1ddc51f8f5..30904c6884 100644 --- a/lib/pure/includes/osenv.nim +++ b/lib/pure/includes/osenv.nim @@ -3,7 +3,8 @@ when not declared(os) and not declared(ospaths): {.error: "This is an include file for os.nim!".} -from parseutils import skipIgnoreCase +when defined(windows): + from parseutils import skipIgnoreCase proc c_getenv(env: cstring): cstring {. importc: "getenv", header: "".} diff --git a/lib/pure/osproc.nim b/lib/pure/osproc.nim index 4d1cc2280c..2726340fb8 100644 --- a/lib/pure/osproc.nim +++ b/lib/pure/osproc.nim @@ -27,9 +27,6 @@ when defined(windows): else: import posix -when defined(linux): - import linux - type ProcessOption* = enum ## Options that can be passed to `startProcess proc ## <#startProcess,string,string,openArray[string],StringTableRef,set[ProcessOption]>`_. diff --git a/lib/pure/parseopt.nim b/lib/pure/parseopt.nim index 23978c964c..d0fcd5dae7 100644 --- a/lib/pure/parseopt.nim +++ b/lib/pure/parseopt.nim @@ -151,8 +151,7 @@ include "system/inclrtl" -import - os, strutils +import os type CmdLineKind* = enum ## The detected command line token. diff --git a/nimsuggest/nimsuggest.nim b/nimsuggest/nimsuggest.nim index 7e31427620..a48e9443d8 100644 --- a/nimsuggest/nimsuggest.nim +++ b/nimsuggest/nimsuggest.nim @@ -17,10 +17,9 @@ import strutils, os, parseopt, parseutils, sequtils, net, rdstdin, sexp # suggestionResultHook, because suggest.nim is included by sigmatch. # So we import that one instead. import compiler / [options, commands, modules, sem, - passes, passaux, msgs, nimconf, - extccomp, condsyms, - sigmatch, ast, scriptconfig, - idents, modulegraphs, vm, prefixmatches, lineinfos, cmdlinehelper, + passes, passaux, msgs, + sigmatch, ast, + idents, modulegraphs, prefixmatches, lineinfos, cmdlinehelper, pathutils] when defined(windows): diff --git a/tools/dochack/fuzzysearch.nim b/tools/dochack/fuzzysearch.nim index 1e5c8f0ef8..05f61bc116 100644 --- a/tools/dochack/fuzzysearch.nim +++ b/tools/dochack/fuzzysearch.nim @@ -5,7 +5,6 @@ # import strutils import math -import macros const diff --git a/tools/nimfind.nim b/tools/nimfind.nim index b9c7d8ac97..7d99cbe834 100644 --- a/tools/nimfind.nim +++ b/tools/nimfind.nim @@ -28,13 +28,11 @@ In addition, all command line options of Nim that do not affect code generation are supported. """ -import strutils, os, parseopt, parseutils +import strutils, os, parseopt import "../compiler" / [options, commands, modules, sem, - passes, passaux, msgs, nimconf, - extccomp, condsyms, - ast, scriptconfig, - idents, modulegraphs, vm, prefixmatches, lineinfos, cmdlinehelper, + passes, passaux, msgs, ast, + idents, modulegraphs, lineinfos, cmdlinehelper, pathutils] import db_sqlite From c6a451c5848fecc9e6b11a1cb1e33bf3c68b7571 Mon Sep 17 00:00:00 2001 From: narimiran Date: Wed, 6 Nov 2019 13:59:31 +0100 Subject: [PATCH 2/2] remove unused imports from tests --- tests/ccgbugs/tmissingderef2.nim | 2 +- tests/ccgbugs/tuple_canon.nim | 3 +-- tests/float/tfloat4.nim | 2 +- tests/iter/titer_issues.nim | 2 +- tests/macros/tgettype.nim | 2 +- tests/macros/tgettypeinst.nim | 2 +- tests/macros/tmacro1.nim | 3 --- tests/macros/tmacro4.nim | 3 +-- tests/macros/tmacros1.nim | 3 +-- tests/metatype/tymatrix.nim | 2 -- tests/misc/tbug511622.nim | 2 +- tools/niminst/niminst.nim | 2 +- 12 files changed, 10 insertions(+), 18 deletions(-) diff --git a/tests/ccgbugs/tmissingderef2.nim b/tests/ccgbugs/tmissingderef2.nim index 59cd24dd16..23be61bcbe 100644 --- a/tests/ccgbugs/tmissingderef2.nim +++ b/tests/ccgbugs/tmissingderef2.nim @@ -4,7 +4,7 @@ discard """ # bug #5079 -import tables, strutils +import tables type Test = ref object s: string diff --git a/tests/ccgbugs/tuple_canon.nim b/tests/ccgbugs/tuple_canon.nim index 6719860546..aa9605d4ba 100644 --- a/tests/ccgbugs/tuple_canon.nim +++ b/tests/ccgbugs/tuple_canon.nim @@ -12,8 +12,7 @@ foo = bar # No error if assigned directly # bug #2250 -import - math, strutils +import math type Meters = float diff --git a/tests/float/tfloat4.nim b/tests/float/tfloat4.nim index 56280111c2..6a87cbe663 100644 --- a/tests/float/tfloat4.nim +++ b/tests/float/tfloat4.nim @@ -2,7 +2,7 @@ discard """ output: "passed all tests." """ -import math, strutils +import strutils proc c_sprintf(buf, fmt: cstring) {.importc:"sprintf", header: "", varargs.} diff --git a/tests/iter/titer_issues.nim b/tests/iter/titer_issues.nim index 773e7dbffc..a7830dfabd 100644 --- a/tests/iter/titer_issues.nim +++ b/tests/iter/titer_issues.nim @@ -22,7 +22,7 @@ end """ -import algorithm, math, sequtils, strutils +import sequtils, strutils block t338: diff --git a/tests/macros/tgettype.nim b/tests/macros/tgettype.nim index 77a55471ff..bd70a1c306 100644 --- a/tests/macros/tgettype.nim +++ b/tests/macros/tgettype.nim @@ -4,7 +4,7 @@ output: ''' (BracketExpr (Sym "typeDesc") (Sym "User")) ''' """ -import strutils, macros +import macros type Model = object of RootObj diff --git a/tests/macros/tgettypeinst.nim b/tests/macros/tgettypeinst.nim index 00e9865fad..2f95571604 100644 --- a/tests/macros/tgettypeinst.nim +++ b/tests/macros/tgettypeinst.nim @@ -1,7 +1,7 @@ discard """ """ -import macros, strUtils +import macros proc symToIdent(x: NimNode): NimNode = case x.kind: diff --git a/tests/macros/tmacro1.nim b/tests/macros/tmacro1.nim index 844738c825..7e9120b650 100644 --- a/tests/macros/tmacro1.nim +++ b/tests/macros/tmacro1.nim @@ -1,7 +1,5 @@ import macros -from uri import `/` - macro test*(a: untyped): untyped = var nodes: tuple[a, b: int] nodes.a = 4 @@ -22,7 +20,6 @@ macro test*(a: untyped): untyped = test: "hi" -import strutils template assertNot(arg: untyped): untyped = assert(not(arg)) diff --git a/tests/macros/tmacro4.nim b/tests/macros/tmacro4.nim index 7c2839aba4..cb0399894c 100644 --- a/tests/macros/tmacro4.nim +++ b/tests/macros/tmacro4.nim @@ -2,8 +2,7 @@ discard """ output: "after" """ -import - macros, strutils +import macros macro test_macro*(s: string, n: untyped): untyped = result = newNimNode(nnkStmtList) diff --git a/tests/macros/tmacros1.nim b/tests/macros/tmacros1.nim index 706281d133..53af4287ce 100644 --- a/tests/macros/tmacros1.nim +++ b/tests/macros/tmacros1.nim @@ -5,8 +5,7 @@ discard """ {a, b}''' """ -import - macros, strutils +import macros macro outterMacro*(n, blck: untyped): untyped = let n = callsite() diff --git a/tests/metatype/tymatrix.nim b/tests/metatype/tymatrix.nim index 14c4d8c889..cf36bfa63a 100644 --- a/tests/metatype/tymatrix.nim +++ b/tests/metatype/tymatrix.nim @@ -1,5 +1,3 @@ -import typetraits - template reject(e) = static: assert(not compiles(e)) diff --git a/tests/misc/tbug511622.nim b/tests/misc/tbug511622.nim index 4b30e96e6e..1af6380ed2 100644 --- a/tests/misc/tbug511622.nim +++ b/tests/misc/tbug511622.nim @@ -1,7 +1,7 @@ discard """ output: "3" """ -import StrUtils, Math +import math proc FibonacciA(n: int): int64 = var fn = float64(n) diff --git a/tools/niminst/niminst.nim b/tools/niminst/niminst.nim index 1ea3870f28..558184904b 100644 --- a/tools/niminst/niminst.nim +++ b/tools/niminst/niminst.nim @@ -14,7 +14,7 @@ when haveZipLib: import zipfiles import - os, osproc, strutils, parseopt, parsecfg, strtabs, streams, debcreation, + os, strutils, parseopt, parsecfg, strtabs, streams, debcreation, std / sha1 const