Skip to content

Commit

Permalink
Merge pull request #11771 from nim-lang/araq-remove-unused-imports
Browse files Browse the repository at this point in the history
[refactoring] remove unused imports in the compiler and in some stdli…
  • Loading branch information
Araq committed Jul 18, 2019
2 parents f50e450 + 07d465c commit 4becd5a
Show file tree
Hide file tree
Showing 76 changed files with 531 additions and 558 deletions.
3 changes: 1 addition & 2 deletions compiler/ast.nim
Expand Up @@ -10,8 +10,7 @@
# abstract syntax tree + symbol table

import
lineinfos, hashes, nversion, options, strutils, std / sha1, ropes, idents,
intsets, idgen
lineinfos, hashes, options, ropes, idents, idgen

type
TCallingConvention* = enum
Expand Down
4 changes: 2 additions & 2 deletions compiler/ccgmerge.nim
Expand Up @@ -11,8 +11,8 @@
## is needed for incremental compilation.

import
ast, astalgo, ropes, options, strutils, nimlexbase, msgs, cgendata, rodutils,
intsets, platform, llstream, tables, sighashes, modulegraphs, pathutils
ast, ropes, options, strutils, nimlexbase, cgendata, rodutils,
intsets, llstream, tables, modulegraphs, pathutils

# Careful! Section marks need to contain a tabulator so that they cannot
# be part of C string literals.
Expand Down
2 changes: 1 addition & 1 deletion compiler/ccgutils.nim
Expand Up @@ -10,7 +10,7 @@
# This module declares some helpers for the C code generator.

import
ast, astalgo, ropes, hashes, strutils, types, msgs, wordrecg,
ast, hashes, strutils, msgs, wordrecg,
platform, trees, options

proc getPragmaStmt*(n: PNode, w: TSpecialWord): PNode =
Expand Down
4 changes: 2 additions & 2 deletions compiler/cgen.nim
Expand Up @@ -11,9 +11,9 @@

import
ast, astalgo, hashes, trees, platform, magicsys, extccomp, options, intsets,
nversion, nimsets, msgs, std / sha1, bitsets, idents, types,
nversion, nimsets, msgs, bitsets, idents, types,
ccgutils, os, ropes, math, passes, wordrecg, treetab, cgmeth,
condsyms, rodutils, renderer, idgen, cgendata, ccgmerge, semfold, aliases,
condsyms, rodutils, renderer, cgendata, ccgmerge, aliases,
lowerings, tables, sets, ndi, lineinfos, pathutils, transf, enumtostr

when not defined(leanCompiler):
Expand Down
2 changes: 1 addition & 1 deletion compiler/cgendata.nim
Expand Up @@ -10,7 +10,7 @@
## This module contains the data structures for the C code generation phase.

import
ast, astalgo, ropes, passes, options, intsets, platform, sighashes,
ast, ropes, passes, options, intsets,
tables, ndi, lineinfos, pathutils, modulegraphs

type
Expand Down
2 changes: 1 addition & 1 deletion compiler/cgmeth.nim
Expand Up @@ -10,7 +10,7 @@
## This module implements code generation for multi methods.

import
intsets, options, ast, astalgo, msgs, idents, renderer, types, magicsys,
intsets, options, ast, msgs, idents, renderer, types, magicsys,
sempass2, strutils, modulegraphs, lineinfos

proc genConv(n: PNode, d: PType, downcast: bool; conf: ConfigRef): PNode =
Expand Down
4 changes: 2 additions & 2 deletions compiler/closureiters.nim
Expand Up @@ -131,8 +131,8 @@
# break :stateLoop

import
intsets, strutils, options, ast, astalgo, trees, treetab, msgs, idents,
renderer, types, magicsys, lowerings, lambdalifting, modulegraphs, lineinfos
ast, msgs, idents,
renderer, magicsys, lowerings, lambdalifting, modulegraphs, lineinfos

type
Ctx = object
Expand Down
2 changes: 1 addition & 1 deletion compiler/commands.nim
Expand Up @@ -27,7 +27,7 @@ bootSwitch(usedNoGC, defined(nogc), "--gc:none")

import
os, msgs, options, nversion, condsyms, strutils, extccomp, platform,
wordrecg, parseutils, nimblecmd, idents, parseopt, sequtils, lineinfos,
wordrecg, parseutils, nimblecmd, parseopt, sequtils, lineinfos,
pathutils, strtabs

# but some have deps to imported modules. Yay.
Expand Down
2 changes: 1 addition & 1 deletion compiler/condsyms.nim
Expand Up @@ -10,7 +10,7 @@
# This module handles the conditional symbols.

