[commit: haddock] ghc-head, ghc-head1, ie_avails, wip/T14529, wip/revert-ttg-2017-11-20, wip/ttg-2017-10-13, wip/ttg-2017-10-31, wip/ttg-2017-11-06, wip/ttg2-2017-11-10, wip/ttg3-2017-11-12, wip/ttg4-constraints-2017-11-13, wip/ttg6-unrevert-2017-11-22: Disable pattern match warnings (#628) (a1b5714)

git at git.haskell.org git at git.haskell.org
Tue Nov 28 11:52:24 UTC 2017


Repository : ssh://git@git.haskell.org/haddock

On branches: ghc-head,ghc-head1,ie_avails,wip/T14529,wip/revert-ttg-2017-11-20,wip/ttg-2017-10-13,wip/ttg-2017-10-31,wip/ttg-2017-11-06,wip/ttg2-2017-11-10,wip/ttg3-2017-11-12,wip/ttg4-constraints-2017-11-13,wip/ttg6-unrevert-2017-11-22
Link       : http://git.haskell.org/haddock.git/commitdiff/a1b57146c5678b32eb5ac37021e93a81a4b73007

>---------------------------------------------------------------

commit a1b57146c5678b32eb5ac37021e93a81a4b73007
Author: Doug Wilson <dwilson at ricoh.co.nz>
Date:   Sat Jun 3 22:02:08 2017 +1200

    Disable pattern match warnings (#628)
    
    This disables the pattern match checker which can be very expensive in some
    cases.
    
    The disabled warnings include:
    * Opt_WarnIncompletePatterns
    * Opt_WarnIncompleteUniPatterns
    * Opt_WarnIncompletePatternsRecUpd
    * Opt_WarnOverlappingPatterns


>---------------------------------------------------------------

a1b57146c5678b32eb5ac37021e93a81a4b73007
 haddock-api/src/Haddock.hs | 22 +++++++++++++++++++---
 1 file changed, 19 insertions(+), 3 deletions(-)

diff --git a/haddock-api/src/Haddock.hs b/haddock-api/src/Haddock.hs
index 637ccf2..080ff92 100644
--- a/haddock-api/src/Haddock.hs
+++ b/haddock-api/src/Haddock.hs
@@ -41,7 +41,7 @@ import Haddock.Utils
 
 import Control.Monad hiding (forM_)
 import Control.Applicative
-import Data.Foldable (forM_)
+import Data.Foldable (forM_, foldl')
 import Data.List (isPrefixOf)
 import Control.Exception
 import Data.Maybe
@@ -72,6 +72,8 @@ import Packages
 import Panic (handleGhcException)
 import Module
 import FastString
+import HscTypes
+import GhcMonad
 
 --------------------------------------------------------------------------------
 -- * Exception handling
@@ -161,7 +163,6 @@ haddockWithGhc ghc args = handleTopExceptions $ do
       hPutStrLn stderr warning
 
   ghc flags' $ do
-
     dflags <- getDynFlags
 
     if not (null files) then do
@@ -397,7 +398,11 @@ withGhc' libDir flags ghcActs = runGhc (Just libDir) $ do
     ghcMode   = CompManager,
     ghcLink   = NoLink
     }
-  let dynflags'' = updOptLevel 0 $ gopt_unset dynflags' Opt_SplitObjs
+  -- We disable pattern match warnings because than can be very
+  -- expensive to check
+  let dynflags'' = unsetPatternMatchWarnings $
+        updOptLevel 0 $
+        gopt_unset dynflags' Opt_SplitObjs
   defaultCleanupHandler dynflags'' $ do
       -- ignore the following return-value, which is a list of packages
       -- that may need to be re-linked: Haddock doesn't do any
@@ -414,6 +419,17 @@ withGhc' libDir flags ghcActs = runGhc (Just libDir) $ do
         then throwE ("Couldn't parse GHC options: " ++ unwords flags)
         else return dynflags'
 
+unsetPatternMatchWarnings :: DynFlags -> DynFlags
+unsetPatternMatchWarnings dflags =
+  foldl' wopt_unset dflags pattern_match_warnings
+  where
+    pattern_match_warnings =
+      [ Opt_WarnIncompletePatterns
+      , Opt_WarnIncompleteUniPatterns
+      , Opt_WarnIncompletePatternsRecUpd
+      , Opt_WarnOverlappingPatterns
+      ]
+
 -------------------------------------------------------------------------------
 -- * Misc
 -------------------------------------------------------------------------------



More information about the ghc-commits mailing list