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/typecheck | |
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/typecheck')
-rw-r--r-- | compiler/typecheck/ClsInst.hs | 2 | ||||
-rw-r--r-- | compiler/typecheck/TcDeriv.hs | 2 | ||||
-rw-r--r-- | compiler/typecheck/TcErrors.hs | 2 | ||||
-rw-r--r-- | compiler/typecheck/TcHsSyn.hs | 1 | ||||
-rw-r--r-- | compiler/typecheck/TcInstDcls.hs-boot | 1 | ||||
-rw-r--r-- | compiler/typecheck/TcInteract.hs | 2 | ||||
-rw-r--r-- | compiler/typecheck/TcPatSyn.hs | 3 | ||||
-rw-r--r-- | compiler/typecheck/TcRnTypes.hs | 3 | ||||
-rw-r--r-- | compiler/typecheck/TcSMonad.hs | 1 | ||||
-rw-r--r-- | compiler/typecheck/TcTypeable.hs | 1 |
10 files changed, 6 insertions, 12 deletions
diff --git a/compiler/typecheck/ClsInst.hs b/compiler/typecheck/ClsInst.hs index de957b71fd..c0a54e48cc 100644 --- a/compiler/typecheck/ClsInst.hs +++ b/compiler/typecheck/ClsInst.hs @@ -29,9 +29,7 @@ import Id import Type import MkCore ( mkStringExprFS, mkNaturalExpr ) -import Unique ( hasKey ) import Name ( Name ) -import Var ( DFunId ) import DataCon import TyCon import Class diff --git a/compiler/typecheck/TcDeriv.hs b/compiler/typecheck/TcDeriv.hs index 6f749fc60f..409cccbc72 100644 --- a/compiler/typecheck/TcDeriv.hs +++ b/compiler/typecheck/TcDeriv.hs @@ -26,7 +26,7 @@ import TcValidity( allDistinctTyVars ) import TcClassDcl( instDeclCtxt3, tcATDefault, tcMkDeclCtxt ) import TcEnv import TcGenDeriv -- Deriv stuff -import TcValidity +import TcValidity( checkValidInstHead ) import InstEnv import Inst import FamInstEnv diff --git a/compiler/typecheck/TcErrors.hs b/compiler/typecheck/TcErrors.hs index bc5b061a9e..ce75259203 100644 --- a/compiler/typecheck/TcErrors.hs +++ b/compiler/typecheck/TcErrors.hs @@ -64,7 +64,7 @@ import qualified Data.Set as Set import {-# SOURCE #-} TcHoleErrors ( findValidHoleFits ) -import Data.Semigroup ( Semigroup ) +-- import Data.Semigroup ( Semigroup ) import qualified Data.Semigroup as Semigroup diff --git a/compiler/typecheck/TcHsSyn.hs b/compiler/typecheck/TcHsSyn.hs index 77e2a246cb..ee00acaad3 100644 --- a/compiler/typecheck/TcHsSyn.hs +++ b/compiler/typecheck/TcHsSyn.hs @@ -56,7 +56,6 @@ import TcEvidence import TysPrim import TyCon import TysWiredIn -import TyCoRep( CoercionHole(..) ) import Type import Coercion import ConLike diff --git a/compiler/typecheck/TcInstDcls.hs-boot b/compiler/typecheck/TcInstDcls.hs-boot index e7240903e4..ea0f50fd36 100644 --- a/compiler/typecheck/TcInstDcls.hs-boot +++ b/compiler/typecheck/TcInstDcls.hs-boot @@ -9,7 +9,6 @@ import HsSyn import TcRnTypes import TcEnv( InstInfo ) import TcDeriv -import HsExtension ( GhcRn ) -- We need this because of the mutual recursion -- between TcTyClsDecls and TcInstDcls diff --git a/compiler/typecheck/TcInteract.hs b/compiler/typecheck/TcInteract.hs index 028b755187..cb1747cdb0 100644 --- a/compiler/typecheck/TcInteract.hs +++ b/compiler/typecheck/TcInteract.hs @@ -27,7 +27,7 @@ import Class import TyCon import FunDeps import FamInst -import ClsInst( ClsInstResult(..), InstanceWhat(..), safeOverlap ) +import ClsInst( InstanceWhat(..), safeOverlap ) import FamInstEnv import Unify ( tcUnifyTyWithTFs, ruleMatchTyKiX ) diff --git a/compiler/typecheck/TcPatSyn.hs b/compiler/typecheck/TcPatSyn.hs index fabe16a1e0..c9dbc0f02f 100644 --- a/compiler/typecheck/TcPatSyn.hs +++ b/compiler/typecheck/TcPatSyn.hs @@ -17,10 +17,9 @@ import GhcPrelude import HsSyn import TcPat -import Type( mkEmptyTCvSubst, tidyTyVarBinders, tidyTypes, tidyType ) +import Type( tidyTyVarBinders, tidyTypes, tidyType ) import TcRnMonad import TcSigs( emptyPragEnv, completeSigFromId ) -import TcType( mkMinimalBySCs ) import TcEnv import TcMType import TcHsSyn( zonkTyVarBindersX, zonkTcTypeToTypes diff --git a/compiler/typecheck/TcRnTypes.hs b/compiler/typecheck/TcRnTypes.hs index ca5639b297..b240585f65 100644 --- a/compiler/typecheck/TcRnTypes.hs +++ b/compiler/typecheck/TcRnTypes.hs @@ -155,7 +155,7 @@ import TcEvidence import Type import Class ( Class ) import TyCon ( TyCon, TyConFlavour, tyConKind ) -import TyCoRep ( CoercionHole(..), coHoleCoVar ) +import TyCoRep ( coHoleCoVar ) import Coercion ( Coercion, mkHoleCo ) import ConLike ( ConLike(..) ) import DataCon ( DataCon, dataConUserType, dataConOrigArgTys ) @@ -556,6 +556,7 @@ data TcGblEnv tcg_dus :: DefUses, -- ^ What is defined in this module and what is used. tcg_used_gres :: TcRef [GlobalRdrElt], -- ^ Records occurrences of imported entities + -- One entry for each occurrence; but may have different GREs for the same Name -- See Note [Tracking unused binding and imports] tcg_keep :: TcRef NameSet, diff --git a/compiler/typecheck/TcSMonad.hs b/compiler/typecheck/TcSMonad.hs index 5bf5cefe01..ad7d332781 100644 --- a/compiler/typecheck/TcSMonad.hs +++ b/compiler/typecheck/TcSMonad.hs @@ -143,7 +143,6 @@ import Kind import TcType import DynFlags import Type -import TyCoRep( coHoleCoVar ) import Coercion import Unify diff --git a/compiler/typecheck/TcTypeable.hs b/compiler/typecheck/TcTypeable.hs index ad266f658f..146c8515b6 100644 --- a/compiler/typecheck/TcTypeable.hs +++ b/compiler/typecheck/TcTypeable.hs @@ -31,7 +31,6 @@ import Type import Kind ( isTYPEApp ) import TyCon import DataCon -import Name ( getOccName ) import Module import HsSyn import DynFlags |