import
strtabs, platform, strutils, idents
strtabs

from options import Feature
from lineinfos import HintsToStr, WarningsToStr
Expand Down
3 changes: 1 addition & 2 deletions compiler/depends.nim
Expand Up @@ -10,8 +10,7 @@
# This module implements a dependency file generator.

import
os, options, ast, astalgo, msgs, ropes, idents, passes, modulepaths,
pathutils
options, ast, ropes, idents, passes, modulepaths, pathutils

from modulegraphs import ModuleGraph, PPassContext

Expand Down
2 changes: 1 addition & 1 deletion compiler/dfa.nim
Expand Up @@ -29,7 +29,7 @@
## "A Graph–Free Approach to Data–Flow Analysis" by Markus Mohnen.
## https://link.springer.com/content/pdf/10.1007/3-540-45937-5_6.pdf

import ast, astalgo, types, intsets, tables, msgs, options, lineinfos, renderer
import ast, types, intsets, lineinfos, renderer

from patterns import sameTrees

Expand Down
2 changes: 1 addition & 1 deletion compiler/docgen.nim
Expand Up @@ -16,7 +16,7 @@ import
wordrecg, syntaxes, renderer, lexer, packages/docutils/rstast,
packages/docutils/rst, packages/docutils/rstgen,
packages/docutils/highlite, json, xmltree, cgi, trees, types,
typesrenderer, astalgo, modulepaths, lineinfos, sequtils, intsets,
typesrenderer, astalgo, modulepaths, lineinfos, intsets,
pathutils, trees

const
Expand Down
3 changes: 1 addition & 2 deletions compiler/docgen2.nim
Expand Up @@ -11,8 +11,7 @@
# semantic checking.

import
os, options, ast, astalgo, msgs, ropes, idents, passes, docgen, lineinfos,
pathutils
options, ast, msgs, idents, passes, docgen, lineinfos, pathutils

from modulegraphs import ModuleGraph, PPassContext

Expand Down
3 changes: 1 addition & 2 deletions compiler/evaltempl.nim
Expand Up @@ -10,8 +10,7 @@
## Template evaluation engine. Now hygienic.

import
strutils, options, ast, astalgo, msgs, os, idents, wordrecg, renderer,
lineinfos
strutils, options, ast, astalgo, msgs, renderer, lineinfos

type
TemplCtx = object
Expand Down
4 changes: 2 additions & 2 deletions compiler/filter_tmpl.nim
Expand Up @@ -10,8 +10,8 @@
# This module implements Nim's standard template filter.

import
llstream, os, wordrecg, idents, strutils, ast, astalgo, msgs, options,
renderer, filters, lineinfos, pathutils
llstream, strutils, ast, msgs, options,
filters, lineinfos, pathutils

type
TParseState = enum
Expand Down
2 changes: 1 addition & 1 deletion compiler/filters.nim
Expand Up @@ -10,7 +10,7 @@
# This module implements Nim's simple filters and helpers for filters.

import
llstream, os, wordrecg, idents, strutils, ast, astalgo, msgs, options,
llstream, idents, strutils, ast, msgs, options,
renderer, pathutils

proc invalidPragma(conf: ConfigRef; n: PNode) =
Expand Down
2 changes: 1 addition & 1 deletion compiler/gorgeimpl.nim
Expand Up @@ -9,7 +9,7 @@

## Module that implements ``gorge`` for the compiler.

import msgs, std / sha1, os, osproc, streams, strutils, options,
import msgs, std / sha1, os, osproc, streams, options,
lineinfos, pathutils

proc readOutput(p: Process): (string, int) =
Expand Down
2 changes: 1 addition & 1 deletion compiler/idents.nim
Expand Up @@ -12,7 +12,7 @@
# id. This module is essential for the compiler's performance.

import
hashes, strutils, wordrecg
hashes, wordrecg

type
TIdObj* = object of RootObj
Expand Down
2 changes: 1 addition & 1 deletion compiler/idgen.nim
Expand Up @@ -9,7 +9,7 @@

## This module contains a simple persistent id generator.

import idents, strutils, os, options, pathutils
import idents, strutils, options, pathutils

var gFrontEndId*: int

Expand Down
4 changes: 2 additions & 2 deletions compiler/importer.nim
Expand Up @@ -10,8 +10,8 @@
## This module implements the symbol importing mechanism.

import
intsets, strutils, os, ast, astalgo, msgs, options, idents, lookups,
semdata, passes, renderer, modulepaths, sigmatch, lineinfos
intsets, ast, astalgo, msgs, options, idents, lookups,
semdata, modulepaths, sigmatch, lineinfos

