[commit: ghc] wip/T13064: Fix unused-import warnings (9bcc2ba)

git at git.haskell.org git at git.haskell.org
Mon Aug 20 09:07:55 UTC 2018


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

On branch  : wip/T13064
Link       : http://ghc.haskell.org/trac/ghc/changeset/9bcc2bab3d84a77dc544acac6000d7f4e8b68033/ghc

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

commit 9bcc2bab3d84a77dc544acac6000d7f4e8b68033
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


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

9bcc2bab3d84a77dc544acac6000d7f4e8b68033
 compiler/basicTypes/RdrName.hs                     | 102 ++++++---
 compiler/hsSyn/HsImpExp.hs                         |   4 +-
 compiler/main/Ar.hs                                |   1 -
 compiler/main/DynamicLoading.hs                    |   5 +-
 compiler/main/GHC.hs                               |   2 -
 compiler/main/HscMain.hs                           |   1 -
 compiler/parser/RdrHsSyn.hs                        |   1 -
 compiler/rename/RnEnv.hs                           |  19 +-
 compiler/rename/RnNames.hs                         | 231 +++++++++++----------
 compiler/typecheck/ClsInst.hs                      |   1 -
 compiler/typecheck/TcDeriv.hs                      |   2 +-
 compiler/typecheck/TcErrors.hs                     |   2 +-
 compiler/typecheck/TcRnTypes.hs                    |   3 +-
 compiler/typecheck/TcSMonad.hs                     |   1 -
 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 +-
 32 files changed, 247 insertions(+), 190 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 9bcc2bab3d84a77dc544acac6000d7f4e8b68033


More information about the ghc-commits mailing list