[commit: ghc] wip/T13064: Fix unused-import warnings (2dcebe6)

git at git.haskell.org git at git.haskell.org
Mon Aug 20 13:22:21 UTC 2018


Repository : ssh://git@git.haskell.org/ghc

On branch  : wip/T13064
Link       : http://ghc.haskell.org/trac/ghc/changeset/2dcebe69f07f9b4328bc3dc2131ccf2953ffa21b/ghc

>---------------------------------------------------------------

commit 2dcebe69f07f9b4328bc3dc2131ccf2953ffa21b
Author: Simon Peyton Jones <simonpj at microsoft.com>
Date:   Mon Aug 20 09:48:41 2018 +0100

    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 at 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
    
    * Slightly change the spec of the unused function
      HsImpExpr.ieLWrappedName, and use it in RnNames.findImportUsage


>---------------------------------------------------------------

2dcebe69f07f9b4328bc3dc2131ccf2953ffa21b
 compiler/basicTypes/RdrName.hs                     | 102 ++++++---
 compiler/cmm/CmmSink.hs                            |   1 -
 compiler/codeGen/StgCmmProf.hs                     |   1 -
 compiler/ghci/ByteCodeLink.hs                      |   1 -
 compiler/ghci/RtClosureInspect.hs                  |   1 -
 compiler/hsSyn/Convert.hs                          |   1 -
 compiler/hsSyn/HsBinds.hs                          |   1 -
 compiler/hsSyn/HsImpExp.hs                         |   4 +-
 compiler/llvmGen/LlvmCodeGen/CodeGen.hs            |   1 -
 compiler/main/Ar.hs                                |   1 -
 compiler/main/DynFlags.hs                          |   2 +
 compiler/main/DynamicLoading.hs                    |   5 +-
 compiler/main/GHC.hs                               |   2 -
 compiler/main/HscMain.hs                           |   1 -
 compiler/main/Packages.hs                          |   1 -
 compiler/parser/RdrHsSyn.hs                        |   1 -
 compiler/rename/RnEnv.hs                           |  19 +-
 compiler/rename/RnExpr.hs-boot                     |   1 -
 compiler/rename/RnNames.hs                         | 231 +++++++++++----------
 compiler/specialise/Specialise.hs                  |   1 -
 compiler/typecheck/ClsInst.hs                      |   2 -
 compiler/typecheck/TcDeriv.hs                      |   2 +-
 compiler/typecheck/TcErrors.hs                     |   2 +-
 compiler/typecheck/TcHsSyn.hs                      |   1 -
 compiler/typecheck/TcInstDcls.hs-boot              |   1 -
 compiler/typecheck/TcInteract.hs                   |   2 +-
 compiler/typecheck/TcPatSyn.hs                     |   3 +-
 compiler/typecheck/TcRnTypes.hs                    |   3 +-
 compiler/typecheck/TcSMonad.hs                     |   1 -
 compiler/typecheck/TcTypeable.hs                   |   1 -
 compiler/types/TyCon.hs                            |   3 +-
 compiler/utils/OrdList.hs                          |   1 -
 compiler/utils/Outputable.hs                       |   1 -
 ghc/GHCi/Leak.hs                                   |   2 +-
 libraries/base/Data/Functor/Classes.hs             |   1 -
 libraries/base/Data/Functor/Compose.hs             |   2 -
 libraries/base/Data/Functor/Contravariant.hs       |   1 -
 libraries/base/Data/Functor/Product.hs             |   3 -
 libraries/base/Data/Functor/Sum.hs                 |   2 -
 libraries/base/Data/Semigroup.hs                   |   3 -
 libraries/base/GHC/Event/PSQ.hs                    |   1 -
 libraries/base/GHC/Generics.hs                     |   2 +-
 libraries/base/GHC/Show.hs                         |   1 -
 libraries/base/GHC/StaticPtr.hs                    |   1 -
 libraries/ghc-prim/GHC/Magic.hs                    |   2 +-
 testsuite/tests/module/mod177.stderr               |   2 +-
 .../ghci/duplicaterecfldsghci01.stdout             |  18 +-
 testsuite/tests/rename/should_compile/T13064.hs    |   8 +
 .../tests/rename/should_compile/T13064.stderr      |   3 +
 testsuite/tests/rename/should_compile/T4239.stdout |   2 +-
 testsuite/tests/rename/should_compile/all.T        |   1 +
 .../tests/rename/should_fail/rnfail044.stderr      |   9 +-
 52 files changed, 253 insertions(+), 212 deletions(-)

Diff suppressed because of size. To see it, use:

    git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc 2dcebe69f07f9b4328bc3dc2131ccf2953ffa21b


More information about the ghc-commits mailing list