Skip to content

Commit e56e2d1

Browse files
committed
Fix most -Wall in ghcide
1 parent 6620f2c commit e56e2d1

12 files changed

+45
-65
lines changed

ghcide/exe/Main.hs

Lines changed: 0 additions & 1 deletion
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

Lines changed: 13 additions & 11 deletions
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/Compat.hs

Lines changed: 15 additions & 26 deletions
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

Lines changed: 10 additions & 15 deletions
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(..),
@@ -344,7 +338,7 @@ module Development.IDE.GHC.Compat.Core (
344338

345339
module GHC.Types.Basic,
346340
module GHC.Types.Id,
347-
module GHC.Types.Name ,
341+
module GHC.Types.Name,
348342
module GHC.Types.Name.Set,
349343

350344
module GHC.Types.Name.Cache,
@@ -370,7 +364,7 @@ module Development.IDE.GHC.Compat.Core (
370364
#if MIN_VERSION_ghc(9,3,0)
371365
CompileReason(..),
372366
hsc_type_env_vars,
373-
hscUpdateHUG, hscUpdateHPT, hsc_HUG,
367+
hscUpdateHUG, hsc_HUG,
374368
GhcMessage(..),
375369
getKey,
376370
module GHC.Driver.Env.KnotVars,
@@ -396,19 +390,20 @@ module Development.IDE.GHC.Compat.Core (
396390
#else
397391
Extension(..),
398392
#endif
399-
UniqFM,
400393
mkCgInteractiveGuts,
401394
justBytecode,
402395
justObjects,
403396
emptyHomeModInfoLinkable,
404397
homeModInfoByteCode,
405398
homeModInfoObject,
406-
# if !MIN_VERSION_ghc(9,5,0)
399+
#if !MIN_VERSION_ghc(9,5,0)
407400
field_label,
408401
#endif
409402
groupOrigin,
410403
isVisibleFunArg,
411-
lookupGlobalRdrEnv,
404+
#if MIN_VERSION_ghc(9,8,0)
405+
lookupGlobalRdrEnv
406+
#endif
412407
) where
413408

414409
import qualified GHC

ghcide/test/exe/CodeLensTests.hs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import qualified Data.Text as T
1212
import Data.Tuple.Extra
1313
import Development.IDE.GHC.Compat (GhcVersion (..), ghcVersion)
1414
import qualified Language.LSP.Protocol.Lens as L
15-
import Language.LSP.Protocol.Message
1615
import Language.LSP.Protocol.Types hiding
1716
(SemanticTokenAbsolute (..),
1817
SemanticTokenRelative (..),

ghcide/test/exe/CompletionTests.hs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -550,7 +550,6 @@ completionDocTests =
550550
test doc (Position 1 7) "id" (Just $ T.length expected) [expected]
551551
]
552552
where
553-
brokenForGhc9 = knownBrokenFor (BrokenForGHC [GHC90, GHC92, GHC94, GHC96]) "Completion doc doesn't support ghc9"
554553
brokenForWinGhc90 = knownBrokenFor (BrokenSpecific Windows [GHC90]) "Extern doc doesn't support Windows for ghc9.2"
555554
-- https://gitlab.haskell.org/ghc/ghc/-/issues/20903
556555
brokenForMacGhc9 = knownBrokenFor (BrokenSpecific MacOS [GHC90, GHC92, GHC94, GHC96]) "Extern doc doesn't support MacOS for ghc9"

ghcide/test/exe/FindDefinitionAndHoverTests.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import Language.LSP.Protocol.Types hiding
2222
import Language.LSP.Test
2323
import System.FilePath
2424
import System.Info.Extra (isWindows)
25-
-- import Test.QuickCheck.Instances ()
25+
2626
import Control.Lens ((^.))
2727
import Test.Tasty
2828
import Test.Tasty.HUnit
@@ -240,7 +240,7 @@ tests = let
240240
yes = Just -- test should run and pass
241241
broken = Just . (`xfail` "known broken")
242242
no = const Nothing -- don't run this test at all
243-
skip = const Nothing -- unreliable, don't run
243+
--skip = const Nothing -- unreliable, don't run
244244

245245
checkFileCompiles :: FilePath -> Session () -> TestTree
246246
checkFileCompiles fp diag =

ghcide/test/exe/HieDbRetry.hs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ errorBusy = SQLite.SQLError{ sqlError = SQLite.ErrorBusy, sqlErrorDetails = "",
4444
isErrorCall :: ErrorCall -> Maybe ErrorCall
4545
isErrorCall e
4646
| ErrorCall _ <- e = Just e
47-
| otherwise = Nothing
4847

4948
tests :: TestTree
5049
tests = testGroup "RetryHieDb"

ghcide/test/exe/HighlightTests.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module HighlightTests (tests) where
33

44
import Control.Monad.IO.Class (liftIO)
55
import qualified Data.Text as T
6-
import Development.IDE.GHC.Compat (GhcVersion (..), ghcVersion)
6+
import Development.IDE.GHC.Compat (GhcVersion (..))
77
import Development.IDE.Types.Location
88
import Language.LSP.Protocol.Types hiding
99
(SemanticTokenAbsolute (..),

ghcide/test/exe/InitializeResponseTests.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import Language.LSP.Protocol.Types hiding
1717
SemanticTokensEdit (..),
1818
mkRange)
1919
import Language.LSP.Test
20-
-- import Test.QuickCheck.Instances ()
20+
2121
import Control.Lens ((^.))
2222
import Development.IDE.Plugin.Test (blockCommandId)
2323
import Test.Tasty

0 commit comments

Comments
 (0)