summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Pickering <matthewtpickering@gmail.com>2019-08-16 21:10:19 +0100
committerMatthew Pickering <matthewtpickering@gmail.com>2019-08-16 21:10:19 +0100
commit1c541c349d56d8a7de870f573f24cfd705c56622 (patch)
treee476ff8e11046a7917ec413b80966c324d0dae98
parent3611d6e5679f3d919dcdc3269326c267e10355d1 (diff)
downloadhaskell-1c541c349d56d8a7de870f573f24cfd705c56622.tar.gz
lint
-rw-r--r--compiler/basicTypes/Module.hs7
-rw-r--r--compiler/llvmGen/LlvmCodeGen/Regs.hs2
-rw-r--r--compiler/main/Annotations.hs2
-rw-r--r--compiler/main/Packages.hs2
-rw-r--r--compiler/rename/RnNames.hs6
-rw-r--r--compiler/typecheck/TcRnDriver.hs2
-rw-r--r--compiler/utils/FastString.hs15
-rw-r--r--compiler/utils/FastStringEnv.hs8
8 files changed, 23 insertions, 21 deletions
diff --git a/compiler/basicTypes/Module.hs b/compiler/basicTypes/Module.hs
index a8c6244742..f9fc9c1560 100644
--- a/compiler/basicTypes/Module.hs
+++ b/compiler/basicTypes/Module.hs
@@ -123,7 +123,7 @@ module Module
lookupWithDefaultModuleEnv, mapModuleEnv, mkModuleEnv, emptyModuleEnv,
moduleEnvKeys, moduleEnvElts, moduleEnvToList,
unitModuleEnv, isEmptyModuleEnv,
- extendModuleEnvWith,
+ extendModuleEnvWith,
-- * ModuleName mappings
ModuleNameEnv, DModuleNameEnv,
@@ -1251,7 +1251,7 @@ mkModuleSet :: [Module] -> ModuleSet
mkModuleSet = mkFsSet
extendModuleSet :: ModuleSet -> Module -> ModuleSet
-extendModuleSet = addOneToFsSet
+extendModuleSet = addOneToFsSet
extendModuleSetList :: ModuleSet -> [Module] -> ModuleSet
extendModuleSetList = addListToFsSet
@@ -1291,4 +1291,5 @@ type ModuleNameEnv elt = FastStringEnv elt
-- | A map keyed off of 'ModuleName's (actually, their 'Unique's)
-- Has deterministic folds and can be deterministically converted to a list
-type DModuleNameEnv elt = DFastStringEnv elt \ No newline at end of file
+type DModuleNameEnv elt = DFastStringEnv elt
+
diff --git a/compiler/llvmGen/LlvmCodeGen/Regs.hs b/compiler/llvmGen/LlvmCodeGen/Regs.hs
index 79e25359bc..0d2d6bf746 100644
--- a/compiler/llvmGen/LlvmCodeGen/Regs.hs
+++ b/compiler/llvmGen/LlvmCodeGen/Regs.hs
@@ -98,7 +98,7 @@ alwaysLive = [BaseReg, Sp, Hp, SpLim, HpLim, node]
-- | STG Type Based Alias Analysis hierarchy
stgTBAA :: Monad m => (FastString -> m Unique) -> m [(Unique, LMString, Maybe Unique)]
-stgTBAA m = undefined
+stgTBAA m = undefined
{-
= return [ (rootN, fsLit "root", Nothing)
, (topN, fsLit "top", Just rootN)
diff --git a/compiler/main/Annotations.hs b/compiler/main/Annotations.hs
index 6090a37ea6..55e0abb974 100644
--- a/compiler/main/Annotations.hs
+++ b/compiler/main/Annotations.hs
@@ -125,7 +125,7 @@ findAnns deserialize (MkAnnEnv ann_env)
-- only transient annotations will be returned.
findAnnsByTypeRep :: AnnEnv Name -> CoreAnnTarget -> TypeRep -> [[Word8]]
findAnnsByTypeRep (MkAnnEnv ann_env) target tyrep
- = [ ws | Serialized tyrep' ws <- Map.findWithDefault [] target ann_env
+ = [ ws | Serialized tyrep' ws <- Map.findWithDefault [] target ann_env
, tyrep' == tyrep ]
-- | Deserialize all annotations of a given type. This happens lazily, that is
diff --git a/compiler/main/Packages.hs b/compiler/main/Packages.hs
index 4ffe348696..04084dfff7 100644
--- a/compiler/main/Packages.hs
+++ b/compiler/main/Packages.hs
@@ -1479,7 +1479,7 @@ mkPackageState dflags dbs preload0 = do
case compareByPreference prec_map unit unit' of
GT -> (fs, unit)
_ -> (fs, unit')
- addIfMorePreferable m unit =
+ addIfMorePreferable m unit =
let fs = fsPackageName unit
in addToUDFM_C preferLater m (FastStringU fs) (fs, unit)
-- This is the set of maximally preferable packages. In fact, it is a set of
diff --git a/compiler/rename/RnNames.hs b/compiler/rename/RnNames.hs
index 258e5ad231..fb5b29f876 100644
--- a/compiler/rename/RnNames.hs
+++ b/compiler/rename/RnNames.hs
@@ -897,6 +897,9 @@ filterImports iface decl_spec (Just (want_hiding, L l import_items))
all_avails = mi_exports iface
-- See Note [Dealing with imports]
+ -- If you remove the bang here then `imp_occ_env` gets computed
+ -- multiple times. (I think, it fixes a problem to do with GCing
+ -- FastString at least)
imp_occ_env :: OccEnv (Name, -- the name
AvailInfo, -- the export item providing the name
Maybe Name) -- the parent of associated types
@@ -923,7 +926,8 @@ filterImports iface decl_spec (Just (want_hiding, L l import_items))
| Just succ <- mb_success = return succ
| otherwise = failLookupWith (BadImport ie)
where
- mb_success = lookupOccEnv imp_occ_env (rdrNameOcc rdr)
+ mb_success = do
+ lookupOccEnv imp_occ_env (rdrNameOcc rdr)
lookup_lie :: LIE GhcPs -> TcRn [(LIE GhcRn, AvailInfo)]
lookup_lie (L loc ieRdr)
diff --git a/compiler/typecheck/TcRnDriver.hs b/compiler/typecheck/TcRnDriver.hs
index 487ab1cb3d..660b3bfb1d 100644
--- a/compiler/typecheck/TcRnDriver.hs
+++ b/compiler/typecheck/TcRnDriver.hs
@@ -2746,7 +2746,7 @@ pprTcGblEnv (TcGblEnv { tcg_type_env = type_env,
, ppr_fam_insts fam_insts
, ppr_rules rules
, text "Dependent modules:" <+>
- pprUniqMap ppr (imp_dep_mods imports)
+ pprUniqMap ppr (imp_dep_mods imports)
, text "Dependent packages:" <+>
ppr (S.toList $ imp_dep_pkgs imports)]
where -- The use of sort is just to reduce unnecessary
diff --git a/compiler/utils/FastString.hs b/compiler/utils/FastString.hs
index 2ea0d0ab13..af825ec26b 100644
--- a/compiler/utils/FastString.hs
+++ b/compiler/utils/FastString.hs
@@ -120,11 +120,8 @@ import GHC.Exts
import System.IO
import Data.Data
import Data.IORef
-import Data.Maybe ( isJust )
import Data.Char
-import Data.List (deleteBy)
import Data.Semigroup as Semi
-import Debug.Trace
import System.Mem.Weak
@@ -137,7 +134,6 @@ import GHC.Conc.Sync (sharedCAF)
#endif
import GHC.Base ( unpackCString#, unpackNBytes# )
-import Debug.Trace
import GHC.ForeignPtr
import GHC.Weak
@@ -201,10 +197,13 @@ newtype FastString = FastString {
fs_bs :: ByteString
}
+
+-- It is sufficient to test pointer equality as we guarantee that
+-- each string is uniquely allocated.
instance Eq FastString where
f1 == f2 =
case (fs_bs f1, fs_bs f2) of
- ((BS.PS fp i len), (BS.PS fp' i' len1)) -> fp == fp' && i == i'
+ ((BS.PS fp i _len), (BS.PS fp' i' _len1)) -> fp == fp' && i == i'
{-# NOINLINE (==) #-}
instance Ord FastString where
@@ -436,8 +435,7 @@ mkFastStringWith mk_fs !ptr !len = do
!new_fs <- mk_fs
withMVar lock $ \_ -> insert new_fs
where
- !(FastStringTable uid segments#) = stringTable
- get_uid = atomicModifyIORef' uid $ \n -> (n+1,n)
+ !(FastStringTable _uid segments#) = stringTable
!(I# hash#) = hashStr ptr len
(# segmentRef #) = indexArray# segments# (hashToSegment# hash#)
@@ -458,10 +456,9 @@ mkFastStringWith mk_fs !ptr !len = do
(# s1, w #) -> (# s1, Weak w #)
-- v <- mkWeak fptr fs (Just $ atomicModifyIORef' fastStringGcCounter (\x -> (x +1, ())))
IO $ \s1# ->
- case writeArray# buckets# idx# (Left fs: bucket) s1# of
+ case writeArray# buckets# idx# (Right v: bucket) s1# of
s2# -> (# s2#, () #)
modifyIORef' counter succ
- let u = uniqueOfFS fs
return fs
{-
delete_fs :: Int -> IO ()
diff --git a/compiler/utils/FastStringEnv.hs b/compiler/utils/FastStringEnv.hs
index 909b58e201..f02a002152 100644
--- a/compiler/utils/FastStringEnv.hs
+++ b/compiler/utils/FastStringEnv.hs
@@ -125,18 +125,18 @@ emptyDFsEnv = emptyUDFM
dFsEnvElts :: DFastStringEnv a -> [a]
dFsEnvElts = map snd . eltsUDFM
-addToDFsEnv ::
+addToDFsEnv ::
HasFastString f => DFastStringEnv a -> f -> a -> DFastStringEnv a
addToDFsEnv m f a = addToUDFM m (FastStringU $ getFastString f) (getFastString f, a)
-addListToDFsEnv ::
+addListToDFsEnv ::
HasFastString f => DFastStringEnv a -> [(f,a)] -> DFastStringEnv a
-addListToDFsEnv m fs =
+addListToDFsEnv m fs =
addListToUDFM m (map (\(f,a) -> ((FastStringU $ getFastString f), (getFastString f, a))) fs)
mkDFsEnv :: HasFastString f => [(f,a)] -> DFastStringEnv a
-mkDFsEnv l = listToUDFM
+mkDFsEnv l = listToUDFM
(map (\(f, x) -> (FastStringU (getFastString f), (getFastString f, x))) l)
lookupDFsEnv :: HasFastString f => DFastStringEnv a -> f -> Maybe a