proc readExceptSet*(c: PContext, n: PNode): IntSet =
assert n.kind in {nkImportExceptStmt, nkExportExceptStmt}
Expand Down
4 changes: 2 additions & 2 deletions compiler/incremental.nim
Expand Up @@ -12,10 +12,10 @@

const nimIncremental* = defined(nimIncremental)

import options, lineinfos, pathutils
import options, lineinfos

when nimIncremental:
import ast, msgs, intsets, btrees, db_sqlite, std / sha1
import ast, msgs, intsets, btrees, db_sqlite, std / sha1, pathutils
from strutils import parseInt

type
Expand Down
2 changes: 1 addition & 1 deletion compiler/injectdestructors.nim
Expand Up @@ -134,7 +134,7 @@ to do it.
]#

import
intsets, ast, astalgo, msgs, renderer, magicsys, types, idents, trees,
intsets, ast, msgs, renderer, magicsys, types, idents,
strutils, options, dfa, lowerings, tables, modulegraphs, msgs,
lineinfos, parampatterns, sighashes

Expand Down
8 changes: 4 additions & 4 deletions compiler/jsgen.nim
Expand Up @@ -29,11 +29,11 @@ implements the required case distinction.


import
ast, astalgo, strutils, hashes, trees, platform, magicsys, extccomp, options,
nversion, nimsets, msgs, std / sha1, bitsets, idents, types, os, tables,
times, ropes, math, passes, ccgutils, wordrecg, renderer,
ast, strutils, trees, magicsys, options,
nversion, msgs, idents, types, tables,
ropes, math, passes, ccgutils, wordrecg, renderer,
intsets, cgmeth, lowerings, sighashes, modulegraphs, lineinfos, rodutils,
pathutils, transf
transf


from modulegraphs import ModuleGraph, PPassContext
Expand Down
2 changes: 1 addition & 1 deletion compiler/lambdalifting.nim
Expand Up @@ -10,7 +10,7 @@
# This file implements lambda lifting for the transformator.

import
intsets, strutils, options, ast, astalgo, trees, treetab, msgs,
intsets, strutils, options, ast, astalgo, msgs,
idents, renderer, types, magicsys, lowerings, tables, modulegraphs, lineinfos,
transf, liftdestructors

Expand Down
2 changes: 1 addition & 1 deletion compiler/liftdestructors.nim
Expand Up @@ -13,7 +13,7 @@
# Todo:
# - use openArray instead of array to avoid over-specializations

import modulegraphs, lineinfos, idents, ast, astalgo, renderer, semdata,
import modulegraphs, lineinfos, idents, ast, renderer, semdata,
sighashes, lowerings, options, types, msgs, magicsys, tables

type
Expand Down
2 changes: 1 addition & 1 deletion compiler/liftlocals.nim
Expand Up @@ -10,7 +10,7 @@
## This module implements the '.liftLocals' pragma.

import
intsets, strutils, options, ast, astalgo, msgs,
strutils, options, ast, msgs,
idents, renderer, types, lowerings, lineinfos

from pragmas import getPragmaVal
Expand Down
6 changes: 2 additions & 4 deletions compiler/linter.nim
Expand Up @@ -9,11 +9,9 @@

## This module implements the style checker.

import
strutils, os, intsets, strtabs
import strutils

import options, ast, astalgo, msgs, semdata, ropes, idents,
lineinfos, pathutils, wordrecg
import options, ast, msgs, idents, lineinfos, wordrecg

const
Letters* = {'a'..'z', 'A'..'Z', '0'..'9', '\x80'..'\xFF', '_'}
Expand Down
2 changes: 1 addition & 1 deletion compiler/llstream.nim
Expand Up @@ -10,7 +10,7 @@
## Low-level streams for high performance.

import
strutils, pathutils
pathutils

# support '-d:useGnuReadline' for backwards compatibility:
when not defined(windows) and (defined(useGnuReadline) or defined(useLinenoise)):
Expand Down
2 changes: 1 addition & 1 deletion compiler/lookups.nim
Expand Up @@ -11,7 +11,7 @@

import
intsets, ast, astalgo, idents, semdata, types, msgs, options,
renderer, wordrecg, idgen, nimfix/prettybase, lineinfos, strutils
renderer, nimfix/prettybase, lineinfos, strutils

proc ensureNoMissingOrUnusedSymbols(c: PContext; scope: PScope)

Expand Down
1 change: 0 additions & 1 deletion compiler/lowerings.nim
Expand Up @@ -14,7 +14,6 @@ const

import ast, astalgo, types, idents, magicsys, msgs, options, modulegraphs,
lineinfos
from trees import getMagic

