Skip to content

Commit 4feea23

Browse files
jhrcekmichaelpjmergify[bot]
authored andcommitted
Fix most -Wall in ghcide (haskell#3984)
* Fix most -Wall in ghcide * Fix ghc 9.2.8 * No spaces after CPP # --------- Co-authored-by: Michael Peyton Jones <[email protected]> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
1 parent 1be6439 commit 4feea23

13 files changed

+53
-74
lines changed

ghcide/exe/Main.hs

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
-- Copyright (c) 2019 The DAML Authors. All rights reserved.
22
-- SPDX-License-Identifier: Apache-2.0
3-
{-# OPTIONS_GHC -Wno-dodgy-imports #-} -- GHC no longer exports def in GHC 8.6 and above
43
{-# LANGUAGE TemplateHaskell #-}
54

65
module Main(main) where

ghcide/ghcide.cabal

+13-11
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,12 @@ flag pedantic
4040
default: False
4141
manual: True
4242

43+
common warnings
44+
ghc-options:
45+
-Wall -Wincomplete-uni-patterns -Wunused-packages
46+
-Wno-unticked-promoted-constructors
47+
-fno-ignore-asserts
48+
4349
library
4450
default-language: Haskell2010
4551
build-depends:
@@ -218,10 +224,6 @@ library
218224
Development.IDE.Session.VersionCheck
219225
Development.IDE.Types.Action
220226

221-
ghc-options:
222-
-Wall -Wincomplete-uni-patterns -Wno-unticked-promoted-constructors
223-
-Wunused-packages -fno-ignore-asserts
224-
225227
if flag(pedantic)
226228
-- We eventually want to build with Werror fully, but we haven't
227229
-- finished purging the warnings, so some are set to not be errors
@@ -246,9 +248,10 @@ flag test-exe
246248
default: True
247249

248250
executable ghcide-test-preprocessor
251+
import: warnings
249252
default-language: Haskell2010
250253
hs-source-dirs: test/preprocessor
251-
ghc-options: -Wall -Wno-name-shadowing
254+
ghc-options: -Wno-name-shadowing
252255
main-is: Main.hs
253256
build-depends: base >=4 && <5
254257

@@ -260,11 +263,11 @@ flag executable
260263
default: True
261264

262265
executable ghcide
266+
import: warnings
263267
default-language: Haskell2010
264268
hs-source-dirs: exe
265-
ghc-options:
266-
-threaded -Wall -Wincomplete-uni-patterns -Wno-name-shadowing -Wunused-packages
267-
-rtsopts "-with-rtsopts=-I0 -A128M -T"
269+
ghc-options: -threaded -rtsopts "-with-rtsopts=-I0 -A128M -T" -Wno-name-shadowing
270+
268271

269272
-- allow user RTS overrides
270273
-- disable idle GC
@@ -314,6 +317,7 @@ executable ghcide
314317
cpp-options: -DMONITORING_EKG
315318

316319
test-suite ghcide-tests
320+
import: warnings
317321
type: exitcode-stdio-1.0
318322
default-language: Haskell2010
319323
build-tool-depends:
@@ -371,9 +375,7 @@ test-suite ghcide-tests
371375
build-depends: ghc-typelits-knownnat
372376

373377
hs-source-dirs: test/cabal test/exe test/src
374-
ghc-options:
375-
-threaded -Wall -Wno-name-shadowing -O0
376-
-Wno-unticked-promoted-constructors -Wunused-packages
378+
ghc-options: -threaded -O0 -Wno-name-shadowing
377379

378380
main-is: Main.hs
379381
other-modules:

ghcide/src/Development/IDE/GHC/CPP.hs

+3-3
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,11 @@ doCpp env input_fn output_fn =
5353
#if MIN_VERSION_ghc(9,5,0)
5454
let cpp_opts = Pipeline.CppOpts
5555
{ cppLinePragmas = True
56-
# if MIN_VERSION_ghc(9,9,0)
56+
#if MIN_VERSION_ghc(9,9,0)
5757
, useHsCpp = True
58-
# else
58+
#else
5959
, cppUseCc = False
60-
# endif
60+
#endif
6161
} in
6262
#else
6363
let cpp_opts = True in

ghcide/src/Development/IDE/GHC/Compat.hs

+15-26
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,15 @@
55
{-# LANGUAGE ConstraintKinds #-}
66
{-# LANGUAGE FlexibleInstances #-}
77
{-# LANGUAGE PatternSynonyms #-}
8-
{-# OPTIONS -Wno-incomplete-uni-patterns -Wno-dodgy-imports #-}
98

109
-- | Attempt at hiding the GHC version differences we can.
1110
module Development.IDE.GHC.Compat(
12-
mkHomeModLocation,
1311
hPutStringBuffer,
1412
addIncludePathsQuote,
1513
getModuleHash,
1614
setUpTypedHoles,
1715
NameCacheUpdater(..),
1816
#if MIN_VERSION_ghc(9,3,0)
19-
getMessages,
20-
renderDiagnosticMessageWithHints,
2117
nameEnvElts,
2218
#else
2319
upNameCache,
@@ -26,10 +22,8 @@ module Development.IDE.GHC.Compat(
2622
disableWarningsAsErrors,
2723
reLoc,
2824
reLocA,
29-
getPsMessages,
3025
renderMessages,
3126
pattern PFailedWithErrorMessages,
32-
isObjectLinkable,
3327

3428
#if !MIN_VERSION_ghc(9,3,0)
3529
extendModSummaryNoDeps,
@@ -53,8 +47,9 @@ module Development.IDE.GHC.Compat(
5347
nodeAnnotations,
5448
mkAstNode,
5549
combineRealSrcSpans,
56-
50+
#if !MIN_VERSION_ghc(9,3,0)
5751
nonDetOccEnvElts,
52+
#endif
5853
nonDetFoldOccEnv,
5954

6055
isQualifiedImport,
@@ -94,7 +89,9 @@ module Development.IDE.GHC.Compat(
9489
simplifyExpr,
9590
tidyExpr,
9691
emptyTidyEnv,
92+
#if MIN_VERSION_ghc(9,7,0)
9793
tcInitTidyEnv,
94+
#endif
9895
corePrepExpr,
9996
corePrepPgm,
10097
lintInteractiveExpr,
@@ -160,11 +157,6 @@ import Data.List (foldl')
160157
import qualified Data.Map as Map
161158
import qualified Data.Set as S
162159

163-
-- See Note [Guidelines For Using CPP In GHCIDE Import Statements]
164-
165-
#if MIN_VERSION_ghc(9,7,0)
166-
import GHC.Tc.Zonk.TcType (tcInitTidyEnv)
167-
#endif
168160
import qualified GHC.Core.Opt.Pipeline as GHC
169161
import GHC.Core.Tidy (tidyExpr)
170162
import GHC.CoreToStg.Prep (corePrepPgm)
@@ -187,15 +179,8 @@ import GHC.Iface.Make (mkIfaceExports)
187179
import GHC.SysTools.Tasks (runUnlit, runPp)
188180
import qualified GHC.Types.Avail as Avail
189181

190-
191-
#if !MIN_VERSION_ghc(9,5,0)
192-
import GHC.Core.Lint (lintInteractiveExpr)
193-
#endif
194-
195-
196182
import GHC.Iface.Env
197183
import GHC.Types.SrcLoc (combineRealSrcSpans)
198-
import GHC.Linker.Loader (loadExpr)
199184
import GHC.Runtime.Context (icInteractiveModule)
200185
import GHC.Unit.Home.ModInfo (HomePackageTable,
201186
lookupHpt)
@@ -205,21 +190,19 @@ import GHC.Builtin.Uniques
205190
import GHC.ByteCode.Types
206191
import GHC.CoreToStg
207192
import GHC.Data.Maybe
208-
import GHC.Linker.Loader (loadDecls)
193+
import GHC.Linker.Loader (loadDecls, loadExpr)
209194
import GHC.Stg.Pipeline
210195
import GHC.Stg.Syntax
211196
import GHC.StgToByteCode
212197
import GHC.Types.CostCentre
213198
import GHC.Types.IPE
214199

200+
-- See Note [Guidelines For Using CPP In GHCIDE Import Statements]
201+
215202
#if !MIN_VERSION_ghc(9,3,0)
216203
import GHC.Unit.Module.Deps (Dependencies(dep_mods), Usage(..))
217-
import GHC.Linker.Types (isObjectLinkable)
218204
import GHC.Unit.Module.ModSummary
219205
import GHC.Runtime.Interpreter
220-
#endif
221-
222-
#if !MIN_VERSION_ghc(9,3,0)
223206
import Data.IORef
224207
#endif
225208

@@ -228,6 +211,10 @@ import GHC.Unit.Module.Deps (Dependencies(dep_direct_mods), Usage(..))
228211
import GHC.Driver.Config.Stg.Pipeline
229212
#endif
230213

214+
#if !MIN_VERSION_ghc(9,5,0)
215+
import GHC.Core.Lint (lintInteractiveExpr)
216+
#endif
217+
231218
#if MIN_VERSION_ghc(9,5,0)
232219
import GHC.Core.Lint.Interactive (interactiveInScope)
233220
import GHC.Driver.Config.Core.Lint.Interactive (lintInteractiveExpr)
@@ -236,12 +223,14 @@ import GHC.Driver.Config.CoreToStg (initCoreTo
236223
import GHC.Driver.Config.CoreToStg.Prep (initCorePrepConfig)
237224
#endif
238225

226+
#if MIN_VERSION_ghc(9,7,0)
227+
import GHC.Tc.Zonk.TcType (tcInitTidyEnv)
228+
#endif
229+
239230
#if !MIN_VERSION_ghc(9,7,0)
240231
liftZonkM :: a -> a
241232
liftZonkM = id
242-
#endif
243233

244-
#if !MIN_VERSION_ghc(9,7,0)
245234
nonDetFoldOccEnv :: (a -> b -> b) -> b -> OccEnv a -> b
246235
nonDetFoldOccEnv = foldOccEnv
247236
#endif

ghcide/src/Development/IDE/GHC/Compat/Core.hs

+15-21
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
{-# LANGUAGE ConstraintKinds #-}
33
{-# LANGUAGE FlexibleInstances #-}
44
{-# LANGUAGE PatternSynonyms #-}
5-
{-# LANGUAGE ViewPatterns #-}
5+
{-# LANGUAGE ViewPatterns #-}
66

77
-- | Compat Core module that handles the GHC module hierarchy re-organization
88
-- by re-exporting everything we care about.
@@ -85,7 +85,6 @@ module Development.IDE.GHC.Compat.Core (
8585
RecompileRequired(..),
8686
mkPartialIface,
8787
mkFullIface,
88-
checkOldIface,
8988
IsBootInterface(..),
9089
-- * Fixity
9190
LexicalFixity(..),
@@ -120,14 +119,14 @@ module Development.IDE.GHC.Compat.Core (
120119
pattern ConPatIn,
121120
conPatDetails,
122121
mapConPatDetail,
122+
#if MIN_VERSION_ghc(9,5,0)
123123
mkVisFunTys,
124+
#endif
124125
-- * Specs
125126
ImpDeclSpec(..),
126127
ImportSpec(..),
127128
-- * SourceText
128129
SourceText(..),
129-
-- * Name
130-
tyThingParent_maybe,
131130
-- * Ways
132131
Way,
133132
wayGeneralFlags,
@@ -168,6 +167,7 @@ module Development.IDE.GHC.Compat.Core (
168167
hscInteractive,
169168
hscSimplify,
170169
hscTypecheckRename,
170+
hscUpdateHPT,
171171
Development.IDE.GHC.Compat.Core.makeSimpleDetails,
172172
-- * Typecheck utils
173173
tcSplitForAllTyVars,
@@ -176,7 +176,6 @@ module Development.IDE.GHC.Compat.Core (
176176
Development.IDE.GHC.Compat.Core.mkIfaceTc,
177177
Development.IDE.GHC.Compat.Core.mkBootModDetailsTc,
178178
Development.IDE.GHC.Compat.Core.initTidyOpts,
179-
hscUpdateHPT,
180179
driverNoStop,
181180
tidyProgram,
182181
ImportedModsVal(..),
@@ -204,7 +203,6 @@ module Development.IDE.GHC.Compat.Core (
204203
pattern RealSrcLoc,
205204
SrcLoc.SrcLoc(SrcLoc.UnhelpfulLoc),
206205
BufSpan,
207-
SrcSpanAnn',
208206
GHC.SrcAnn,
209207
SrcLoc.leftmost_smallest,
210208
SrcLoc.containsSpan,
@@ -236,7 +234,6 @@ module Development.IDE.GHC.Compat.Core (
236234
-- * Finder
237235
FindResult(..),
238236
mkHomeModLocation,
239-
addBootSuffixLocnOut,
240237
findObjectLinkableMaybe,
241238
InstalledFindResult(..),
242239
-- * Module and Package
@@ -263,7 +260,6 @@ module Development.IDE.GHC.Compat.Core (
263260
Target(..),
264261
TargetId(..),
265262
mkSimpleTarget,
266-
mkModuleGraph,
267263
-- * GHCi
268264
initObjLinker,
269265
loadDLL,
@@ -285,8 +281,6 @@ module Development.IDE.GHC.Compat.Core (
285281
Role(..),
286282
-- * Panic
287283
Plain.PlainGhcException,
288-
panic,
289-
panicDoc,
290284
-- * Other
291285
GHC.CoreModule(..),
292286
GHC.SafeHaskellMode(..),
@@ -321,6 +315,7 @@ module Development.IDE.GHC.Compat.Core (
321315
module GHC.HsToCore.Monad,
322316

323317
module GHC.Iface.Syntax,
318+
module GHC.Iface.Recomp,
324319

325320
module GHC.Hs.Decls,
326321
module GHC.Hs.Expr,
@@ -344,9 +339,8 @@ module Development.IDE.GHC.Compat.Core (
344339

345340
module GHC.Types.Basic,
346341
module GHC.Types.Id,
347-
module GHC.Types.Name ,
342+
module GHC.Types.Name,
348343
module GHC.Types.Name.Set,
349-
350344
module GHC.Types.Name.Cache,
351345
module GHC.Types.Name.Env,
352346
module GHC.Types.Name.Reader,
@@ -361,30 +355,29 @@ module Development.IDE.GHC.Compat.Core (
361355
module GHC.Types.Unique.Supply,
362356
module GHC.Types.Var,
363357
module GHC.Unit.Module,
358+
module GHC.Unit.Module.Graph,
364359
-- * Syntax re-exports
365360
module GHC.Hs,
366361
module GHC.Hs.Binds,
367362
module GHC.Parser,
368363
module GHC.Parser.Header,
369364
module GHC.Parser.Lexer,
365+
module GHC.Utils.Panic,
370366
#if MIN_VERSION_ghc(9,3,0)
371367
CompileReason(..),
372368
hsc_type_env_vars,
373-
hscUpdateHUG, hscUpdateHPT, hsc_HUG,
369+
hscUpdateHUG, hsc_HUG,
374370
GhcMessage(..),
375371
getKey,
376372
module GHC.Driver.Env.KnotVars,
377-
module GHC.Iface.Recomp,
378373
module GHC.Linker.Types,
379-
module GHC.Unit.Module.Graph,
380374
module GHC.Types.Unique.Map,
381375
module GHC.Utils.TmpFs,
382-
module GHC.Utils.Panic,
383376
module GHC.Unit.Finder.Types,
384377
module GHC.Unit.Env,
385378
module GHC.Driver.Phases,
386379
#endif
387-
# if !MIN_VERSION_ghc(9,4,0)
380+
#if !MIN_VERSION_ghc(9,4,0)
388381
pattern HsFieldBind,
389382
hfbAnn,
390383
hfbLHS,
@@ -396,19 +389,20 @@ module Development.IDE.GHC.Compat.Core (
396389
#else
397390
Extension(..),
398391
#endif
399-
UniqFM,
400392
mkCgInteractiveGuts,
401393
justBytecode,
402394
justObjects,
403395
emptyHomeModInfoLinkable,
404396
homeModInfoByteCode,
405397
homeModInfoObject,
406-
# if !MIN_VERSION_ghc(9,5,0)
398+
#if !MIN_VERSION_ghc(9,5,0)
407399
field_label,
408400
#endif
409401
groupOrigin,
410402
isVisibleFunArg,
411-
lookupGlobalRdrEnv,
403+
#if MIN_VERSION_ghc(9,8,0)
404+
lookupGlobalRdrEnv
405+
#endif
412406
) where
413407

414408
import qualified GHC
@@ -539,7 +533,7 @@ import GHC.Unit.Home.ModInfo
539533
import GHC.Unit.Module.Imported
540534
import GHC.Unit.Module.ModDetails
541535
import GHC.Unit.Module.ModGuts
542-
import GHC.Unit.Module.ModIface (IfaceExport, ModIface (..),
536+
import GHC.Unit.Module.ModIface (IfaceExport, ModIface,
543537
ModIface_ (..), mi_fix)
544538
import GHC.Unit.Module.ModSummary (ModSummary (..))
545539
import Language.Haskell.Syntax hiding (FunDep)

0 commit comments

Comments
 (0)