Fix unused-import warnings
authorDavid Eichmann <EichmannD@gmail.com>
Thu, 22 Nov 2018 19:48:05 +0000 (14:48 -0500)
committerBen Gamari <ben@smart-cactus.org>
Thu, 22 Nov 2018 21:10:06 +0000 (16:10 -0500)
commit6353efc7694ba8ec86c091918e02595662169ae2
tree13a255193a5a9685a97e99c020578144df21af39
parent8d008b71db53f7a59673f894f329b8d71f84c8ee
Fix unused-import warnings

This patch fixes a fairly long-standing bug (dating back to 2015) in
RdrName.bestImport, namely

   commit 9376249b6b78610db055a10d05f6592d6bbbea2f
   Author: Simon Peyton Jones <simonpj@microsoft.com>
   Date:   Wed Oct 28 17:16:55 2015 +0000

   Fix unused-import stuff in a better way

In that patch got the sense of the comparison back to front, and
thereby failed to implement the unused-import rules described in
  Note [Choosing the best import declaration] in RdrName

This led to Trac #13064 and #15393

Fixing this bug revealed a bunch of unused imports in libraries;
the ones in the GHC repo are part of this commit.

The two important changes are

* Fix the bug in bestImport

* Modified the rules by adding (a) in
     Note [Choosing the best import declaration] in RdrName
  Reason: the previosu rules made Trac #5211 go bad again.  And
  the new rule (a) makes sense to me.

In unravalling this I also ended up doing a few other things

* Refactor RnNames.ImportDeclUsage to use a [GlobalRdrElt] for the
  things that are used, rather than [AvailInfo]. This is simpler
  and more direct.

* Rename greParentName to greParent_maybe, to follow GHC
  naming conventions

* Delete dead code RdrName.greUsedRdrName

Bumps a few submodules.

Reviewers: hvr, goldfire, bgamari, simonmar, jrtc27

Subscribers: rwbarton, carter

Differential Revision: https://phabricator.haskell.org/D5312
85 files changed:
compiler/basicTypes/RdrName.hs
compiler/cmm/Bitmap.hs
compiler/cmm/CmmCommonBlockElim.hs
compiler/cmm/CmmLayoutStack.hs
compiler/cmm/CmmProcPoint.hs
compiler/cmm/Hoopl/Collections.hs
compiler/codeGen/StgCmmProf.hs
compiler/coreSyn/CoreOpt.hs
compiler/coreSyn/CorePrep.hs
compiler/coreSyn/CoreStats.hs
compiler/deSugar/DsBinds.hs
compiler/ghci/ByteCodeLink.hs
compiler/ghci/RtClosureInspect.hs
compiler/hsSyn/Convert.hs
compiler/hsSyn/HsBinds.hs
compiler/hsSyn/HsExtension.hs
compiler/hsSyn/HsImpExp.hs
compiler/hsSyn/HsTypes.hs
compiler/llvmGen/LlvmCodeGen/CodeGen.hs
compiler/main/Ar.hs
compiler/main/DynFlags.hs
compiler/main/DynamicLoading.hs
compiler/main/Finder.hs
compiler/main/GHC.hs
compiler/main/HscMain.hs
compiler/main/HscStats.hs
compiler/main/Packages.hs
compiler/nativeGen/RegAlloc/Linear/JoinToTargets.hs
compiler/nativeGen/RegAlloc/Linear/PPC/FreeRegs.hs
compiler/nativeGen/RegAlloc/Linear/SPARC/FreeRegs.hs
compiler/nativeGen/RegAlloc/Linear/X86/FreeRegs.hs
compiler/nativeGen/RegAlloc/Linear/X86_64/FreeRegs.hs
compiler/parser/RdrHsSyn.hs
compiler/rename/RnEnv.hs
compiler/rename/RnExpr.hs-boot
compiler/rename/RnNames.hs
compiler/rename/RnSource.hs
compiler/simplStg/RepType.hs
compiler/specialise/Specialise.hs
compiler/typecheck/ClsInst.hs
compiler/typecheck/TcBackpack.hs
compiler/typecheck/TcCanonical.hs
compiler/typecheck/TcDeriv.hs
compiler/typecheck/TcErrors.hs
compiler/typecheck/TcHoleErrors.hs
compiler/typecheck/TcHsSyn.hs
compiler/typecheck/TcInstDcls.hs-boot
compiler/typecheck/TcInteract.hs
compiler/typecheck/TcPatSyn.hs
compiler/typecheck/TcRnTypes.hs
compiler/typecheck/TcSMonad.hs
compiler/typecheck/TcType.hs
compiler/typecheck/TcTypeable.hs
compiler/types/TyCon.hs
compiler/utils/OrdList.hs
compiler/utils/Outputable.hs
compiler/utils/UniqSet.hs
ghc/GHCi/Leak.hs
hadrian/hadrian.cabal
hadrian/src/Hadrian/Haskell/Cabal/Parse.hs
libraries/Cabal
libraries/base/Data/Functor/Classes.hs
libraries/base/Data/Functor/Compose.hs
libraries/base/Data/Functor/Contravariant.hs
libraries/base/Data/Functor/Product.hs
libraries/base/Data/Functor/Sum.hs
libraries/base/Data/Semigroup.hs
libraries/base/GHC/Event/PSQ.hs
libraries/base/GHC/Generics.hs
libraries/base/GHC/Show.hs
libraries/base/GHC/StaticPtr.hs
libraries/bytestring
libraries/ghc-prim/GHC/Magic.hs
libraries/ghci/GHCi/CreateBCO.hs
testsuite/tests/driver/T4437.hs
testsuite/tests/module/mod177.stderr
testsuite/tests/rename/should_compile/T13064.hs [new file with mode: 0644]
testsuite/tests/rename/should_compile/T13064.stderr [new file with mode: 0644]
testsuite/tests/rename/should_compile/T4239.stdout
testsuite/tests/rename/should_compile/all.T
utils/check-api-annotations/check-api-annotations.cabal
utils/check-ppr/check-ppr.cabal
utils/ghc-cabal/ghc-cabal.cabal
utils/ghctags/Main.hs
utils/ghctags/ghctags.cabal