summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--compiler/basicTypes/RdrName.hs102
-rw-r--r--compiler/cmm/Bitmap.hs1
-rw-r--r--compiler/cmm/CmmCommonBlockElim.hs1
-rw-r--r--compiler/cmm/CmmLayoutStack.hs2
-rw-r--r--compiler/cmm/CmmProcPoint.hs2
-rw-r--r--compiler/cmm/Hoopl/Collections.hs2
-rw-r--r--compiler/codeGen/StgCmmProf.hs1
-rw-r--r--compiler/coreSyn/CoreOpt.hs2
-rw-r--r--compiler/coreSyn/CorePrep.hs2
-rw-r--r--compiler/coreSyn/CoreStats.hs2
-rw-r--r--compiler/deSugar/DsBinds.hs2
-rw-r--r--compiler/ghci/ByteCodeLink.hs1
-rw-r--r--compiler/ghci/RtClosureInspect.hs5
-rw-r--r--compiler/hsSyn/Convert.hs1
-rw-r--r--compiler/hsSyn/HsBinds.hs1
-rw-r--r--compiler/hsSyn/HsExtension.hs1
-rw-r--r--compiler/hsSyn/HsImpExp.hs3
-rw-r--r--compiler/hsSyn/HsTypes.hs1
-rw-r--r--compiler/llvmGen/LlvmCodeGen/CodeGen.hs1
-rw-r--r--compiler/main/Ar.hs1
-rw-r--r--compiler/main/DynFlags.hs2
-rw-r--r--compiler/main/DynamicLoading.hs5
-rw-r--r--compiler/main/Finder.hs1
-rw-r--r--compiler/main/GHC.hs2
-rw-r--r--compiler/main/HscMain.hs1
-rw-r--r--compiler/main/HscStats.hs1
-rw-r--r--compiler/main/Packages.hs1
-rw-r--r--compiler/nativeGen/RegAlloc/Linear/JoinToTargets.hs2
-rw-r--r--compiler/nativeGen/RegAlloc/Linear/PPC/FreeRegs.hs1
-rw-r--r--compiler/nativeGen/RegAlloc/Linear/SPARC/FreeRegs.hs1
-rw-r--r--compiler/nativeGen/RegAlloc/Linear/X86/FreeRegs.hs1
-rw-r--r--compiler/nativeGen/RegAlloc/Linear/X86_64/FreeRegs.hs1
-rw-r--r--compiler/parser/RdrHsSyn.hs1
-rw-r--r--compiler/rename/RnEnv.hs19
-rw-r--r--compiler/rename/RnExpr.hs-boot1
-rw-r--r--compiler/rename/RnNames.hs233
-rw-r--r--compiler/rename/RnSource.hs2
-rw-r--r--compiler/simplStg/RepType.hs2
-rw-r--r--compiler/specialise/Specialise.hs1
-rw-r--r--compiler/typecheck/ClsInst.hs2
-rw-r--r--compiler/typecheck/TcBackpack.hs2
-rw-r--r--compiler/typecheck/TcCanonical.hs2
-rw-r--r--compiler/typecheck/TcDeriv.hs2
-rw-r--r--compiler/typecheck/TcErrors.hs2
-rw-r--r--compiler/typecheck/TcHoleErrors.hs1
-rw-r--r--compiler/typecheck/TcHsSyn.hs1
-rw-r--r--compiler/typecheck/TcInstDcls.hs-boot1
-rw-r--r--compiler/typecheck/TcInteract.hs4
-rw-r--r--compiler/typecheck/TcPatSyn.hs4
-rw-r--r--compiler/typecheck/TcRnTypes.hs5
-rw-r--r--compiler/typecheck/TcSMonad.hs3
-rw-r--r--compiler/typecheck/TcType.hs2
-rw-r--r--compiler/typecheck/TcTypeable.hs1
-rw-r--r--compiler/types/TyCon.hs4
-rw-r--r--compiler/utils/OrdList.hs1
-rw-r--r--compiler/utils/Outputable.hs1
-rw-r--r--compiler/utils/UniqSet.hs1
-rw-r--r--ghc/GHCi/Leak.hs2
-rw-r--r--hadrian/hadrian.cabal2
-rw-r--r--hadrian/src/Hadrian/Haskell/Cabal/Parse.hs2
m---------libraries/Cabal0
-rw-r--r--libraries/base/Data/Functor/Classes.hs1
-rw-r--r--libraries/base/Data/Functor/Compose.hs2
-rw-r--r--libraries/base/Data/Functor/Contravariant.hs1
-rw-r--r--libraries/base/Data/Functor/Product.hs3
-rw-r--r--libraries/base/Data/Functor/Sum.hs2
-rw-r--r--libraries/base/Data/Semigroup.hs3
-rw-r--r--libraries/base/GHC/Event/PSQ.hs1
-rw-r--r--libraries/base/GHC/Generics.hs2
-rw-r--r--libraries/base/GHC/Show.hs1
-rw-r--r--libraries/base/GHC/StaticPtr.hs1
m---------libraries/bytestring0
-rw-r--r--libraries/ghc-prim/GHC/Magic.hs10
-rw-r--r--libraries/ghci/GHCi/CreateBCO.hs2
-rw-r--r--testsuite/tests/driver/T4437.hs1
-rw-r--r--testsuite/tests/module/mod177.stderr2
-rw-r--r--testsuite/tests/rename/should_compile/T13064.hs8
-rw-r--r--testsuite/tests/rename/should_compile/T13064.stderr3
-rw-r--r--testsuite/tests/rename/should_compile/T4239.stdout2
-rw-r--r--testsuite/tests/rename/should_compile/all.T1
-rw-r--r--utils/check-api-annotations/check-api-annotations.cabal2
-rw-r--r--utils/check-ppr/check-ppr.cabal2
-rw-r--r--utils/ghc-cabal/ghc-cabal.cabal2
-rw-r--r--utils/ghctags/Main.hs2
-rw-r--r--utils/ghctags/ghctags.cabal2
85 files changed, 275 insertions, 238 deletions
diff --git a/compiler/basicTypes/RdrName.hs b/compiler/basicTypes/RdrName.hs
index 45f23249bc..6a3db51399 100644
--- a/compiler/basicTypes/RdrName.hs
+++ b/compiler/basicTypes/RdrName.hs
@@ -53,14 +53,14 @@ module RdrName (
-- * GlobalRdrElts
gresFromAvails, gresFromAvail, localGREsFromAvail, availFromGRE,
- greUsedRdrName, greRdrNames, greSrcSpan, greQualModName,
+ greRdrNames, greSrcSpan, greQualModName,
gresToAvailInfo,
-- ** Global 'RdrName' mapping elements: 'GlobalRdrElt', 'Provenance', 'ImportSpec'
GlobalRdrElt(..), isLocalGRE, isRecFldGRE, greLabel,
unQualOK, qualSpecOK, unQualSpecOK,
pprNameProvenance,
- Parent(..),
+ Parent(..), greParent_maybe,
ImportSpec(..), ImpDeclSpec(..), ImpItemSpec(..),
importSpecLoc, importSpecModule, isExplicitItem, bestImport,
@@ -657,18 +657,6 @@ greQualModName gre@(GRE { gre_name = name, gre_lcl = lcl, gre_imp = iss })
| (is:_) <- iss = is_as (is_decl is)
| otherwise = pprPanic "greQualModName" (ppr gre)
-greUsedRdrName :: GlobalRdrElt -> RdrName
--- For imported things, return a RdrName to add to the used-RdrName
--- set, which is used to generate unused-import-decl warnings.
--- Return a Qual RdrName if poss, so that identifies the most
--- specific ImportSpec. See Trac #10890 for some good examples.
-greUsedRdrName gre@GRE{ gre_name = name, gre_lcl = lcl, gre_imp = iss }
- | lcl, Just mod <- nameModule_maybe name = Qual (moduleName mod) occ
- | not (null iss), is <- bestImport iss = Qual (is_as (is_decl is)) occ
- | otherwise = pprTrace "greUsedRdrName" (ppr gre) (Unqual occ)
- where
- occ = greOccName gre
-
greRdrNames :: GlobalRdrElt -> [RdrName]
greRdrNames gre@GRE{ gre_lcl = lcl, gre_imp = iss }
= (if lcl then [unqual] else []) ++ concatMap do_spec (map is_decl iss)
@@ -696,11 +684,11 @@ mkParent _ (Avail _) = NoParent
mkParent n (AvailTC m _ _) | n == m = NoParent
| otherwise = ParentIs m
-greParentName :: GlobalRdrElt -> Maybe Name
-greParentName gre = case gre_par gre of
- NoParent -> Nothing
- ParentIs n -> Just n
- FldParent n _ -> Just n
+greParent_maybe :: GlobalRdrElt -> Maybe Name
+greParent_maybe gre = case gre_par gre of
+ NoParent -> Nothing
+ ParentIs n -> Just n
+ FldParent n _ -> Just n
-- | Takes a list of distinct GREs and folds them
-- into AvailInfos. This is more efficient than mapping each individual
@@ -716,7 +704,7 @@ gresToAvailInfo gres
add :: NameEnv AvailInfo -> GlobalRdrElt -> NameEnv AvailInfo
add env gre = extendNameEnv_Acc comb availFromGRE env
(fromMaybe (gre_name gre)
- (greParentName gre)) gre
+ (greParent_maybe gre)) gre
where
-- We want to insert the child `k` into a list of children but
@@ -1192,10 +1180,7 @@ instance Ord ImpItemSpec where
bestImport :: [ImportSpec] -> ImportSpec
--- Given a non-empty bunch of ImportSpecs, return the one that
--- imported the item most specifically (e.g. by name), using
--- textually-first as a tie breaker. This is used when reporting
--- redundant imports
+-- See Note [Choosing the best import declaration]
bestImport iss
= case sortBy best iss of
(is:_) -> is
@@ -1203,17 +1188,76 @@ bestImport iss
where
best :: ImportSpec -> ImportSpec -> Ordering
-- Less means better
+ -- Unqualified always wins over qualified; then
+ -- import-all wins over import-some; then
+ -- earlier declaration wins over later
best (ImpSpec { is_item = item1, is_decl = d1 })
(ImpSpec { is_item = item2, is_decl = d2 })
- = best_item item1 item2 `thenCmp` (is_dloc d1 `compare` is_dloc d2)
+ = (is_qual d1 `compare` is_qual d2) `thenCmp`
+ (best_item item1 item2) `thenCmp`
+ (is_dloc d1 `compare` is_dloc d2)
best_item :: ImpItemSpec -> ImpItemSpec -> Ordering
best_item ImpAll ImpAll = EQ
- best_item ImpAll (ImpSome {}) = GT
- best_item (ImpSome {}) ImpAll = LT
+ best_item ImpAll (ImpSome {}) = LT
+ best_item (ImpSome {}) ImpAll = GT
best_item (ImpSome { is_explicit = e1 })
- (ImpSome { is_explicit = e2 }) = e2 `compare` e1
- -- False < True, so if e1 is explicit and e2 is not, we get LT
+ (ImpSome { is_explicit = e2 }) = e1 `compare` e2
+ -- False < True, so if e1 is explicit and e2 is not, we get GT
+
+{- Note [Choosing the best import declaration]
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+When reporting unused import declarations we use the following rules.
+ (see [wiki:Commentary/Compiler/UnusedImports])
+
+Say that an import-item is either
+ * an entire import-all decl (eg import Foo), or
+ * a particular item in an import list (eg import Foo( ..., x, ...)).
+The general idea is that for each /occurrence/ of an imported name, we will
+attribute that use to one import-item. Once we have processed all the
+occurrences, any import items with no uses attributed to them are unused,
+and are warned about. More precisely:
+
+1. For every RdrName in the program text, find its GlobalRdrElt.
+
+2. Then, from the [ImportSpec] (gre_imp) of that GRE, choose one
+ the "chosen import-item", and mark it "used". This is done
+ by 'bestImport'
+
+3. After processing all the RdrNames, bleat about any
+ import-items that are unused.
+ This is done in RnNames.warnUnusedImportDecls.
+
+The function 'bestImport' returns the dominant import among the
+ImportSpecs it is given, implementing Step 2. We say import-item A
+dominates import-item B if we choose A over B. In general, we try to
+choose the import that is most likely to render other imports
+unnecessary. Here is the dominance relationship we choose:
+
+ a) import Foo dominates import qualified Foo.
+
+ b) import Foo dominates import Foo(x).
+
+ c) Otherwise choose the textually first one.
+
+Rationale for (a). Consider
+ import qualified M -- Import #1
+ import M( x ) -- Import #2
+ foo = M.x + x
+
+The unqualified 'x' can only come from import #2. The qualified 'M.x'
+could come from either, but bestImport picks import #2, because it is
+more likely to be useful in other imports, as indeed it is in this
+case (see Trac #5211 for a concrete example).
+
+But the rules are not perfect; consider
+ import qualified M -- Import #1
+ import M( x ) -- Import #2
+ foo = M.x + M.y
+
+The M.x will use import #2, but M.y can only use import #1.
+-}
+
unQualSpecOK :: ImportSpec -> Bool
-- ^ Is in scope unqualified?
diff --git a/compiler/cmm/Bitmap.hs b/compiler/cmm/Bitmap.hs
index e6ac15f4a8..42acc5f3cd 100644
--- a/compiler/cmm/Bitmap.hs
+++ b/compiler/cmm/Bitmap.hs
@@ -21,7 +21,6 @@ import SMRep
import DynFlags
import Util
-import Data.Foldable (foldl')
import Data.Bits
{-|
diff --git a/compiler/cmm/CmmCommonBlockElim.hs b/compiler/cmm/CmmCommonBlockElim.hs
index 1af9a84028..b43d68970f 100644
--- a/compiler/cmm/CmmCommonBlockElim.hs
+++ b/compiler/cmm/CmmCommonBlockElim.hs
@@ -29,7 +29,6 @@ import qualified TrieMap as TM
import UniqFM
import Unique
import Control.Arrow (first, second)
-import Data.List (foldl')
-- -----------------------------------------------------------------------------
-- Eliminate common blocks
diff --git a/compiler/cmm/CmmLayoutStack.hs b/compiler/cmm/CmmLayoutStack.hs
index 1d6c209953..3b3f49e20b 100644
--- a/compiler/cmm/CmmLayoutStack.hs
+++ b/compiler/cmm/CmmLayoutStack.hs
@@ -37,7 +37,7 @@ import qualified Data.Set as Set
import Control.Monad.Fix
import Data.Array as Array
import Data.Bits
-import Data.List (nub, foldl')
+import Data.List (nub)
{- Note [Stack Layout]
diff --git a/compiler/cmm/CmmProcPoint.hs b/compiler/cmm/CmmProcPoint.hs
index bef8f384b8..427de3bb3d 100644
--- a/compiler/cmm/CmmProcPoint.hs
+++ b/compiler/cmm/CmmProcPoint.hs
@@ -19,7 +19,7 @@ import CmmUtils
import CmmInfo
import CmmLive
import CmmSwitch
-import Data.List (sortBy, foldl')
+import Data.List (sortBy)
import Maybes
import Control.Monad
import Outputable
diff --git a/compiler/cmm/Hoopl/Collections.hs b/compiler/cmm/Hoopl/Collections.hs
index d7f53a0bad..4c5516be79 100644
--- a/compiler/cmm/Hoopl/Collections.hs
+++ b/compiler/cmm/Hoopl/Collections.hs
@@ -17,7 +17,7 @@ import GhcPrelude
import qualified Data.IntMap.Strict as M
import qualified Data.IntSet as S
-import Data.List (foldl', foldl1')
+import Data.List (foldl1')
class IsSet set where
type ElemOf set
diff --git a/compiler/codeGen/StgCmmProf.hs b/compiler/codeGen/StgCmmProf.hs
index 15c31ca59c..172b77c8f9 100644
--- a/compiler/codeGen/StgCmmProf.hs
+++ b/compiler/codeGen/StgCmmProf.hs
@@ -35,7 +35,6 @@ import Cmm
import CmmUtils
import CLabel
-import qualified Module
import CostCentre
import DynFlags
import FastString
diff --git a/compiler/coreSyn/CoreOpt.hs b/compiler/coreSyn/CoreOpt.hs
index aebd0e3828..f4fc94d2ae 100644
--- a/compiler/coreSyn/CoreOpt.hs
+++ b/compiler/coreSyn/CoreOpt.hs
@@ -32,7 +32,7 @@ import PprCore ( pprCoreBindings, pprRules )
import OccurAnal( occurAnalyseExpr, occurAnalysePgm )
import Literal ( Literal(LitString) )
import Id
-import Var ( varType, isNonCoVarId )
+import Var ( isNonCoVarId )
import VarSet
import VarEnv
import DataCon
diff --git a/compiler/coreSyn/CorePrep.hs b/compiler/coreSyn/CorePrep.hs
index 58a7162dca..cf37a8d93b 100644
--- a/compiler/coreSyn/CorePrep.hs
+++ b/compiler/coreSyn/CorePrep.hs
@@ -60,7 +60,7 @@ import Name ( NamedThing(..), nameSrcSpan )
import SrcLoc ( SrcSpan(..), realSrcLocSpan, mkRealSrcLoc )
import Data.Bits
import MonadUtils ( mapAccumLM )
-import Data.List ( mapAccumL, foldl' )
+import Data.List ( mapAccumL )
import Control.Monad
import CostCentre ( CostCentre, ccFromThisModule )
import qualified Data.Set as S
diff --git a/compiler/coreSyn/CoreStats.hs b/compiler/coreSyn/CoreStats.hs
index 826ffe171e..fde107b372 100644
--- a/compiler/coreSyn/CoreStats.hs
+++ b/compiler/coreSyn/CoreStats.hs
@@ -21,8 +21,6 @@ import Var
import Type (Type, typeSize)
import Id (isJoinId)
-import Data.List (foldl')
-
data CoreStats = CS { cs_tm :: !Int -- Terms
, cs_ty :: !Int -- Types
, cs_co :: !Int -- Coercions
diff --git a/compiler/deSugar/DsBinds.hs b/compiler/deSugar/DsBinds.hs
index 447fea4871..f322e1457c 100644
--- a/compiler/deSugar/DsBinds.hs
+++ b/compiler/deSugar/DsBinds.hs
@@ -53,7 +53,7 @@ import Name
import VarSet
import Rules
import VarEnv
-import Var( EvVar, varType )
+import Var( EvVar )
import Outputable
import Module
import SrcLoc
diff --git a/compiler/ghci/ByteCodeLink.hs b/compiler/ghci/ByteCodeLink.hs
index e7eb7108f9..9a5fb39e6d 100644
--- a/compiler/ghci/ByteCodeLink.hs
+++ b/compiler/ghci/ByteCodeLink.hs
@@ -41,7 +41,6 @@ import Util
-- Standard libraries
import Data.Array.Unboxed
import Foreign.Ptr
-import GHC.IO ( IO(..) )
import GHC.Exts
{-
diff --git a/compiler/ghci/RtClosureInspect.hs b/compiler/ghci/RtClosureInspect.hs
index 167ea1b6ac..f4d09cc6de 100644
--- a/compiler/ghci/RtClosureInspect.hs
+++ b/compiler/ghci/RtClosureInspect.hs
@@ -57,16 +57,15 @@ import TysWiredIn
import DynFlags
import Outputable as Ppr
import GHC.Char
-import GHC.Exts
import GHC.Exts.Heap
-import GHC.IO ( IO(..) )
import SMRep ( roundUpTo )
import Control.Monad
-import Data.Array.Base
import Data.Maybe
import Data.List
#if defined(INTEGER_GMP)
+import GHC.Exts
+import Data.Array.Base
import GHC.Integer.GMP.Internals
#endif
import qualified Data.Sequence as Seq
diff --git a/compiler/hsSyn/Convert.hs b/compiler/hsSyn/Convert.hs
index 8bd33d6a5b..92fc77ed6c 100644
--- a/compiler/hsSyn/Convert.hs
+++ b/compiler/hsSyn/Convert.hs
@@ -22,7 +22,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/HsExtension.hs b/compiler/hsSyn/HsExtension.hs
index 43653a52bd..2dff478e55 100644
--- a/compiler/hsSyn/HsExtension.hs
+++ b/compiler/hsSyn/HsExtension.hs
@@ -18,7 +18,6 @@ module HsExtension where
import GhcPrelude
-import GHC.Exts (Constraint)
import Data.Data hiding ( Fixity )
import PlaceHolder
import Name
diff --git a/compiler/hsSyn/HsImpExp.hs b/compiler/hsSyn/HsImpExp.hs
index 39bd9b7e18..d97be4bd54 100644
--- a/compiler/hsSyn/HsImpExp.hs
+++ b/compiler/hsSyn/HsImpExp.hs
@@ -281,6 +281,9 @@ ieWrappedName (IEName (L _ n)) = n
ieWrappedName (IEPattern (L _ n)) = n
ieWrappedName (IEType (L _ n)) = n
+lieWrappedName :: LIEWrappedName name -> name
+lieWrappedName (L _ n) = ieWrappedName n
+
ieLWrappedName :: LIEWrappedName name -> Located name
ieLWrappedName (L l n) = L l (ieWrappedName n)
diff --git a/compiler/hsSyn/HsTypes.hs b/compiler/hsSyn/HsTypes.hs
index f0f71be738..1d44bffa2f 100644
--- a/compiler/hsSyn/HsTypes.hs
+++ b/compiler/hsSyn/HsTypes.hs
@@ -90,7 +90,6 @@ import FastString
import Maybes( isJust )
import Data.Data hiding ( Fixity, Prefix, Infix )
-import Data.List ( foldl' )
import Data.Maybe ( fromMaybe )
{-
diff --git a/compiler/llvmGen/LlvmCodeGen/CodeGen.hs b/compiler/llvmGen/LlvmCodeGen/CodeGen.hs
index bb82049dda..6071bd82e5 100644
--- a/compiler/llvmGen/LlvmCodeGen/CodeGen.hs
+++ b/compiler/llvmGen/LlvmCodeGen/CodeGen.hs
@@ -38,7 +38,6 @@ import Util
import Control.Monad.Trans.Class
import Control.Monad.Trans.Writer
-import Data.Semigroup ( Semigroup )
import qualified Data.Semigroup as Semigroup
import Data.List ( nub )
import Data.Maybe ( catMaybes )
diff --git a/compiler/main/Ar.hs b/compiler/main/Ar.hs
index 814b71e248..1f1b44ed35 100644
--- a/compiler/main/Ar.hs
+++ b/compiler/main/Ar.hs
@@ -34,7 +34,6 @@ module Ar
import GhcPrelude
-import Data.Semigroup (Semigroup)
import Data.List (mapAccumL, isPrefixOf)
import Data.Monoid ((<>))
import Data.Binary.Get
diff --git a/compiler/main/DynFlags.hs b/compiler/main/DynFlags.hs
index 654c347d3f..a93da7b3b0 100644
--- a/compiler/main/DynFlags.hs
+++ b/compiler/main/DynFlags.hs
@@ -248,7 +248,9 @@ import qualified EnumSet
import GHC.Foreign (withCString, peekCString)
import qualified GHC.LanguageExtensions as LangExt
+#if defined(GHCI)
import Foreign (Ptr) -- needed for 2nd stage
+#endif
-- Note [Updating flag description in the User's Guide]
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
diff --git a/compiler/main/DynamicLoading.hs b/compiler/main/DynamicLoading.hs
index 764bf2dd41..7420f7cc01 100644
--- a/compiler/main/DynamicLoading.hs
+++ b/compiler/main/DynamicLoading.hs
@@ -25,7 +25,6 @@ module DynamicLoading (
) where
import GhcPrelude
-import HscTypes ( HscEnv )
import DynFlags
#if defined(GHCI)
@@ -63,6 +62,7 @@ import GHC.Exts ( unsafeCoerce# )
#else
+import HscTypes ( HscEnv )
import Module ( ModuleName, moduleNameString )
import Panic
@@ -76,12 +76,13 @@ import Control.Monad ( unless )
-- actual compilation starts. Idempotent operation. Should be re-called if
-- pluginModNames or pluginModNameOpts changes.
initializePlugins :: HscEnv -> DynFlags -> IO DynFlags
-initializePlugins hsc_env df
#if !defined(GHCI)
+initializePlugins _ df
= do let pluginMods = pluginModNames df
unless (null pluginMods) (pluginError pluginMods)
return df
#else
+initializePlugins hsc_env df
| map lpModuleName (plugins df) == pluginModNames df -- plugins not changed
&& all (\p -> lpArguments p == argumentsForPlugin p (pluginModNameOpts df))
(plugins df) -- arguments not changed
diff --git a/compiler/main/Finder.hs b/compiler/main/Finder.hs
index 3e2c9638e3..57d608bbf7 100644
--- a/compiler/main/Finder.hs
+++ b/compiler/main/Finder.hs
@@ -50,7 +50,6 @@ import System.Directory
import System.FilePath
import Control.Monad
import Data.Time
-import Data.List ( foldl' )
type FileExt = String -- Filename extension
diff --git a/compiler/main/GHC.hs b/compiler/main/GHC.hs
index cf9c74f885..da5ef8ba2d 100644
--- a/compiler/main/GHC.hs
+++ b/compiler/main/GHC.hs
@@ -291,7 +291,6 @@ import GhcPrelude hiding (init)
import ByteCodeTypes
import InteractiveEval
import InteractiveEvalTypes
-import TcRnDriver ( runTcInteractive )
import GHCi
import GHCi.RemoteTypes
@@ -359,7 +358,6 @@ import Data.Set (Set)
import qualified Data.Sequence as Seq
import System.Directory ( doesFileExist )
import Data.Maybe
-import Data.List ( find )
import Data.Time
import Data.Typeable ( Typeable )
import Data.Word ( Word8 )
diff --git a/compiler/main/HscMain.hs b/compiler/main/HscMain.hs
index 837e903631..d7cebd00fc 100644
--- a/compiler/main/HscMain.hs
+++ b/compiler/main/HscMain.hs
@@ -85,7 +85,6 @@ module HscMain
import GhcPrelude
import Data.Data hiding (Fixity, TyCon)
-import DynFlags (addPluginModuleName)
import Id
import GHCi ( addSptEntry )
import GHCi.RemoteTypes ( ForeignHValue )
diff --git a/compiler/main/HscStats.hs b/compiler/main/HscStats.hs
index 0bd83ce246..72f45346d1 100644
--- a/compiler/main/HscStats.hs
+++ b/compiler/main/HscStats.hs
@@ -17,7 +17,6 @@ import SrcLoc
import Util
import Data.Char
-import Data.Foldable (foldl')
-- | Source Statistics
ppSourceStats :: Bool -> Located (HsModule GhcPs) -> SDoc
diff --git a/compiler/main/Packages.hs b/compiler/main/Packages.hs
index 78d5961ee2..2ee2136581 100644
--- a/compiler/main/Packages.hs
+++ b/compiler/main/Packages.hs
@@ -95,7 +95,6 @@ import Data.List as List
import Data.Map (Map)
import Data.Set (Set)
import Data.Monoid (First(..))
-import Data.Semigroup ( Semigroup )
import qualified Data.Semigroup as Semigroup
import qualified Data.Map as Map
import qualified Data.Map.Strict as MapStrict
diff --git a/compiler/nativeGen/RegAlloc/Linear/JoinToTargets.hs b/compiler/nativeGen/RegAlloc/Linear/JoinToTargets.hs
index fb002e2fe0..546d48af21 100644
--- a/compiler/nativeGen/RegAlloc/Linear/JoinToTargets.hs
+++ b/compiler/nativeGen/RegAlloc/Linear/JoinToTargets.hs
@@ -27,8 +27,6 @@ import Unique
import UniqFM
import UniqSet
-import Data.Foldable (foldl')
-
-- | For a jump instruction at the end of a block, generate fixup code so its
-- vregs are in the correct regs for its destination.
--
diff --git a/compiler/nativeGen/RegAlloc/Linear/PPC/FreeRegs.hs b/compiler/nativeGen/RegAlloc/Linear/PPC/FreeRegs.hs
index 581548212a..24577c446c 100644
--- a/compiler/nativeGen/RegAlloc/Linear/PPC/FreeRegs.hs
+++ b/compiler/nativeGen/RegAlloc/Linear/PPC/FreeRegs.hs
@@ -13,7 +13,6 @@ import Platform
import Data.Word
import Data.Bits
-import Data.Foldable (foldl')
-- The PowerPC has 32 integer and 32 floating point registers.
-- This is 32bit PowerPC, so Word64 is inefficient - two Word32s are much
diff --git a/compiler/nativeGen/RegAlloc/Linear/SPARC/FreeRegs.hs b/compiler/nativeGen/RegAlloc/Linear/SPARC/FreeRegs.hs
index 653b2707c9..09003cf0a3 100644
--- a/compiler/nativeGen/RegAlloc/Linear/SPARC/FreeRegs.hs
+++ b/compiler/nativeGen/RegAlloc/Linear/SPARC/FreeRegs.hs
@@ -15,7 +15,6 @@ import Platform
import Data.Word
import Data.Bits
-import Data.Foldable (foldl')
--------------------------------------------------------------------------------
diff --git a/compiler/nativeGen/RegAlloc/Linear/X86/FreeRegs.hs b/compiler/nativeGen/RegAlloc/Linear/X86/FreeRegs.hs
index 65a566d1c3..b8af046d82 100644
--- a/compiler/nativeGen/RegAlloc/Linear/X86/FreeRegs.hs
+++ b/compiler/nativeGen/RegAlloc/Linear/X86/FreeRegs.hs
@@ -13,7 +13,6 @@ import Platform
import Data.Word
import Data.Bits
-import Data.Foldable (foldl')
newtype FreeRegs = FreeRegs Word32
deriving Show
diff --git a/compiler/nativeGen/RegAlloc/Linear/X86_64/FreeRegs.hs b/compiler/nativeGen/RegAlloc/Linear/X86_64/FreeRegs.hs
index 713b053356..3a6e3407a7 100644
--- a/compiler/nativeGen/RegAlloc/Linear/X86_64/FreeRegs.hs
+++ b/compiler/nativeGen/RegAlloc/Linear/X86_64/FreeRegs.hs
@@ -11,7 +11,6 @@ import Reg
import Panic
import Platform
-import Data.Foldable (foldl')
import Data.Word
import Data.Bits
diff --git a/compiler/parser/RdrHsSyn.hs b/compiler/parser/RdrHsSyn.hs
index 2faa58b09e..ef8b10eea2 100644
--- a/compiler/parser/RdrHsSyn.hs
+++ b/compiler/parser/RdrHsSyn.hs
@@ -106,7 +106,6 @@ import FastString
import Maybes
import Util
import ApiAnnotation
-import HsExtension ( noExt )
import Data.List
import DynFlags ( WarningFlag(..) )
diff --git a/compiler/rename/RnEnv.hs b/compiler/rename/RnEnv.hs
index c28f47e43d..87f8be7d4f 100644
--- a/compiler/rename/RnEnv.hs
+++ b/compiler/rename/RnEnv.hs
@@ -77,7 +77,6 @@ import ListSetOps ( minusList )
import qualified GHC.LanguageExtensions as LangExt
import RnUnbound
import RnUtils
-import Data.Maybe (isJust)
import qualified Data.Semigroup as Semi
import Data.Either ( partitionEithers )
import Data.List (find)
@@ -638,21 +637,21 @@ lookupSubBndrOcc_helper must_have_parent warn_if_deprec parent rdr_name
NoParent -> Nothing
picked_gres :: [GlobalRdrElt] -> DisambigInfo
+ -- For Unqual, find GREs that are in scope qualified or unqualified
+ -- For Qual, find GREs that are in scope with that qualification
picked_gres gres
| isUnqual rdr_name
- = mconcat (map right_parent gres)
+ = mconcat (map right_parent gres)
| otherwise
- = mconcat (map right_parent (pickGREs rdr_name gres))
-
+ = mconcat (map right_parent (pickGREs rdr_name gres))
right_parent :: GlobalRdrElt -> DisambigInfo
right_parent p
- | Just cur_parent <- getParent p
- = if parent == cur_parent
- then DisambiguatedOccurrence p
- else NoOccurrence
- | otherwise
- = UniqueOccurrence p
+ = case getParent p of
+ Just cur_parent
+ | parent == cur_parent -> DisambiguatedOccurrence p
+ | otherwise -> NoOccurrence
+ Nothing -> UniqueOccurrence p
-- This domain specific datatype is used to record why we decided it was
diff --git a/compiler/rename/RnExpr.hs-boot b/compiler/rename/RnExpr.hs-boot
index a944d7124e..b325eeb6f0 100644
--- a/compiler/rename/RnExpr.hs-boot
+++ b/compiler/rename/RnExpr.hs-boot
@@ -5,7 +5,6 @@ import NameSet ( FreeVars )
import TcRnTypes
import SrcLoc ( Located )
import Outputable ( Outputable )
-import HsExtension ( GhcPs, GhcRn )
rnLExpr :: LHsExpr GhcPs
-> RnM (LHsExpr GhcRn, FreeVars)
diff --git a/compiler/rename/RnNames.hs b/compiler/rename/RnNames.hs
index 8ded9c27db..09fa81576a 100644
--- a/compiler/rename/RnNames.hs
+++ b/compiler/rename/RnNames.hs
@@ -63,13 +63,11 @@ import qualified GHC.LanguageExtensions as LangExt
import Control.Monad
import Data.Either ( partitionEithers, isRight, rights )
--- import qualified Data.Foldable as Foldable
import Data.Map ( Map )
import qualified Data.Map as Map
import Data.Ord ( comparing )
import Data.List ( partition, (\\), find, sortBy )
import qualified Data.Set as S
--- import qualified Data.Set as Set
import System.FilePath ((</>))
import System.IO
@@ -1094,8 +1092,8 @@ gresFromIE decl_spec (L loc ie, avail)
= gresFromAvail prov_fn avail
where
is_explicit = case ie of
- IEThingAll _ (L _ name) -> \n -> n == ieWrappedName name
- _ -> \_ -> True
+ IEThingAll _ name -> \n -> n == lieWrappedName name
+ _ -> \_ -> True
prov_fn name
= Just (ImpSpec { is_decl = decl_spec, is_item = item_spec })
where
@@ -1217,44 +1215,11 @@ reportUnusedNames _export_decls gbl_env
is_unused_local :: GlobalRdrElt -> Bool
is_unused_local gre = isLocalGRE gre && isExternalName (gre_name gre)
-{-
-*********************************************************
-* *
-\subsection{Unused imports}
-* *
-*********************************************************
-
-This code finds which import declarations are unused. The
-specification and implementation notes are here:
- http://ghc.haskell.org/trac/ghc/wiki/Commentary/Compiler/UnusedImports
--}
-
-type ImportDeclUsage
- = ( LImportDecl GhcRn -- The import declaration
- , [AvailInfo] -- What *is* used (normalised)
- , [Name] ) -- What is imported but *not* used
-
-warnUnusedImportDecls :: TcGblEnv -> RnM ()
-warnUnusedImportDecls gbl_env
- = do { uses <- readMutVar (tcg_used_gres gbl_env)
- ; let user_imports = filterOut (ideclImplicit . unLoc) (tcg_rn_imports gbl_env)
- -- This whole function deals only with *user* imports
- -- both for warning about unnecessary ones, and for
- -- deciding the minimal ones
- rdr_env = tcg_rdr_env gbl_env
- fld_env = mkFieldEnv rdr_env
-
- ; let usage :: [ImportDeclUsage]
- usage = findImportUsage user_imports uses
-
- ; traceRn "warnUnusedImportDecls" $
- (vcat [ text "Uses:" <+> ppr uses
- , text "Import usage" <+> ppr usage])
- ; whenWOptM Opt_WarnUnusedImports $
- mapM_ (warnUnusedImport Opt_WarnUnusedImports fld_env) usage
-
- ; whenGOptM Opt_D_dump_minimal_imports $
- printMinimalImports usage }
+{- *********************************************************************
+* *
+ Missing signatures
+* *
+********************************************************************* -}
-- | Warn the user about top level binders that lack type signatures.
-- Called /after/ type inference, so that we can report the
@@ -1312,29 +1277,50 @@ warnMissingSignatures gbl_env
; add_sig_warns }
+
{-
-Note [The ImportMap]
-~~~~~~~~~~~~~~~~~~~~
-The ImportMap is a short-lived intermediate data structure records, for
-each import declaration, what stuff brought into scope by that
-declaration is actually used in the module.
+*********************************************************
+* *
+\subsection{Unused imports}
+* *
+*********************************************************
-The SrcLoc is the location of the END of a particular 'import'
-declaration. Why *END*? Because we don't want to get confused
-by the implicit Prelude import. Consider (Trac #7476) the module
- import Foo( foo )
- main = print foo
-There is an implicit 'import Prelude(print)', and it gets a SrcSpan
-of line 1:1 (just the point, not a span). If we use the *START* of
-the SrcSpan to identify the import decl, we'll confuse the implicit
-import Prelude with the explicit 'import Foo'. So we use the END.
-It's just a cheap hack; we could equally well use the Span too.
+This code finds which import declarations are unused. The
+specification and implementation notes are here:
+ http://ghc.haskell.org/trac/ghc/wiki/Commentary/Compiler/UnusedImports
-The AvailInfos are the things imported from that decl (just a list,
-not normalised).
+See also Note [Choosing the best import declaration] in RdrName
-}
-type ImportMap = Map SrcLoc [AvailInfo] -- See [The ImportMap]
+type ImportDeclUsage
+ = ( LImportDecl GhcRn -- The import declaration
+ , [GlobalRdrElt] -- What *is* used (normalised)
+ , [Name] ) -- What is imported but *not* used
+
+warnUnusedImportDecls :: TcGblEnv -> RnM ()
+warnUnusedImportDecls gbl_env
+ = do { uses <- readMutVar (tcg_used_gres gbl_env)
+ ; let user_imports = filterOut
+ (ideclImplicit . unLoc)
+ (tcg_rn_imports gbl_env)
+ -- This whole function deals only with *user* imports
+ -- both for warning about unnecessary ones, and for
+ -- deciding the minimal ones
+ rdr_env = tcg_rdr_env gbl_env
+ fld_env = mkFieldEnv rdr_env
+
+ ; let usage :: [ImportDeclUsage]
+ usage = findImportUsage user_imports uses
+
+ ; traceRn "warnUnusedImportDecls" $
+ (vcat [ text "Uses:" <+> ppr uses
+ , text "Import usage" <+> ppr usage])
+
+ ; whenWOptM Opt_WarnUnusedImports $
+ mapM_ (warnUnusedImport Opt_WarnUnusedImports fld_env) usage
+
+ ; whenGOptM Opt_D_dump_minimal_imports $
+ printMinimalImports usage }
findImportUsage :: [LImportDecl GhcRn]
-> [GlobalRdrElt]
@@ -1344,16 +1330,17 @@ findImportUsage imports used_gres
= map unused_decl imports
where
import_usage :: ImportMap
- import_usage
- = foldr extendImportMap Map.empty used_gres
+ import_usage = mkImportMap used_gres
unused_decl decl@(L loc (ImportDecl { ideclHiding = imps }))
- = (decl, nubAvails used_avails, nameSetElemsStable unused_imps)
+ = (decl, used_gres, nameSetElemsStable unused_imps)
where
- used_avails = Map.lookup (srcSpanEnd loc) import_usage `orElse` []
- -- srcSpanEnd: see Note [The ImportMap]
- used_names = availsToNameSetWithSelectors used_avails
- used_parents = mkNameSet [n | AvailTC n _ _ <- used_avails]
+ used_gres = Map.lookup (srcSpanEnd loc) import_usage
+ -- srcSpanEnd: see Note [The ImportMap]
+ `orElse` []
+
+ used_names = mkNameSet (map gre_name used_gres)
+ used_parents = mkNameSet (mapMaybe greParent_maybe used_gres)
unused_imps -- Not trivial; see eg Trac #7454
= case imps of
@@ -1362,19 +1349,16 @@ findImportUsage imports used_gres
_other -> emptyNameSet -- No explicit import list => no unused-name list
add_unused :: IE GhcRn -> NameSet -> NameSet
- add_unused (IEVar _ (L _ n)) acc
- = add_unused_name (ieWrappedName n) acc
- add_unused (IEThingAbs _ (L _ n)) acc
- = add_unused_name (ieWrappedName n) acc
- add_unused (IEThingAll _ (L _ n)) acc
- = add_unused_all (ieWrappedName n) acc
- add_unused (IEThingWith _ (L _ p) wc ns fs) acc =
- add_wc_all (add_unused_with (ieWrappedName p) xs acc)
- where xs = map (ieWrappedName . unLoc) ns
- ++ map (flSelector . unLoc) fs
+ add_unused (IEVar _ n) acc = add_unused_name (lieWrappedName n) acc
+ add_unused (IEThingAbs _ n) acc = add_unused_name (lieWrappedName n) acc
+ add_unused (IEThingAll _ n) acc = add_unused_all (lieWrappedName n) acc
+ add_unused (IEThingWith _ p wc ns fs) acc =
+ add_wc_all (add_unused_with pn xs acc)
+ where pn = lieWrappedName p
+ xs = map lieWrappedName ns ++ map (flSelector . unLoc) fs
add_wc_all = case wc of
NoIEWildcard -> id
- IEWildcard _ -> add_unused_all (ieWrappedName p)
+ IEWildcard _ -> add_unused_all pn
add_unused _ acc = acc
add_unused_name n acc
@@ -1394,49 +1378,86 @@ findImportUsage imports used_gres
-- Num is not itself mentioned. Hence the two cases in add_unused_with.
unused_decl (L _ (XImportDecl _)) = panic "unused_decl"
-extendImportMap :: GlobalRdrElt -> ImportMap -> ImportMap
+
+{- Note [The ImportMap]
+~~~~~~~~~~~~~~~~~~~~~~~
+The ImportMap is a short-lived intermediate data structure records, for
+each import declaration, what stuff brought into scope by that
+declaration is actually used in the module.
+
+The SrcLoc is the location of the END of a particular 'import'
+declaration. Why *END*? Because we don't want to get confused
+by the implicit Prelude import. Consider (Trac #7476) the module
+ import Foo( foo )
+ main = print foo
+There is an implicit 'import Prelude(print)', and it gets a SrcSpan
+of line 1:1 (just the point, not a span). If we use the *START* of
+the SrcSpan to identify the import decl, we'll confuse the implicit
+import Prelude with the explicit 'import Foo'. So we use the END.
+It's just a cheap hack; we could equally well use the Span too.
+
+The [GlobalRdrElt] are the things imported from that decl.
+-}
+
+type ImportMap = Map SrcLoc [GlobalRdrElt] -- See [The ImportMap]
+ -- If loc :-> gres, then
+ -- 'loc' = the end loc of the bestImport of each GRE in 'gres'
+
+mkImportMap :: [GlobalRdrElt] -> ImportMap
-- For each of a list of used GREs, find all the import decls that brought
-- it into scope; choose one of them (bestImport), and record
-- the RdrName in that import decl's entry in the ImportMap
-extendImportMap gre imp_map
- = add_imp gre (bestImport (gre_imp gre)) imp_map
+mkImportMap gres
+ = foldr add_one Map.empty gres
where
- add_imp :: GlobalRdrElt -> ImportSpec -> ImportMap -> ImportMap
- add_imp gre (ImpSpec { is_decl = imp_decl_spec }) imp_map
- = Map.insertWith add decl_loc [avail] imp_map
- where
- add _ avails = avail : avails -- add is really just a specialised (++)
- decl_loc = srcSpanEnd (is_dloc imp_decl_spec)
- -- For srcSpanEnd see Note [The ImportMap]
- avail = availFromGRE gre
+ add_one gre@(GRE { gre_imp = imp_specs }) imp_map
+ = Map.insertWith add decl_loc [gre] imp_map
+ where
+ best_imp_spec = bestImport imp_specs
+ decl_loc = srcSpanEnd (is_dloc (is_decl best_imp_spec))
+ -- For srcSpanEnd see Note [The ImportMap]
+ add _ gres = gre : gres
warnUnusedImport :: WarningFlag -> NameEnv (FieldLabelString, Name)
-> ImportDeclUsage -> RnM ()
warnUnusedImport flag fld_env (L loc decl, used, unused)
+
+ -- Do not warn for 'import M()'
| Just (False,L _ []) <- ideclHiding decl
- = return () -- Do not warn for 'import M()'
+ = return ()
+ -- Note [Do not warn about Prelude hiding]
| Just (True, L _ hides) <- ideclHiding decl
, not (null hides)
, pRELUDE_NAME == unLoc (ideclName decl)
- = return () -- Note [Do not warn about Prelude hiding]
- | null used = addWarnAt (Reason flag) loc msg1 -- Nothing used; drop entire decl
- | null unused = return () -- Everything imported is used; nop
- | otherwise = addWarnAt (Reason flag) loc msg2 -- Some imports are unused
+ = return ()
+
+ -- Nothing used; drop entire declaration
+ | null used
+ = addWarnAt (Reason flag) loc msg1
+
+ -- Everything imported is used; nop
+ | null unused
+ = return ()
+
+ -- Some imports are unused
+ | otherwise
+ = addWarnAt (Reason flag) loc msg2
+
where
- msg1 = vcat [pp_herald <+> quotes pp_mod <+> pp_not_used,
- nest 2 (text "except perhaps to import instances from"
- <+> quotes pp_mod),
- text "To import instances alone, use:"
+ msg1 = vcat [ pp_herald <+> quotes pp_mod <+> is_redundant
+ , nest 2 (text "except perhaps to import instances from"
+ <+> quotes pp_mod)
+ , text "To import instances alone, use:"
<+> text "import" <+> pp_mod <> parens Outputable.empty ]
- msg2 = sep [pp_herald <+> quotes sort_unused,
- text "from module" <+> quotes pp_mod <+> pp_not_used]
+ msg2 = sep [ pp_herald <+> quotes sort_unused
+ , text "from module" <+> quotes pp_mod <+> is_redundant]
pp_herald = text "The" <+> pp_qual <+> text "import of"
pp_qual
| ideclQualified decl = text "qualified"
| otherwise = Outputable.empty
- pp_mod = ppr (unLoc (ideclName decl))
- pp_not_used = text "is redundant"
+ pp_mod = ppr (unLoc (ideclName decl))
+ is_redundant = text "is redundant"
-- In warning message, pretty-print identifiers unqualified unconditionally
-- to improve the consistent for ambiguous/unambiguous identifiers.
@@ -1446,8 +1467,9 @@ warnUnusedImport flag fld_env (L loc decl, used, unused)
Nothing -> pprNameUnqualified n
-- Print unused names in a deterministic (lexicographic) order
+ sort_unused :: SDoc
sort_unused = pprWithCommas ppr_possible_field $
- sortBy (comparing nameOccName) unused
+ sortBy (comparing nameOccName) unused
{-
Note [Do not warn about Prelude hiding]
@@ -1475,7 +1497,7 @@ decls, and simply trim their import lists. NB that
getMinimalImports :: [ImportDeclUsage] -> RnM [LImportDecl GhcRn]
getMinimalImports = mapM mk_minimal
where
- mk_minimal (L l decl, used, unused)
+ mk_minimal (L l decl, used_gres, unused)
| null unused
, Just (False, _) <- ideclHiding decl
= return (L l decl)
@@ -1484,7 +1506,8 @@ getMinimalImports = mapM mk_minimal
, ideclSource = is_boot
, ideclPkgQual = mb_pkg } = decl
; iface <- loadSrcInterface doc mod_name is_boot (fmap sl_fs mb_pkg)
- ; let lies = map (L l) (concatMap (to_ie iface) used)
+ ; let used_avails = gresToAvailInfo used_gres
+ lies = map (L l) (concatMap (to_ie iface) used_avails)
; return (L l (decl { ideclHiding = Just (False, L l lies) })) }
where
doc = text "Compute minimal imports for" <+> ppr decl
diff --git a/compiler/rename/RnSource.hs b/compiler/rename/RnSource.hs
index 48739cdf69..5ecb1a68e7 100644
--- a/compiler/rename/RnSource.hs
+++ b/compiler/rename/RnSource.hs
@@ -67,7 +67,7 @@ import Control.Arrow ( first )
import Data.List ( mapAccumL )
import qualified Data.List.NonEmpty as NE
import Data.List.NonEmpty ( NonEmpty(..) )
-import Data.Maybe ( isNothing, maybe, fromMaybe )
+import Data.Maybe ( isNothing, fromMaybe )
import qualified Data.Set as Set ( difference, fromList, toList, null )
{- | @rnSourceDecl@ "renames" declarations.
diff --git a/compiler/simplStg/RepType.hs b/compiler/simplStg/RepType.hs
index eb148b15b4..4d437d3b7c 100644
--- a/compiler/simplStg/RepType.hs
+++ b/compiler/simplStg/RepType.hs
@@ -37,7 +37,7 @@ import Util
import TysPrim
import {-# SOURCE #-} TysWiredIn ( anyTypeOfKind )
-import Data.List (foldl', sort)
+import Data.List (sort)
import qualified Data.IntSet as IS
{- **********************************************************************
diff --git a/compiler/specialise/Specialise.hs b/compiler/specialise/Specialise.hs
index 6f775dfdcb..67e57c877b 100644
--- a/compiler/specialise/Specialise.hs
+++ b/compiler/specialise/Specialise.hs
@@ -27,7 +27,6 @@ import Rules
import CoreOpt ( collectBindersPushingCo )
import CoreUtils ( exprIsTrivial, applyTypeToArgs, mkCast )
import CoreFVs
-import FV ( InterestingVarFun )
import CoreArity ( etaExpandToJoinPointRule )
import UniqSupply
import Name
diff --git a/compiler/typecheck/ClsInst.hs b/compiler/typecheck/ClsInst.hs
index 03adfdebbb..37057a1c41 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/TcBackpack.hs b/compiler/typecheck/TcBackpack.hs
index 31055fdb7c..73f39eda1d 100644
--- a/compiler/typecheck/TcBackpack.hs
+++ b/compiler/typecheck/TcBackpack.hs
@@ -65,7 +65,7 @@ import RnModIface
import Util
import Control.Monad
-import Data.List (find, foldl')
+import Data.List (find)
import {-# SOURCE #-} TcRnDriver
diff --git a/compiler/typecheck/TcCanonical.hs b/compiler/typecheck/TcCanonical.hs
index b576fc34b8..46e5d821b4 100644
--- a/compiler/typecheck/TcCanonical.hs
+++ b/compiler/typecheck/TcCanonical.hs
@@ -43,7 +43,7 @@ import Bag
import MonadUtils
import Control.Monad
import Data.Maybe ( isJust )
-import Data.List ( zip4, foldl' )
+import Data.List ( zip4 )
import BasicTypes
import Data.Bifunctor ( bimap )
diff --git a/compiler/typecheck/TcDeriv.hs b/compiler/typecheck/TcDeriv.hs
index bb9c76ba61..4ee0f23de0 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 5496f16ce1..6443fbdc8a 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/TcHoleErrors.hs b/compiler/typecheck/TcHoleErrors.hs
index 1dee603c57..843ec84d75 100644
--- a/compiler/typecheck/TcHoleErrors.hs
+++ b/compiler/typecheck/TcHoleErrors.hs
@@ -44,7 +44,6 @@ import HscTypes ( ModIface(..) )
import LoadIface ( loadInterfaceForNameMaybe )
import PrelInfo (knownKeyNames)
-import Name (isBuiltInSyntax)
{-
diff --git a/compiler/typecheck/TcHsSyn.hs b/compiler/typecheck/TcHsSyn.hs
index 99e2172c5b..69f51b8758 100644
--- a/compiler/typecheck/TcHsSyn.hs
+++ b/compiler/typecheck/TcHsSyn.hs
@@ -59,7 +59,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 32b4718577..0833b3329e 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 )
@@ -40,7 +40,7 @@ import Bag
import MonadUtils ( concatMapM, foldlM )
import CoreSyn
-import Data.List( partition, foldl', deleteFirstsBy )
+import Data.List( partition, deleteFirstsBy )
import SrcLoc
import VarEnv
diff --git a/compiler/typecheck/TcPatSyn.hs b/compiler/typecheck/TcPatSyn.hs
index 4a770b563d..5fad219a90 100644
--- a/compiler/typecheck/TcPatSyn.hs
+++ b/compiler/typecheck/TcPatSyn.hs
@@ -17,15 +17,13 @@ import GhcPrelude
import HsSyn
import TcPat
-import Type( mkEmptyTCvSubst, tidyTyCoVarBinders, tidyTypes, tidyType )
+import Type( tidyTyCoVarBinders, tidyTypes, tidyType )
import TcRnMonad
import TcSigs( emptyPragEnv, completeSigFromId )
-import TcType( mkMinimalBySCs )
import TcEnv
import TcMType
import TcHsSyn
import TysPrim
-import TysWiredIn ( runtimeRepTy )
import Name
import SrcLoc
import PatSyn
diff --git a/compiler/typecheck/TcRnTypes.hs b/compiler/typecheck/TcRnTypes.hs
index 9d150b5bd6..04f17ccdca 100644
--- a/compiler/typecheck/TcRnTypes.hs
+++ b/compiler/typecheck/TcRnTypes.hs
@@ -156,7 +156,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 )
@@ -557,7 +557,8 @@ 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
- -- See Note [Tracking unused binding and imports]
+ -- 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,
-- ^ Locally-defined top-level names to keep alive.
diff --git a/compiler/typecheck/TcSMonad.hs b/compiler/typecheck/TcSMonad.hs
index 68a514fbd9..adcfdbe383 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
@@ -175,7 +174,7 @@ import Control.Monad
import qualified Control.Monad.Fail as MonadFail
import MonadUtils
import Data.IORef
-import Data.List ( foldl', partition, mapAccumL )
+import Data.List ( partition, mapAccumL )
#if defined(DEBUG)
import Digraph
diff --git a/compiler/typecheck/TcType.hs b/compiler/typecheck/TcType.hs
index d454f4cd32..1e596baa09 100644
--- a/compiler/typecheck/TcType.hs
+++ b/compiler/typecheck/TcType.hs
@@ -224,7 +224,7 @@ import FastString
import ErrUtils( Validity(..), MsgDoc, isValid )
import qualified GHC.LanguageExtensions as LangExt
-import Data.List ( mapAccumL, foldl' )
+import Data.List ( mapAccumL )
import Data.Functor.Identity( Identity(..) )
import Data.IORef
import Data.List.NonEmpty( NonEmpty(..) )
diff --git a/compiler/typecheck/TcTypeable.hs b/compiler/typecheck/TcTypeable.hs
index 05d49ae39d..90a4a836d1 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
diff --git a/compiler/types/TyCon.hs b/compiler/types/TyCon.hs
index 98dbf4b944..a40a02dd2a 100644
--- a/compiler/types/TyCon.hs
+++ b/compiler/types/TyCon.hs
@@ -137,7 +137,8 @@ import {-# SOURCE #-} TysWiredIn ( runtimeRepTyCon, constraintKind
, vecCountTyCon, vecElemTyCon, liftedTypeKind
, mkFunKind, mkForAllKind )
import {-# SOURCE #-} DataCon ( DataCon, dataConExTyCoVars, dataConFieldLabels
- , dataConTyCon, dataConFullSig )
+ , dataConTyCon, dataConFullSig
+ , isUnboxedSumCon )
import Binary
import Var
@@ -159,7 +160,6 @@ import Util
import Unique( tyConRepNameUnique, dataConTyRepNameUnique )
import UniqSet
import Module
-import {-# SOURCE #-} DataCon
import qualified Data.Data as Data
diff --git a/compiler/utils/OrdList.hs b/compiler/utils/OrdList.hs
index 8e4dae7561..064712bbad 100644
--- a/compiler/utils/OrdList.hs
+++ b/compiler/utils/OrdList.hs
@@ -19,7 +19,6 @@ import GhcPrelude
import Outputable
-import Data.Semigroup ( Semigroup )
import qualified Data.Semigroup as Semigroup
infixl 5 `appOL`
diff --git a/compiler/utils/Outputable.hs b/compiler/utils/Outputable.hs
index 28fd48783c..bb3b9d3177 100644
--- a/compiler/utils/Outputable.hs
+++ b/compiler/utils/Outputable.hs
@@ -108,7 +108,6 @@ import Panic
import GHC.Serialized
import GHC.LanguageExtensions (Extension)
-import Control.Exception (finally)
import Data.ByteString (ByteString)
import qualified Data.ByteString as BS
import Data.Char
diff --git a/compiler/utils/UniqSet.hs b/compiler/utils/UniqSet.hs
index 82b5e9fca4..1c45f7485f 100644
--- a/compiler/utils/UniqSet.hs
+++ b/compiler/utils/UniqSet.hs
@@ -52,7 +52,6 @@ import UniqFM
import Unique
import Data.Coerce
import Outputable
-import Data.Foldable (foldl')
import Data.Data
import qualified Data.Semigroup as Semi
diff --git a/ghc/GHCi/Leak.hs b/ghc/GHCi/Leak.hs
index 47fed9c28f..8135c3731e 100644
--- a/ghc/GHCi/Leak.hs
+++ b/ghc/GHCi/Leak.hs
@@ -7,7 +7,7 @@ module GHCi.Leak
import Control.Monad
import Data.Bits
-import DynFlags (settings, sTargetPlatform)
+import DynFlags ( sTargetPlatform )
import Foreign.Ptr (ptrToIntPtr, intPtrToPtr)
import GHC
import GHC.Exts (anyToAddr#)
diff --git a/hadrian/hadrian.cabal b/hadrian/hadrian.cabal
index fec927a834..422217b56d 100644
--- a/hadrian/hadrian.cabal
+++ b/hadrian/hadrian.cabal
@@ -114,7 +114,7 @@ executable hadrian
other-extensions: MultiParamTypeClasses
, TypeFamilies
build-depends: base >= 4.8 && < 5
- , Cabal >= 2.4 && < 2.5
+ , Cabal >= 2.5 && < 2.6
, containers == 0.5.*
, directory >= 1.2 && < 1.4
, extra >= 1.4.7
diff --git a/hadrian/src/Hadrian/Haskell/Cabal/Parse.hs b/hadrian/src/Hadrian/Haskell/Cabal/Parse.hs
index e0edb78731..bb2f0be3da 100644
--- a/hadrian/src/Hadrian/Haskell/Cabal/Parse.hs
+++ b/hadrian/src/Hadrian/Haskell/Cabal/Parse.hs
@@ -63,7 +63,7 @@ parsePackageData pkg = do
libDeps = collectDeps (C.condLibrary gpd)
exeDeps = map (collectDeps . Just . snd) (C.condExecutables gpd)
allDeps = concat (libDeps : exeDeps)
- sorted = sort [ C.unPackageName p | C.Dependency p _ <- allDeps ]
+ sorted = sort [ C.unPackageName p | C.Dependency p _ _ <- allDeps ]
deps = nubOrd sorted \\ [name]
depPkgs = catMaybes $ map findPackageByName deps
return $ PackageData name version (C.synopsis pd) (C.description pd) depPkgs gpd
diff --git a/libraries/Cabal b/libraries/Cabal
-Subproject 836ba04516516ec3740a9a584e514e0fed1d50d
+Subproject 3da088e281f5cbc8a731e18ceb698cfea2e4500
diff --git a/libraries/base/Data/Functor/Classes.hs b/libraries/base/Data/Functor/Classes.hs
index 0ae7b66e7a..e719c8ffe8 100644
--- a/libraries/base/Data/Functor/Classes.hs
+++ b/libraries/base/Data/Functor/Classes.hs
@@ -69,7 +69,6 @@ import Control.Applicative (Alternative((<|>)), Const(Const))
import Data.Functor.Identity (Identity(Identity))
import Data.Proxy (Proxy(Proxy))
import Data.List.NonEmpty (NonEmpty(..))
-import Data.Monoid (mappend)
import Data.Ord (Down(Down))
import GHC.Read (expectP, list, paren)
diff --git a/libraries/base/Data/Functor/Compose.hs b/libraries/base/Data/Functor/Compose.hs
index 8ceadb8572..4ddd12cb2f 100644
--- a/libraries/base/Data/Functor/Compose.hs
+++ b/libraries/base/Data/Functor/Compose.hs
@@ -27,8 +27,6 @@ import Data.Functor.Classes
import Control.Applicative
import Data.Coerce (coerce)
import Data.Data (Data)
-import Data.Foldable (Foldable(foldMap))
-import Data.Traversable (Traversable(traverse))
import GHC.Generics (Generic, Generic1)
import Text.Read (Read(..), readListDefault, readListPrecDefault)
diff --git a/libraries/base/Data/Functor/Contravariant.hs b/libraries/base/Data/Functor/Contravariant.hs
index 68a9993145..fa03069c58 100644
--- a/libraries/base/Data/Functor/Contravariant.hs
+++ b/libraries/base/Data/Functor/Contravariant.hs
@@ -54,7 +54,6 @@ import Data.Functor.Sum
import Data.Functor.Compose
import Data.Monoid (Alt(..))
-import Data.Semigroup (Semigroup(..))
import Data.Proxy
import GHC.Generics
diff --git a/libraries/base/Data/Functor/Product.hs b/libraries/base/Data/Functor/Product.hs
index d98d31ea59..8ed983b077 100644
--- a/libraries/base/Data/Functor/Product.hs
+++ b/libraries/base/Data/Functor/Product.hs
@@ -26,10 +26,7 @@ import Control.Monad (MonadPlus(..))
import Control.Monad.Fix (MonadFix(..))
import Control.Monad.Zip (MonadZip(mzipWith))
import Data.Data (Data)
-import Data.Foldable (Foldable(foldMap))
import Data.Functor.Classes
-import Data.Monoid (mappend)
-import Data.Traversable (Traversable(traverse))
import GHC.Generics (Generic, Generic1)
import Text.Read (Read(..), readListDefault, readListPrecDefault)
diff --git a/libraries/base/Data/Functor/Sum.hs b/libraries/base/Data/Functor/Sum.hs
index 68e60fe817..337db02eee 100644
--- a/libraries/base/Data/Functor/Sum.hs
+++ b/libraries/base/Data/Functor/Sum.hs
@@ -23,9 +23,7 @@ module Data.Functor.Sum (
import Control.Applicative ((<|>))
import Data.Data (Data)
-import Data.Foldable (Foldable(foldMap))
import Data.Functor.Classes
-import Data.Traversable (Traversable(traverse))
import GHC.Generics (Generic, Generic1)
import Text.Read (Read(..), readListDefault, readListPrecDefault)
diff --git a/libraries/base/Data/Semigroup.hs b/libraries/base/Data/Semigroup.hs
index fad1b206c4..918351f62e 100644
--- a/libraries/base/Data/Semigroup.hs
+++ b/libraries/base/Data/Semigroup.hs
@@ -117,9 +117,6 @@ import Data.Bifunctor
import Data.Bitraversable
import Data.Coerce
import Data.Data
-import Data.Monoid (All (..), Any (..), Dual (..), Endo (..),
- Product (..), Sum (..))
--- import qualified Data.Monoid as Monoid
import GHC.Generics
-- | A generalization of 'Data.List.cycle' to an arbitrary 'Semigroup'.
diff --git a/libraries/base/GHC/Event/PSQ.hs b/libraries/base/GHC/Event/PSQ.hs
index 6e13839491..55a39fcb81 100644
--- a/libraries/base/GHC/Event/PSQ.hs
+++ b/libraries/base/GHC/Event/PSQ.hs
@@ -49,7 +49,6 @@ import GHC.Event.Unique
import GHC.Word (Word64)
import GHC.Num (Num(..))
import GHC.Real (fromIntegral)
-import GHC.Types (Int)
#include "MachDeps.h"
diff --git a/libraries/base/GHC/Generics.hs b/libraries/base/GHC/Generics.hs
index c4e09aa198..0492464d2b 100644
--- a/libraries/base/GHC/Generics.hs
+++ b/libraries/base/GHC/Generics.hs
@@ -747,7 +747,7 @@ import GHC.Show ( Show(..), showString )
-- Needed for metadata
import Data.Proxy ( Proxy(..) )
-import GHC.TypeLits ( Nat, Symbol, KnownSymbol, KnownNat, symbolVal, natVal )
+import GHC.TypeLits ( KnownSymbol, KnownNat, symbolVal, natVal )
--------------------------------------------------------------------------------
-- Representation types
diff --git a/libraries/base/GHC/Show.hs b/libraries/base/GHC/Show.hs
index a41bf81cb3..faaa629a76 100644
--- a/libraries/base/GHC/Show.hs
+++ b/libraries/base/GHC/Show.hs
@@ -53,7 +53,6 @@ import GHC.Base
import GHC.List ((!!), foldr1, break)
import GHC.Num
import GHC.Stack.Types
-import GHC.Types (TypeLitSort (..))
-- | The @shows@ functions return a function that prepends the
diff --git a/libraries/base/GHC/StaticPtr.hs b/libraries/base/GHC/StaticPtr.hs
index 14ff3e0b2d..ee5ba786f6 100644
--- a/libraries/base/GHC/StaticPtr.hs
+++ b/libraries/base/GHC/StaticPtr.hs
@@ -49,7 +49,6 @@ module GHC.StaticPtr
import Foreign.C.Types (CInt(..))
import Foreign.Marshal (allocaArray, peekArray)
-import GHC.Exts (addrToAny#)
import GHC.Ptr (Ptr(..), nullPtr)
import GHC.Fingerprint (Fingerprint(..))
import GHC.Prim
diff --git a/libraries/bytestring b/libraries/bytestring
-Subproject ce3c6a01cd9e2438358108e3e4b515304b5ce5a
+Subproject 847563a2e5ce84714688429c4fee8df5c8568cb
diff --git a/libraries/ghc-prim/GHC/Magic.hs b/libraries/ghc-prim/GHC/Magic.hs
index 8bc88527b1..2cc3212d95 100644
--- a/libraries/ghc-prim/GHC/Magic.hs
+++ b/libraries/ghc-prim/GHC/Magic.hs
@@ -30,7 +30,15 @@ module GHC.Magic ( inline, noinline, lazy, oneShot, runRW# ) where
-- See Note [magicIds] in MkId.hs
--------------------------------------------------
-import GHC.Prim
+-- Here import TYPE explicitely from GHC.Types and not from GHC.Prim. This is
+-- because TYPE is not exported by the source Haskell module generated by
+-- genprimops which Haddock will typecheck.
+-- Likewise, realWorld# is not generated by genprimops so we use CPP and only
+-- import/use it when not building haddock docs.
+#if !defined(__HADDOCK_VERSION__)
+import GHC.Prim (realWorld#)
+#endif
+import GHC.Prim (State#, RealWorld)
import GHC.CString ()
import GHC.Types (RuntimeRep, TYPE)
diff --git a/libraries/ghci/GHCi/CreateBCO.hs b/libraries/ghci/GHCi/CreateBCO.hs
index 3ebcf0ea22..96fc4418ff 100644
--- a/libraries/ghci/GHCi/CreateBCO.hs
+++ b/libraries/ghci/GHCi/CreateBCO.hs
@@ -26,7 +26,7 @@ import Foreign hiding (newArray)
import GHC.Arr ( Array(..) )
import GHC.Exts
import GHC.IO
-import Control.Exception (throwIO, ErrorCall(..))
+import Control.Exception ( ErrorCall(..) )
createBCOs :: [ResolvedBCO] -> IO [HValueRef]
createBCOs bcos = do
diff --git a/testsuite/tests/driver/T4437.hs b/testsuite/tests/driver/T4437.hs
index 2818851444..5ae423086a 100644
--- a/testsuite/tests/driver/T4437.hs
+++ b/testsuite/tests/driver/T4437.hs
@@ -39,7 +39,6 @@ expectedGhcOnlyExtensions :: [String]
expectedGhcOnlyExtensions = ["RelaxedLayout",
"AlternativeLayoutRule",
"AlternativeLayoutRuleTransitional",
- "DerivingVia",
"EmptyDataDeriving",
"GeneralisedNewtypeDeriving"]
diff --git a/testsuite/tests/module/mod177.stderr b/testsuite/tests/module/mod177.stderr
index 2f9ffbbe0b..ea9306aa76 100644
--- a/testsuite/tests/module/mod177.stderr
+++ b/testsuite/tests/module/mod177.stderr
@@ -1,5 +1,5 @@
-mod177.hs:5:1: warning: [-Wunused-imports (in -Wextra)]
+mod177.hs:4:1: warning: [-Wunused-imports (in -Wextra)]
The import of ‘Data.Maybe’ is redundant
except perhaps to import instances from ‘Data.Maybe’
To import instances alone, use: import Data.Maybe()
diff --git a/testsuite/tests/rename/should_compile/T13064.hs b/testsuite/tests/rename/should_compile/T13064.hs
new file mode 100644
index 0000000000..6c8d79fb17
--- /dev/null
+++ b/testsuite/tests/rename/should_compile/T13064.hs
@@ -0,0 +1,8 @@
+{-# OPTIONS_GHC -Wunused-imports #-}
+module T13064 where
+
+import Control.Applicative
+import Prelude (IO, pure) -- Import of 'pure' is redundant
+
+foo :: IO ()
+foo = () <$ pure ()
diff --git a/testsuite/tests/rename/should_compile/T13064.stderr b/testsuite/tests/rename/should_compile/T13064.stderr
new file mode 100644
index 0000000000..3175a8563f
--- /dev/null
+++ b/testsuite/tests/rename/should_compile/T13064.stderr
@@ -0,0 +1,3 @@
+
+T13064.hs:5:1: warning: [-Wunused-imports (in -Wextra)]
+ The import of ‘pure’ from module ‘Prelude’ is redundant
diff --git a/testsuite/tests/rename/should_compile/T4239.stdout b/testsuite/tests/rename/should_compile/T4239.stdout
index a1f53d2c9e..d8f8909bc3 100644
--- a/testsuite/tests/rename/should_compile/T4239.stdout
+++ b/testsuite/tests/rename/should_compile/T4239.stdout
@@ -1 +1 @@
-import T4239A ( (·), type (:+++)((:---), X, (:+++)) )
+import T4239A ( (·), type (:+++)((:---), (:+++), X) )
diff --git a/testsuite/tests/rename/should_compile/all.T b/testsuite/tests/rename/should_compile/all.T
index a3f862f8a4..86f04d0ea9 100644
--- a/testsuite/tests/rename/should_compile/all.T
+++ b/testsuite/tests/rename/should_compile/all.T
@@ -161,3 +161,4 @@ test('T14881', [], multimod_compile, ['T14881', '-W'])
test('T14487', [], multimod_compile, ['T14487', '-v0'])
test('T14747', [], multimod_compile, ['T14747', '-v0'])
test('T15149', [], multimod_compile, ['T15149', '-v0'])
+test('T13064', normal, compile, [''])
diff --git a/utils/check-api-annotations/check-api-annotations.cabal b/utils/check-api-annotations/check-api-annotations.cabal
index 3d07608577..bc9698c16e 100644
--- a/utils/check-api-annotations/check-api-annotations.cabal
+++ b/utils/check-api-annotations/check-api-annotations.cabal
@@ -24,6 +24,6 @@ Executable check-api-annotations
Build-Depends: base >= 4 && < 5,
containers,
- Cabal >= 2.4.0 && < 2.5,
+ Cabal >= 2.5 && < 2.6,
directory,
ghc
diff --git a/utils/check-ppr/check-ppr.cabal b/utils/check-ppr/check-ppr.cabal
index 2da21d766b..4257a88471 100644
--- a/utils/check-ppr/check-ppr.cabal
+++ b/utils/check-ppr/check-ppr.cabal
@@ -25,7 +25,7 @@ Executable check-ppr
Build-Depends: base >= 4 && < 5,
bytestring,
containers,
- Cabal >= 2.4 && < 2.5,
+ Cabal >= 2.5 && < 2.6,
directory,
filepath,
ghc
diff --git a/utils/ghc-cabal/ghc-cabal.cabal b/utils/ghc-cabal/ghc-cabal.cabal
index baa7a1702a..c2512c1ca7 100644
--- a/utils/ghc-cabal/ghc-cabal.cabal
+++ b/utils/ghc-cabal/ghc-cabal.cabal
@@ -21,7 +21,7 @@ Executable ghc-cabal
Build-Depends: base >= 3 && < 5,
bytestring >= 0.10 && < 0.11,
- Cabal >= 2.4 && < 2.5,
+ Cabal >= 2.5 && < 2.6,
directory >= 1.1 && < 1.4,
filepath >= 1.2 && < 1.5
diff --git a/utils/ghctags/Main.hs b/utils/ghctags/Main.hs
index e774b80726..6020f41d27 100644
--- a/utils/ghctags/Main.hs
+++ b/utils/ghctags/Main.hs
@@ -183,7 +183,7 @@ flagsFromCabal :: FilePath -> IO [String]
flagsFromCabal distPref = do
lbi <- getPersistBuildConfig distPref
let pd = localPkgDescr lbi
- case componentNameTargets' pd lbi CLibName of
+ case componentNameTargets' pd lbi (CLibName LMainLibName) of
[target] ->
let clbi = targetCLBI target
CLib lib = getComponent pd (componentLocalName clbi)
diff --git a/utils/ghctags/ghctags.cabal b/utils/ghctags/ghctags.cabal
index f74bc4ff4a..23de1524b9 100644
--- a/utils/ghctags/ghctags.cabal
+++ b/utils/ghctags/ghctags.cabal
@@ -18,6 +18,6 @@ Executable ghctags
Build-Depends: base >= 4 && < 5,
containers,
- Cabal >= 2.4 && <2.5,
+ Cabal >= 2.5 && <2.6,
ghc