From d645407e9df0baf3190dd2577e085676207aac39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Hr=C4=8Dek?= Date: Fri, 19 Jan 2024 07:46:07 +0100 Subject: [PATCH 1/3] Fix most -Wall in ghcide --- ghcide/exe/Main.hs | 1 - ghcide/ghcide.cabal | 24 ++++++----- ghcide/src/Development/IDE/GHC/Compat.hs | 41 +++++++------------ ghcide/src/Development/IDE/GHC/Compat/Core.hs | 25 +++++------ ghcide/test/exe/CodeLensTests.hs | 1 - ghcide/test/exe/CompletionTests.hs | 1 - .../test/exe/FindDefinitionAndHoverTests.hs | 4 +- ghcide/test/exe/HieDbRetry.hs | 1 - ghcide/test/exe/HighlightTests.hs | 2 +- ghcide/test/exe/InitializeResponseTests.hs | 2 +- ghcide/test/exe/Progress.hs | 2 +- ghcide/test/exe/TestUtils.hs | 6 +-- 12 files changed, 45 insertions(+), 65 deletions(-) diff --git a/ghcide/exe/Main.hs b/ghcide/exe/Main.hs index 67e109ea98..b9e3637068 100644 --- a/ghcide/exe/Main.hs +++ b/ghcide/exe/Main.hs @@ -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 diff --git a/ghcide/ghcide.cabal b/ghcide/ghcide.cabal index f2d3d4ce77..16b29fbc3d 100644 --- a/ghcide/ghcide.cabal +++ b/ghcide/ghcide.cabal @@ -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: @@ -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 @@ -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 @@ -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 @@ -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: @@ -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: diff --git a/ghcide/src/Development/IDE/GHC/Compat.hs b/ghcide/src/Development/IDE/GHC/Compat.hs index fd5e0c01d5..12c3fb346e 100644 --- a/ghcide/src/Development/IDE/GHC/Compat.hs +++ b/ghcide/src/Development/IDE/GHC/Compat.hs @@ -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, @@ -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, @@ -53,8 +47,9 @@ module Development.IDE.GHC.Compat( nodeAnnotations, mkAstNode, combineRealSrcSpans, - +#if !MIN_VERSION_ghc(9,3,0) nonDetOccEnvElts, +#endif nonDetFoldOccEnv, isQualifiedImport, @@ -94,7 +89,9 @@ module Development.IDE.GHC.Compat( simplifyExpr, tidyExpr, emptyTidyEnv, +#if MIN_VERSION_ghc(9,7,0) tcInitTidyEnv, +#endif corePrepExpr, corePrepPgm, lintInteractiveExpr, @@ -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) @@ -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) @@ -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 @@ -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) @@ -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 diff --git a/ghcide/src/Development/IDE/GHC/Compat/Core.hs b/ghcide/src/Development/IDE/GHC/Compat/Core.hs index 9f35fb6bf6..6d22b11e91 100644 --- a/ghcide/src/Development/IDE/GHC/Compat/Core.hs +++ b/ghcide/src/Development/IDE/GHC/Compat/Core.hs @@ -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. @@ -85,7 +85,6 @@ module Development.IDE.GHC.Compat.Core ( RecompileRequired(..), mkPartialIface, mkFullIface, - checkOldIface, IsBootInterface(..), -- * Fixity LexicalFixity(..), @@ -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, @@ -168,6 +167,7 @@ module Development.IDE.GHC.Compat.Core ( hscInteractive, hscSimplify, hscTypecheckRename, + hscUpdateHPT, Development.IDE.GHC.Compat.Core.makeSimpleDetails, -- * Typecheck utils tcSplitForAllTyVars, @@ -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(..), @@ -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, @@ -236,7 +234,6 @@ module Development.IDE.GHC.Compat.Core ( -- * Finder FindResult(..), mkHomeModLocation, - addBootSuffixLocnOut, findObjectLinkableMaybe, InstalledFindResult(..), -- * Module and Package @@ -263,7 +260,6 @@ module Development.IDE.GHC.Compat.Core ( Target(..), TargetId(..), mkSimpleTarget, - mkModuleGraph, -- * GHCi initObjLinker, loadDLL, @@ -285,8 +281,6 @@ module Development.IDE.GHC.Compat.Core ( Role(..), -- * Panic Plain.PlainGhcException, - panic, - panicDoc, -- * Other GHC.CoreModule(..), GHC.SafeHaskellMode(..), @@ -344,7 +338,7 @@ 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, @@ -370,7 +364,7 @@ module Development.IDE.GHC.Compat.Core ( #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, @@ -396,19 +390,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 diff --git a/ghcide/test/exe/CodeLensTests.hs b/ghcide/test/exe/CodeLensTests.hs index 818e6953d5..c475baa50b 100644 --- a/ghcide/test/exe/CodeLensTests.hs +++ b/ghcide/test/exe/CodeLensTests.hs @@ -12,7 +12,6 @@ import qualified Data.Text as T import Data.Tuple.Extra import Development.IDE.GHC.Compat (GhcVersion (..), ghcVersion) import qualified Language.LSP.Protocol.Lens as L -import Language.LSP.Protocol.Message import Language.LSP.Protocol.Types hiding (SemanticTokenAbsolute (..), SemanticTokenRelative (..), diff --git a/ghcide/test/exe/CompletionTests.hs b/ghcide/test/exe/CompletionTests.hs index 4508197bcc..471e0fd6be 100644 --- a/ghcide/test/exe/CompletionTests.hs +++ b/ghcide/test/exe/CompletionTests.hs @@ -550,7 +550,6 @@ completionDocTests = test doc (Position 1 7) "id" (Just $ T.length expected) [expected] ] where - brokenForGhc9 = knownBrokenFor (BrokenForGHC [GHC90, GHC92, GHC94, GHC96]) "Completion doc doesn't support ghc9" brokenForWinGhc90 = knownBrokenFor (BrokenSpecific Windows [GHC90]) "Extern doc doesn't support Windows for ghc9.2" -- https://gitlab.haskell.org/ghc/ghc/-/issues/20903 brokenForMacGhc9 = knownBrokenFor (BrokenSpecific MacOS [GHC90, GHC92, GHC94, GHC96]) "Extern doc doesn't support MacOS for ghc9" diff --git a/ghcide/test/exe/FindDefinitionAndHoverTests.hs b/ghcide/test/exe/FindDefinitionAndHoverTests.hs index 9627546ac8..98789ab311 100644 --- a/ghcide/test/exe/FindDefinitionAndHoverTests.hs +++ b/ghcide/test/exe/FindDefinitionAndHoverTests.hs @@ -22,7 +22,7 @@ import Language.LSP.Protocol.Types hiding import Language.LSP.Test import System.FilePath import System.Info.Extra (isWindows) --- import Test.QuickCheck.Instances () + import Control.Lens ((^.)) import Test.Tasty import Test.Tasty.HUnit @@ -240,7 +240,7 @@ tests = let yes = Just -- test should run and pass broken = Just . (`xfail` "known broken") no = const Nothing -- don't run this test at all - skip = const Nothing -- unreliable, don't run + --skip = const Nothing -- unreliable, don't run checkFileCompiles :: FilePath -> Session () -> TestTree checkFileCompiles fp diag = diff --git a/ghcide/test/exe/HieDbRetry.hs b/ghcide/test/exe/HieDbRetry.hs index b84715c1b8..3e0c41c2f9 100644 --- a/ghcide/test/exe/HieDbRetry.hs +++ b/ghcide/test/exe/HieDbRetry.hs @@ -44,7 +44,6 @@ errorBusy = SQLite.SQLError{ sqlError = SQLite.ErrorBusy, sqlErrorDetails = "", isErrorCall :: ErrorCall -> Maybe ErrorCall isErrorCall e | ErrorCall _ <- e = Just e - | otherwise = Nothing tests :: TestTree tests = testGroup "RetryHieDb" diff --git a/ghcide/test/exe/HighlightTests.hs b/ghcide/test/exe/HighlightTests.hs index e01377615d..6d8dacfd4a 100644 --- a/ghcide/test/exe/HighlightTests.hs +++ b/ghcide/test/exe/HighlightTests.hs @@ -3,7 +3,7 @@ module HighlightTests (tests) where import Control.Monad.IO.Class (liftIO) import qualified Data.Text as T -import Development.IDE.GHC.Compat (GhcVersion (..), ghcVersion) +import Development.IDE.GHC.Compat (GhcVersion (..)) import Development.IDE.Types.Location import Language.LSP.Protocol.Types hiding (SemanticTokenAbsolute (..), diff --git a/ghcide/test/exe/InitializeResponseTests.hs b/ghcide/test/exe/InitializeResponseTests.hs index 84e673ef8e..e5b336f962 100644 --- a/ghcide/test/exe/InitializeResponseTests.hs +++ b/ghcide/test/exe/InitializeResponseTests.hs @@ -17,7 +17,7 @@ import Language.LSP.Protocol.Types hiding SemanticTokensEdit (..), mkRange) import Language.LSP.Test --- import Test.QuickCheck.Instances () + import Control.Lens ((^.)) import Development.IDE.Plugin.Test (blockCommandId) import Test.Tasty diff --git a/ghcide/test/exe/Progress.hs b/ghcide/test/exe/Progress.hs index a92fea9bc4..08ad03c78b 100644 --- a/ghcide/test/exe/Progress.hs +++ b/ghcide/test/exe/Progress.hs @@ -38,7 +38,7 @@ reportProgressTests = testGroup "recordProgress" model state $ \st -> recordProgress st key change model stateModelIO k = do state <- fromModel =<< stateModelIO - k state + _ <- k state toModel state test name p = testCase name $ do InProgressModel{..} <- p diff --git a/ghcide/test/exe/TestUtils.hs b/ghcide/test/exe/TestUtils.hs index 676cad1b34..91f43aced1 100644 --- a/ghcide/test/exe/TestUtils.hs +++ b/ghcide/test/exe/TestUtils.hs @@ -7,8 +7,8 @@ module TestUtils where import Control.Applicative.Combinators import Control.Concurrent.Async -import Control.Exception (bracket_, finally, throw) -import Control.Lens ((.~), (^.)) +import Control.Exception (bracket_, finally) +import Control.Lens ((.~)) import qualified Control.Lens as Lens import qualified Control.Lens.Extras as Lens import Control.Monad @@ -48,8 +48,6 @@ import Test.Tasty.HUnit import LogType -import Data.Traversable (for) - -- | Wait for the next progress begin step waitForProgressBegin :: Session () waitForProgressBegin = skipManyTill anyMessage $ satisfyMaybe $ \case From 8df8e35da6c9d545c81396d294f0333e037ca15d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Hr=C4=8Dek?= Date: Fri, 19 Jan 2024 18:51:05 +0100 Subject: [PATCH 2/3] Fix ghc 9.2.8 --- ghcide/src/Development/IDE/GHC/Compat/Core.hs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/ghcide/src/Development/IDE/GHC/Compat/Core.hs b/ghcide/src/Development/IDE/GHC/Compat/Core.hs index 6d22b11e91..683770b3de 100644 --- a/ghcide/src/Development/IDE/GHC/Compat/Core.hs +++ b/ghcide/src/Development/IDE/GHC/Compat/Core.hs @@ -315,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, @@ -340,7 +341,6 @@ module Development.IDE.GHC.Compat.Core ( module GHC.Types.Id, module GHC.Types.Name, module GHC.Types.Name.Set, - module GHC.Types.Name.Cache, module GHC.Types.Name.Env, module GHC.Types.Name.Reader, @@ -355,12 +355,14 @@ 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, @@ -368,12 +370,9 @@ module Development.IDE.GHC.Compat.Core ( 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, @@ -534,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) From 5599ce9d546d94fd5017504306d749e21f6069d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Hr=C4=8Dek?= Date: Sat, 20 Jan 2024 08:24:22 +0100 Subject: [PATCH 3/3] No spaces after CPP # --- ghcide/src/Development/IDE/GHC/CPP.hs | 6 +++--- ghcide/src/Development/IDE/GHC/Compat/Core.hs | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ghcide/src/Development/IDE/GHC/CPP.hs b/ghcide/src/Development/IDE/GHC/CPP.hs index b65fa8e89a..d11aa9f5a0 100644 --- a/ghcide/src/Development/IDE/GHC/CPP.hs +++ b/ghcide/src/Development/IDE/GHC/CPP.hs @@ -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 diff --git a/ghcide/src/Development/IDE/GHC/Compat/Core.hs b/ghcide/src/Development/IDE/GHC/Compat/Core.hs index 683770b3de..9df82e6c9c 100644 --- a/ghcide/src/Development/IDE/GHC/Compat/Core.hs +++ b/ghcide/src/Development/IDE/GHC/Compat/Core.hs @@ -377,7 +377,7 @@ module Development.IDE.GHC.Compat.Core ( 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,