proc newDeref*(n: PNode): PNode {.inline.} =
result = newNodeIT(nkHiddenDeref, n.info, n.typ.sons[0])
Expand Down
2 changes: 1 addition & 1 deletion compiler/macrocacheimpl.nim
Expand Up @@ -9,7 +9,7 @@

## This module implements helpers for the macro cache.

import lineinfos, ast, modulegraphs, vmdef, magicsys
import lineinfos, ast, modulegraphs, vmdef

proc recordInc*(c: PCtx; info: TLineInfo; key: string; by: BiggestInt) =
var recorded = newNodeI(nkCommentStmt, info)
Expand Down
2 changes: 1 addition & 1 deletion compiler/magicsys.nim
Expand Up @@ -10,7 +10,7 @@
# Built-in types and compilerprocs are registered here.

import
ast, astalgo, hashes, msgs, platform, nversion, times, idents,
ast, astalgo, msgs, platform, idents,
modulegraphs, lineinfos

export createMagic
Expand Down
10 changes: 5 additions & 5 deletions compiler/main.nim
Expand Up @@ -13,12 +13,12 @@ when not defined(nimcore):
{.error: "nimcore MUST be defined for Nim's core tooling".}

import
llstream, strutils, ast, astalgo, lexer, syntaxes, renderer, options, msgs,
os, condsyms, times,
wordrecg, sem, semdata, idents, passes, extccomp,
llstream, strutils, ast, lexer, syntaxes, options, msgs,
condsyms, times,
sem, idents, passes, extccomp,
cgen, json, nversion,
platform, nimconf, importer, passaux, depends, vm, vmdef, types, idgen,
parser, modules, ccgutils, sigmatch, ropes,
platform, nimconf, passaux, depends, vm, idgen,
parser, modules,
modulegraphs, tables, rod, lineinfos, pathutils

when not defined(leanCompiler):
Expand Down
2 changes: 1 addition & 1 deletion compiler/modulepaths.nim
Expand Up @@ -8,7 +8,7 @@
#

import ast, renderer, strutils, msgs, options, idents, os, lineinfos,
pathutils, nimblecmd
pathutils

when false:
const
Expand Down
4 changes: 2 additions & 2 deletions compiler/modules.nim
Expand Up @@ -10,8 +10,8 @@
## Implements the module handling, including the caching of modules.

import
ast, astalgo, magicsys, std / sha1, msgs, cgendata, sigmatch, options,
idents, os, lexer, idgen, passes, syntaxes, llstream, modulegraphs, rod,
ast, astalgo, magicsys, msgs, options,
idents, lexer, idgen, passes, syntaxes, llstream, modulegraphs, rod,
lineinfos, pathutils, tables

proc resetSystemArtifacts*(g: ModuleGraph) =
Expand Down
2 changes: 1 addition & 1 deletion compiler/msgs.nim
Expand Up @@ -8,7 +8,7 @@
#

import
options, strutils, os, tables, ropes, platform, terminal, macros,
options, strutils, os, tables, ropes, terminal, macros,
lineinfos, pathutils

proc toCChar*(c: char; result: var string) =
Expand Down
6 changes: 3 additions & 3 deletions compiler/nim.nim
Expand Up @@ -19,9 +19,9 @@ when defined(i386) and defined(windows) and defined(vcc):
{.link: "../icons/nim-i386-windows-vcc.res".}

import
commands, lexer, condsyms, options, msgs, nversion, nimconf, ropes,
extccomp, strutils, os, osproc, platform, main, parseopt,
scriptconfig, idents, modulegraphs, lineinfos, cmdlinehelper,
commands, options, msgs,
extccomp, strutils, os, main, parseopt,
idents, lineinfos, cmdlinehelper,
pathutils

include nodejs
Expand Down
2 changes: 1 addition & 1 deletion compiler/nimconf.nim
Expand Up @@ -10,7 +10,7 @@
# This module handles the reading of the config file.

import
llstream, nversion, commands, os, strutils, msgs, platform, condsyms, lexer,
llstream, commands, os, strutils, msgs, lexer,
options, idents, wordrecg, strtabs, lineinfos, pathutils

# ---------------- configuration file parser -----------------------------
Expand Down
2 changes: 0 additions & 2 deletions compiler/nimfix/prettybase.nim
Expand Up @@ -8,9 +8,7 @@
#

import strutils except Letters
import lexbase, streams
import ".." / [ast, msgs, lineinfos, idents, options, linter]
from os import splitFile

proc replaceDeprecated*(conf: ConfigRef; info: TLineInfo; oldSym, newSym: PIdent) =
let line = sourceLine(conf, info)
Expand Down

0 comments on commit 4becd5a

Please sign in to comment.