Skip to content

Commit 224c72e

Browse files
committed
werror
1 parent 7242673 commit 224c72e

File tree

1 file changed

+26
-32
lines changed

1 file changed

+26
-32
lines changed

ghcide/session-loader/Development/IDE/Session.hs

+26-32
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ import Data.Function
4040
import Data.Hashable hiding (hash)
4141
import qualified Data.HashMap.Strict as HM
4242
import Data.IORef
43-
import qualified Data.Set as OS
4443
import Data.List
4544
import Data.List.NonEmpty (NonEmpty (..))
4645
import Data.List.Extra as L
@@ -66,7 +65,7 @@ import Development.IDE.Graph (Action)
6665
import Development.IDE.Session.VersionCheck
6766
import Development.IDE.Types.Diagnostics
6867
import Development.IDE.Types.Exports
69-
import Development.IDE.Types.HscEnvEq (HscEnvEq, newHscEnvEq, envImportPaths,
68+
import Development.IDE.Types.HscEnvEq (HscEnvEq, newHscEnvEq,
7069
newHscEnvEqPreserveImportPaths)
7170
import Development.IDE.Types.Location
7271
import Development.IDE.Types.Options
@@ -119,13 +118,14 @@ import Development.IDE.GHC.Compat.CmdLine
119118

120119
-- See Note [Guidelines For Using CPP In GHCIDE Import Statements]
121120
#if MIN_VERSION_ghc(9,3,0)
121+
import qualified Data.Set as OS
122+
122123
import GHC.Driver.Errors.Types
123124
import GHC.Driver.Env (hscSetActiveUnitId, hsc_all_home_unit_ids)
124125
import GHC.Driver.Make (checkHomeUnitsClosed)
125126
import GHC.Unit.State
126127
import GHC.Types.Error (errMsgDiagnostic)
127128
import GHC.Data.Bag
128-
import GHC.Unit.Env
129129
#endif
130130

131131
import GHC.ResponseFile
@@ -518,17 +518,17 @@ loadSessionWithOptions recorder SessionLoadingOptions{..} dir = do
518518
-- compilation but these are the true source of
519519
-- information.
520520
new_deps = fmap (\(df, targets) -> RawComponentInfo (homeUnitId_ df) df targets cfp opts dep_info) newTargetDfs
521-
all_deps = new_deps `appendListToNonEmpty` maybe [] id oldDeps
521+
all_deps = new_deps `NE.appendList` maybe [] id oldDeps
522522
-- Get all the unit-ids for things in this component
523-
inplace = map rawComponentUnitId $ NE.toList all_deps
523+
_inplace = map rawComponentUnitId $ NE.toList all_deps
524524

525525
all_deps' <- forM all_deps $ \RawComponentInfo{..} -> do
526526
-- Remove all inplace dependencies from package flags for
527527
-- components in this HscEnv
528528
#if MIN_VERSION_ghc(9,3,0)
529529
let (df2, uids) = (rawComponentDynFlags, [])
530530
#else
531-
let (df2, uids) = _removeInplacePackages fakeUid inplace rawComponentDynFlags
531+
let (df2, uids) = _removeInplacePackages fakeUid _inplace rawComponentDynFlags
532532
#endif
533533
let prefix = show rawComponentUnitId
534534
-- See Note [Avoiding bad interface files]
@@ -539,13 +539,15 @@ loadSessionWithOptions recorder SessionLoadingOptions{..} dir = do
539539
-- The final component information, mostly the same but the DynFlags don't
540540
-- contain any packages which are also loaded
541541
-- into the same component.
542-
pure $ ComponentInfo rawComponentUnitId
543-
processed_df
544-
uids
545-
rawComponentTargets
546-
rawComponentFP
547-
rawComponentCOptions
548-
rawComponentDependencyInfo
542+
pure $ ComponentInfo
543+
{ componentUnitId = rawComponentUnitId
544+
, componentDynFlags = processed_df
545+
, componentInternalUnits = uids
546+
, componentTargets = rawComponentTargets
547+
, componentFP = rawComponentFP
548+
, componentCOptions = rawComponentCOptions
549+
, componentDependencyInfo = rawComponentDependencyInfo
550+
}
549551
-- Modify the map so the hieYaml now maps to the newly updated
550552
-- ComponentInfos
551553
-- Returns
@@ -786,7 +788,7 @@ newComponentCache
786788
-> [ComponentInfo] -- ^ New components to be loaded
787789
-> [ComponentInfo] -- ^ old, already existing components
788790
-> IO [ ([TargetDetails], (IdeResult HscEnvEq, DependencyInfo))]
789-
newComponentCache recorder exts cradlePath cfp hsc_env old_cis new_cis = do
791+
newComponentCache recorder exts cradlePath _cfp hsc_env old_cis new_cis = do
790792
let cis = Map.unionWith unionCIs (mkMap new_cis) (mkMap old_cis)
791793
-- When we have multiple components with the same uid,
792794
-- prefer the new one over the old.
@@ -809,15 +811,15 @@ newComponentCache recorder exts cradlePath cfp hsc_env old_cis new_cis = do
809811

810812
case closure_errs of
811813
errs@(_:_) -> do
812-
let rendered_err = map (ideErrorWithSource (Just "cradle") (Just DiagnosticSeverity_Error) cfp . T.pack . Compat.printWithoutUniques) errs
814+
let rendered_err = map (ideErrorWithSource (Just "cradle") (Just DiagnosticSeverity_Error) _cfp . T.pack . Compat.printWithoutUniques) errs
813815
res = (rendered_err,Nothing)
814816
dep_info = foldMap componentDependencyInfo (filter isBad $ Map.elems cis)
815817
bad_units = OS.fromList $ concat $ do
816818
x <- bagToList $ mapBag errMsgDiagnostic $ unionManyBags $ map Compat.getMessages errs
817819
DriverHomePackagesNotClosed us <- pure x
818820
pure us
819821
isBad ci = (homeUnitId_ (componentDynFlags ci)) `OS.member` bad_units
820-
return [([TargetDetails (TargetFile cfp) res dep_info [cfp]],(res,dep_info))]
822+
return [([TargetDetails (TargetFile _cfp) res dep_info [_cfp]],(res,dep_info))]
821823
[] -> do
822824
#else
823825
do
@@ -968,13 +970,13 @@ data ComponentInfo = ComponentInfo
968970
-- | Internal units, such as local libraries, that this component
969971
-- is loaded with. These have been extracted from the original
970972
-- ComponentOptions.
971-
, _componentInternalUnits :: [UnitId]
973+
, componentInternalUnits :: [UnitId]
972974
-- | All targets of this components.
973975
, componentTargets :: [GHC.Target]
974976
-- | Filepath which caused the creation of this component
975977
, componentFP :: NormalizedFilePath
976978
-- | Component Options used to load the component.
977-
, _componentCOptions :: ComponentOptions
979+
, componentCOptions :: ComponentOptions
978980
-- | Maps cradle dependencies, such as `stack.yaml`, or `.cabal` file
979981
-- to last modification time. See Note [Multi Cradle Dependency Info]
980982
, componentDependencyInfo :: DependencyInfo
@@ -1050,9 +1052,9 @@ addUnit unit_str = liftEwM $ do
10501052
putCmdLineState (unit_str : units)
10511053

10521054
-- | Throws if package flags are unsatisfiable
1053-
setOptions :: GhcMonad m => NormalizedFilePath -> ComponentOptions -> DynFlags -> m (NE.NonEmpty (DynFlags, [GHC.Target]))
1055+
setOptions :: GhcMonad m => NormalizedFilePath -> ComponentOptions -> DynFlags -> m (NonEmpty (DynFlags, [GHC.Target]))
10541056
setOptions cfp (ComponentOptions theOpts compRoot _) dflags = do
1055-
((theOpts',errs,warns),units) <- processCmdLineP unit_flags [] (map noLoc theOpts)
1057+
((theOpts',_errs,_warns),units) <- processCmdLineP unit_flags [] (map noLoc theOpts)
10561058
case NE.nonEmpty units of
10571059
Just us -> initMulti us
10581060
Nothing -> do
@@ -1071,14 +1073,14 @@ setOptions cfp (ComponentOptions theOpts compRoot _) dflags = do
10711073
-- does list all targets.
10721074
abs_fp <- liftIO $ makeAbsolute (fromNormalizedFilePath cfp)
10731075
let special_target = Compat.mkSimpleTarget df abs_fp
1074-
pure $ (df, special_target : targets) NE.:| []
1076+
pure $ (df, special_target : targets) :| []
10751077
where
10761078
initMulti unitArgFiles =
10771079
forM unitArgFiles $ \f -> do
10781080
args <- liftIO $ expandResponse [f]
10791081
initOne args
1080-
initOne theOpts = do
1081-
(dflags', targets') <- addCmdOpts theOpts dflags
1082+
initOne this_opts = do
1083+
(dflags', targets') <- addCmdOpts this_opts dflags
10821084
let dflags'' =
10831085
#if MIN_VERSION_ghc(9,3,0)
10841086
case unitIdString (homeUnitId_ dflags') of
@@ -1089,7 +1091,7 @@ setOptions cfp (ComponentOptions theOpts compRoot _) dflags = do
10891091
-- This works because there won't be any dependencies on the
10901092
-- executable unit.
10911093
"main" ->
1092-
let hash = B.unpack $ B16.encode $ H.finalize $ H.updates H.init (map B.pack $ theOpts)
1094+
let hash = B.unpack $ B16.encode $ H.finalize $ H.updates H.init (map B.pack $ this_opts)
10931095
hashed_uid = Compat.toUnitId (Compat.stringToUnit ("main-"++hash))
10941096
in setHomeUnitId_ hashed_uid dflags'
10951097
_ -> dflags'
@@ -1202,11 +1204,3 @@ showPackageSetupException (PackageCheckFailed BasePackageAbiMismatch{..}) = unwo
12021204
renderPackageSetupException :: FilePath -> PackageSetupException -> (NormalizedFilePath, ShowDiagnostic, Diagnostic)
12031205
renderPackageSetupException fp e =
12041206
ideErrorWithSource (Just "cradle") (Just DiagnosticSeverity_Error) (toNormalizedFilePath' fp) (T.pack $ showPackageSetupException e)
1205-
1206-
1207-
appendListToNonEmpty :: NE.NonEmpty a -> [a] -> NE.NonEmpty a
1208-
#if MIN_VERSION_base(4,16,0)
1209-
appendListToNonEmpty = NE.appendList
1210-
#else
1211-
appendListToNonEmpty (x NE.:| xs) ys = x NE.:| (xs ++ ys)
1212-
#endif

0 commit comments

Comments
 (0)