Skip to content

Fix most -Wall in ghcide #3984

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jan 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion ghcide/exe/Main.hs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
-- Copyright (c) 2019 The DAML Authors. All rights reserved.
-- SPDX-License-Identifier: Apache-2.0
{-# OPTIONS_GHC -Wno-dodgy-imports #-} -- GHC no longer exports def in GHC 8.6 and above
{-# LANGUAGE TemplateHaskell #-}

module Main(main) where
Expand Down
24 changes: 13 additions & 11 deletions ghcide/ghcide.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ flag pedantic
default: False
manual: True

common warnings
ghc-options:
-Wall -Wincomplete-uni-patterns -Wunused-packages
-Wno-unticked-promoted-constructors
-fno-ignore-asserts

library
default-language: Haskell2010
build-depends:
Expand Down Expand Up @@ -218,10 +224,6 @@ library
Development.IDE.Session.VersionCheck
Development.IDE.Types.Action

ghc-options:
-Wall -Wincomplete-uni-patterns -Wno-unticked-promoted-constructors
-Wunused-packages -fno-ignore-asserts

if flag(pedantic)
-- We eventually want to build with Werror fully, but we haven't
-- finished purging the warnings, so some are set to not be errors
Expand All @@ -246,9 +248,10 @@ flag test-exe
default: True

executable ghcide-test-preprocessor
import: warnings
default-language: Haskell2010
hs-source-dirs: test/preprocessor
ghc-options: -Wall -Wno-name-shadowing
ghc-options: -Wno-name-shadowing
main-is: Main.hs
build-depends: base >=4 && <5

Expand All @@ -260,11 +263,11 @@ flag executable
default: True

executable ghcide
import: warnings
default-language: Haskell2010
hs-source-dirs: exe
ghc-options:
-threaded -Wall -Wincomplete-uni-patterns -Wno-name-shadowing -Wunused-packages
-rtsopts "-with-rtsopts=-I0 -A128M -T"
ghc-options: -threaded -rtsopts "-with-rtsopts=-I0 -A128M -T" -Wno-name-shadowing


-- allow user RTS overrides
-- disable idle GC
Expand Down Expand Up @@ -314,6 +317,7 @@ executable ghcide
cpp-options: -DMONITORING_EKG

test-suite ghcide-tests
import: warnings
type: exitcode-stdio-1.0
default-language: Haskell2010
build-tool-depends:
Expand Down Expand Up @@ -371,9 +375,7 @@ test-suite ghcide-tests
build-depends: ghc-typelits-knownnat

hs-source-dirs: test/cabal test/exe test/src
ghc-options:
-threaded -Wall -Wno-name-shadowing -O0
-Wno-unticked-promoted-constructors -Wunused-packages
ghc-options: -threaded -O0 -Wno-name-shadowing

main-is: Main.hs
other-modules:
Expand Down
6 changes: 3 additions & 3 deletions ghcide/src/Development/IDE/GHC/CPP.hs
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@ doCpp env input_fn output_fn =
#if MIN_VERSION_ghc(9,5,0)
let cpp_opts = Pipeline.CppOpts
{ cppLinePragmas = True
# if MIN_VERSION_ghc(9,9,0)
#if MIN_VERSION_ghc(9,9,0)
, useHsCpp = True
# else
#else
, cppUseCc = False
# endif
#endif
} in
#else
let cpp_opts = True in
Expand Down
41 changes: 15 additions & 26 deletions ghcide/src/Development/IDE/GHC/Compat.hs
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,15 @@
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE PatternSynonyms #-}
{-# OPTIONS -Wno-incomplete-uni-patterns -Wno-dodgy-imports #-}

-- | Attempt at hiding the GHC version differences we can.
module Development.IDE.GHC.Compat(
mkHomeModLocation,
hPutStringBuffer,
addIncludePathsQuote,
getModuleHash,
setUpTypedHoles,
NameCacheUpdater(..),
#if MIN_VERSION_ghc(9,3,0)
getMessages,
renderDiagnosticMessageWithHints,
nameEnvElts,
#else
upNameCache,
Expand All @@ -26,10 +22,8 @@ module Development.IDE.GHC.Compat(
disableWarningsAsErrors,
reLoc,
reLocA,
getPsMessages,
renderMessages,
pattern PFailedWithErrorMessages,
isObjectLinkable,

#if !MIN_VERSION_ghc(9,3,0)
extendModSummaryNoDeps,
Expand All @@ -53,8 +47,9 @@ module Development.IDE.GHC.Compat(
nodeAnnotations,
mkAstNode,
combineRealSrcSpans,

#if !MIN_VERSION_ghc(9,3,0)
nonDetOccEnvElts,
#endif
nonDetFoldOccEnv,

isQualifiedImport,
Expand Down Expand Up @@ -94,7 +89,9 @@ module Development.IDE.GHC.Compat(
simplifyExpr,
tidyExpr,
emptyTidyEnv,
#if MIN_VERSION_ghc(9,7,0)
tcInitTidyEnv,
#endif
corePrepExpr,
corePrepPgm,
lintInteractiveExpr,
Expand Down Expand Up @@ -160,11 +157,6 @@ import Data.List (foldl')
import qualified Data.Map as Map
import qualified Data.Set as S

-- See Note [Guidelines For Using CPP In GHCIDE Import Statements]

#if MIN_VERSION_ghc(9,7,0)
import GHC.Tc.Zonk.TcType (tcInitTidyEnv)
#endif
import qualified GHC.Core.Opt.Pipeline as GHC
import GHC.Core.Tidy (tidyExpr)
import GHC.CoreToStg.Prep (corePrepPgm)
Expand All @@ -187,15 +179,8 @@ import GHC.Iface.Make (mkIfaceExports)
import GHC.SysTools.Tasks (runUnlit, runPp)
import qualified GHC.Types.Avail as Avail


#if !MIN_VERSION_ghc(9,5,0)
import GHC.Core.Lint (lintInteractiveExpr)
#endif


import GHC.Iface.Env
import GHC.Types.SrcLoc (combineRealSrcSpans)
import GHC.Linker.Loader (loadExpr)
import GHC.Runtime.Context (icInteractiveModule)
import GHC.Unit.Home.ModInfo (HomePackageTable,
lookupHpt)
Expand All @@ -205,21 +190,19 @@ import GHC.Builtin.Uniques
import GHC.ByteCode.Types
import GHC.CoreToStg
import GHC.Data.Maybe
import GHC.Linker.Loader (loadDecls)
import GHC.Linker.Loader (loadDecls, loadExpr)
import GHC.Stg.Pipeline
import GHC.Stg.Syntax
import GHC.StgToByteCode
import GHC.Types.CostCentre
import GHC.Types.IPE

-- See Note [Guidelines For Using CPP In GHCIDE Import Statements]

#if !MIN_VERSION_ghc(9,3,0)
import GHC.Unit.Module.Deps (Dependencies(dep_mods), Usage(..))
import GHC.Linker.Types (isObjectLinkable)
import GHC.Unit.Module.ModSummary
import GHC.Runtime.Interpreter
#endif

#if !MIN_VERSION_ghc(9,3,0)
import Data.IORef
#endif

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

#if !MIN_VERSION_ghc(9,5,0)
import GHC.Core.Lint (lintInteractiveExpr)
#endif

#if MIN_VERSION_ghc(9,5,0)
import GHC.Core.Lint.Interactive (interactiveInScope)
import GHC.Driver.Config.Core.Lint.Interactive (lintInteractiveExpr)
Expand All @@ -236,12 +223,14 @@ import GHC.Driver.Config.CoreToStg (initCoreTo
import GHC.Driver.Config.CoreToStg.Prep (initCorePrepConfig)
#endif

#if MIN_VERSION_ghc(9,7,0)
import GHC.Tc.Zonk.TcType (tcInitTidyEnv)
#endif

#if !MIN_VERSION_ghc(9,7,0)
liftZonkM :: a -> a
liftZonkM = id
#endif

#if !MIN_VERSION_ghc(9,7,0)
nonDetFoldOccEnv :: (a -> b -> b) -> b -> OccEnv a -> b
nonDetFoldOccEnv = foldOccEnv
#endif
Expand Down
36 changes: 15 additions & 21 deletions ghcide/src/Development/IDE/GHC/Compat/Core.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE ViewPatterns #-}
{-# LANGUAGE ViewPatterns #-}

-- | Compat Core module that handles the GHC module hierarchy re-organization
-- by re-exporting everything we care about.
Expand Down Expand Up @@ -85,7 +85,6 @@ module Development.IDE.GHC.Compat.Core (
RecompileRequired(..),
mkPartialIface,
mkFullIface,
checkOldIface,
IsBootInterface(..),
-- * Fixity
LexicalFixity(..),
Expand Down Expand Up @@ -120,14 +119,14 @@ module Development.IDE.GHC.Compat.Core (
pattern ConPatIn,
conPatDetails,
mapConPatDetail,
#if MIN_VERSION_ghc(9,5,0)
mkVisFunTys,
#endif
-- * Specs
ImpDeclSpec(..),
ImportSpec(..),
-- * SourceText
SourceText(..),
-- * Name
tyThingParent_maybe,
-- * Ways
Way,
wayGeneralFlags,
Expand Down Expand Up @@ -168,6 +167,7 @@ module Development.IDE.GHC.Compat.Core (
hscInteractive,
hscSimplify,
hscTypecheckRename,
hscUpdateHPT,
Development.IDE.GHC.Compat.Core.makeSimpleDetails,
-- * Typecheck utils
tcSplitForAllTyVars,
Expand All @@ -176,7 +176,6 @@ module Development.IDE.GHC.Compat.Core (
Development.IDE.GHC.Compat.Core.mkIfaceTc,
Development.IDE.GHC.Compat.Core.mkBootModDetailsTc,
Development.IDE.GHC.Compat.Core.initTidyOpts,
hscUpdateHPT,
driverNoStop,
tidyProgram,
ImportedModsVal(..),
Expand Down Expand Up @@ -204,7 +203,6 @@ module Development.IDE.GHC.Compat.Core (
pattern RealSrcLoc,
SrcLoc.SrcLoc(SrcLoc.UnhelpfulLoc),
BufSpan,
SrcSpanAnn',
GHC.SrcAnn,
SrcLoc.leftmost_smallest,
SrcLoc.containsSpan,
Expand Down Expand Up @@ -236,7 +234,6 @@ module Development.IDE.GHC.Compat.Core (
-- * Finder
FindResult(..),
mkHomeModLocation,
addBootSuffixLocnOut,
findObjectLinkableMaybe,
InstalledFindResult(..),
-- * Module and Package
Expand All @@ -263,7 +260,6 @@ module Development.IDE.GHC.Compat.Core (
Target(..),
TargetId(..),
mkSimpleTarget,
mkModuleGraph,
-- * GHCi
initObjLinker,
loadDLL,
Expand All @@ -285,8 +281,6 @@ module Development.IDE.GHC.Compat.Core (
Role(..),
-- * Panic
Plain.PlainGhcException,
panic,
panicDoc,
-- * Other
GHC.CoreModule(..),
GHC.SafeHaskellMode(..),
Expand Down Expand Up @@ -321,6 +315,7 @@ module Development.IDE.GHC.Compat.Core (
module GHC.HsToCore.Monad,

module GHC.Iface.Syntax,
module GHC.Iface.Recomp,

module GHC.Hs.Decls,
module GHC.Hs.Expr,
Expand All @@ -344,9 +339,8 @@ module Development.IDE.GHC.Compat.Core (

module GHC.Types.Basic,
module GHC.Types.Id,
module GHC.Types.Name ,
module GHC.Types.Name,
module GHC.Types.Name.Set,

module GHC.Types.Name.Cache,
module GHC.Types.Name.Env,
module GHC.Types.Name.Reader,
Expand All @@ -361,30 +355,29 @@ module Development.IDE.GHC.Compat.Core (
module GHC.Types.Unique.Supply,
module GHC.Types.Var,
module GHC.Unit.Module,
module GHC.Unit.Module.Graph,
-- * Syntax re-exports
module GHC.Hs,
module GHC.Hs.Binds,
module GHC.Parser,
module GHC.Parser.Header,
module GHC.Parser.Lexer,
module GHC.Utils.Panic,
#if MIN_VERSION_ghc(9,3,0)
CompileReason(..),
hsc_type_env_vars,
hscUpdateHUG, hscUpdateHPT, hsc_HUG,
hscUpdateHUG, hsc_HUG,
GhcMessage(..),
getKey,
module GHC.Driver.Env.KnotVars,
module GHC.Iface.Recomp,
module GHC.Linker.Types,
module GHC.Unit.Module.Graph,
module GHC.Types.Unique.Map,
module GHC.Utils.TmpFs,
module GHC.Utils.Panic,
module GHC.Unit.Finder.Types,
module GHC.Unit.Env,
module GHC.Driver.Phases,
#endif
# if !MIN_VERSION_ghc(9,4,0)
#if !MIN_VERSION_ghc(9,4,0)
pattern HsFieldBind,
hfbAnn,
hfbLHS,
Expand All @@ -396,19 +389,20 @@ module Development.IDE.GHC.Compat.Core (
#else
Extension(..),
#endif
UniqFM,
mkCgInteractiveGuts,
justBytecode,
justObjects,
emptyHomeModInfoLinkable,
homeModInfoByteCode,
homeModInfoObject,
# if !MIN_VERSION_ghc(9,5,0)
#if !MIN_VERSION_ghc(9,5,0)
field_label,
#endif
groupOrigin,
isVisibleFunArg,
lookupGlobalRdrEnv,
#if MIN_VERSION_ghc(9,8,0)
lookupGlobalRdrEnv
#endif
) where

import qualified GHC
Expand Down Expand Up @@ -539,7 +533,7 @@ import GHC.Unit.Home.ModInfo
import GHC.Unit.Module.Imported
import GHC.Unit.Module.ModDetails
import GHC.Unit.Module.ModGuts
import GHC.Unit.Module.ModIface (IfaceExport, ModIface (..),
import GHC.Unit.Module.ModIface (IfaceExport, ModIface,
ModIface_ (..), mi_fix)
import GHC.Unit.Module.ModSummary (ModSummary (..))
import Language.Haskell.Syntax hiding (FunDep)
Expand Down
Loading