diff options
author | Simon Peyton Jones <simonpj@microsoft.com> | 2018-08-20 09:48:41 +0100 |
---|---|---|
committer | Simon Peyton Jones <simonpj@microsoft.com> | 2018-08-20 14:21:38 +0100 |
commit | 2dcebe69f07f9b4328bc3dc2131ccf2953ffa21b (patch) | |
tree | 2106ada6f22bd198dc1891f1283740d26bf4047d /compiler/hsSyn | |
parent | a08b285f74cd49196feb0f819d70ad0508689da3 (diff) | |
download | haskell-wip/T13064.tar.gz |
Fix unused-import warningswip/T13064
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
* Slightly change the spec of the unused function
HsImpExpr.ieLWrappedName, and use it in RnNames.findImportUsage
Diffstat (limited to 'compiler/hsSyn')
-rw-r--r-- | compiler/hsSyn/Convert.hs | 1 | ||||
-rw-r--r-- | compiler/hsSyn/HsBinds.hs | 1 | ||||
-rw-r--r-- | compiler/hsSyn/HsImpExp.hs | 4 |
3 files changed, 2 insertions, 4 deletions
diff --git a/compiler/hsSyn/Convert.hs b/compiler/hsSyn/Convert.hs index fbecf9ce9e..0dc2d9aef4 100644 --- a/compiler/hsSyn/Convert.hs +++ b/compiler/hsSyn/Convert.hs @@ -23,7 +23,6 @@ import RdrName import qualified Name import Module import RdrHsSyn -import qualified OccName import OccName import SrcLoc import Type diff --git a/compiler/hsSyn/HsBinds.hs b/compiler/hsSyn/HsBinds.hs index 98f503b0d9..c541a129ce 100644 --- a/compiler/hsSyn/HsBinds.hs +++ b/compiler/hsSyn/HsBinds.hs @@ -44,7 +44,6 @@ import DynFlags import Data.Data hiding ( Fixity ) import Data.List hiding ( foldr ) import Data.Ord -import Data.Foldable ( Foldable(..) ) {- ************************************************************************ diff --git a/compiler/hsSyn/HsImpExp.hs b/compiler/hsSyn/HsImpExp.hs index 39bd9b7e18..a48fdb2f3e 100644 --- a/compiler/hsSyn/HsImpExp.hs +++ b/compiler/hsSyn/HsImpExp.hs @@ -281,8 +281,8 @@ ieWrappedName (IEName (L _ n)) = n ieWrappedName (IEPattern (L _ n)) = n ieWrappedName (IEType (L _ n)) = n -ieLWrappedName :: LIEWrappedName name -> Located name -ieLWrappedName (L l n) = L l (ieWrappedName n) +ieLWrappedName :: LIEWrappedName name -> name +ieLWrappedName (L l n) = ieWrappedName n replaceWrappedName :: IEWrappedName name1 -> name2 -> IEWrappedName name2 replaceWrappedName (IEName (L l _)) n = IEName (L l n) |