Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC

Commits:

15 changed files:

Changes:

  • compiler/GHC/Driver/Errors.hs
    1
    +{-# OPTIONS_GHC -Wno-x-InternalMCDiagnostic #-}
    
    1 2
     module GHC.Driver.Errors (
    
    2 3
         reportError
    
    3 4
       , reportDiagnostic
    
    ... ... @@ -66,7 +67,7 @@ printMessage logger msg_opts opts message
    66 67
         doc = updSDocContext (\_ -> ctx) (messageWithHints diagnostic)
    
    67 68
     
    
    68 69
         messageClass :: MessageClass
    
    69
    -    messageClass = MCDiagnostic severity (errMsgReason message) (diagnosticCode diagnostic)
    
    70
    +    messageClass = InternalMCDiagnostic severity (errMsgReason message) (diagnosticCode diagnostic)
    
    70 71
     
    
    71 72
         style :: PprStyle
    
    72 73
         style = mkErrStyle (errMsgContext message)
    

  • compiler/GHC/Driver/Main/Passes.hs
    ... ... @@ -2,6 +2,7 @@
    2 2
     {-# LANGUAGE MultiWayIf #-}
    
    3 3
     
    
    4 4
     {-# OPTIONS_GHC -fprof-auto-top #-}
    
    5
    +{-# OPTIONS_GHC -Wwarn=x-internalPprMessages #-}
    
    5 6
     
    
    6 7
     -------------------------------------------------------------------------------
    
    7 8
     -- | Aspects of GHC.Driver.Main dealing with running particular passes.
    
    ... ... @@ -1401,9 +1402,15 @@ markUnsafeInfer tcg_env whyUnsafe = do
    1401 1402
         whyUnsafe' df = vcat [ quotes pprMod <+> text "has been inferred as unsafe!"
    
    1402 1403
                              , text "Reason:"
    
    1403 1404
                              , nest 4 $ (vcat $ badFlags df) $+$
    
    1404
    -                                    -- MP: Using defaultDiagnosticOpts here is not right but it's also not right to handle these
    
    1405
    -                                    -- unsafety error messages in an unstructured manner.
    
    1406
    -                                    (vcat $ pprMsgEnvelopeBagWithLoc (defaultDiagnosticOpts @e) (getMessages whyUnsafe)) $+$
    
    1405
    +
    
    1406
    +                                    -- FIXME: `GHC.Utils.Error.internalPprMessages` is an
    
    1407
    +                                    -- internal function!
    
    1408
    +                                    --
    
    1409
    +                                    -- Use `GHC.Driver.Errors.printMessages` to report the
    
    1410
    +                                    -- diagnostics here and remove `internalPprMessages`
    
    1411
    +                                    -- from the export list of "GHC.Utils.Error".
    
    1412
    +                                    (vcat $ internalPprMessages (getMessages whyUnsafe)) $+$
    
    1413
    +
    
    1407 1414
                                         (vcat $ badInsts $ tcg_insts tcg_env)
    
    1408 1415
                              ]
    
    1409 1416
         badFlags df   = concatMap (badFlag df) unsafeFlagsForInfer
    

  • compiler/GHC/Driver/Pipeline.hs
    ... ... @@ -101,7 +101,7 @@ import GHC.Iface.Recomp
    101 101
     import GHC.Runtime.Loader      ( initializePlugins )
    
    102 102
     
    
    103 103
     import GHC.Types.Basic        ( SuccessFlag(..), ForeignSrcLang(..) )
    
    104
    -import GHC.Types.Error        ( singleMessage, getMessages, mkSimpleUnknownDiagnostic, defaultDiagnosticOpts )
    
    104
    +import GHC.Types.Error        ( singleMessage, getMessages, mkSimpleUnknownDiagnostic )
    
    105 105
     import GHC.Types.ForeignStubs ( ForeignStubs (NoStubs) )
    
    106 106
     import GHC.Types.Target
    
    107 107
     import GHC.Types.SrcLoc
    
    ... ... @@ -169,9 +169,7 @@ preprocess hsc_env input_fn mb_input_buf mb_phase =
    169 169
     
    
    170 170
         to_driver_messages :: Messages GhcMessage -> Messages DriverMessage
    
    171 171
         to_driver_messages msgs = case traverse to_driver_message msgs of
    
    172
    -      Nothing    -> pprPanic "non-driver message in preprocess"
    
    173
    -                             -- MP: Default config is fine here as it's just in a panic.
    
    174
    -                             (vcat $ pprMsgEnvelopeBagWithLoc (defaultDiagnosticOpts @GhcMessage) (getMessages msgs))
    
    172
    +      Nothing    -> panicMessage "non-driver message in preprocess" (getMessages msgs)
    
    175 173
           Just msgs' -> msgs'
    
    176 174
     
    
    177 175
         to_driver_message = \case
    

  • compiler/GHC/HsToCore/Monad.hs
    ... ... @@ -404,7 +404,7 @@ initTcDsForSolver thing_inside
    404 404
              thing_inside
    
    405 405
            ; case mb_ret of
    
    406 406
                Just ret -> pure ret
    
    407
    -           Nothing  -> pprPanic "initTcDsForSolver" (vcat $ pprMsgEnvelopeBagWithLocDefault (getErrorMessages msgs)) }
    
    407
    +           Nothing  -> panicMessage "initTcDsForSolver" (getErrorMessages msgs) }
    
    408 408
     
    
    409 409
     mkDsEnvs :: UnitEnv -> Module -> GlobalRdrEnv -> TypeEnv -> FamInstEnv
    
    410 410
              -> TcMPluginsRun
    

  • compiler/GHC/Tc/Errors.hs
    ... ... @@ -71,7 +71,7 @@ import GHC.Core.TyCo.FVs
    71 71
     import GHC.Core.InstEnv
    
    72 72
     import GHC.Core.TyCon
    
    73 73
     
    
    74
    -import GHC.Utils.Error  (diagReasonSeverity,  pprLocMsgEnvelope )
    
    74
    +import GHC.Utils.Error  (diagReasonSeverity, deferredTypeErrorMessage )
    
    75 75
     import GHC.Utils.Misc
    
    76 76
     import GHC.Utils.Outputable as O
    
    77 77
     import GHC.Utils.Panic
    
    ... ... @@ -1395,9 +1395,8 @@ mkErrorTerm ct_loc ty ctxt msg supp hints
    1395 1395
                       hints
    
    1396 1396
              -- This will be reported at runtime, so we always want "error:" in the report, never "warning:"
    
    1397 1397
            ; dflags <- getDynFlags
    
    1398
    -       ; let err_msg = pprLocMsgEnvelope (initTcMessageOpts dflags) msg
    
    1399
    -             err_str = showSDoc dflags $
    
    1400
    -                       err_msg $$ text "(deferred type error)"
    
    1398
    +       ; let err_msg = deferredTypeErrorMessage (initTcMessageOpts dflags) msg
    
    1399
    +             err_str = showSDoc dflags err_msg
    
    1401 1400
     
    
    1402 1401
            ; return $ evDelayedError ty err_str }
    
    1403 1402
     
    

  • compiler/GHC/Tc/Utils/Monad.hs
    1 1
     {-# LANGUAGE RecordWildCards #-}
    
    2 2
     
    
    3 3
     {-# OPTIONS_GHC -fno-warn-orphans #-}
    
    4
    +{-# OPTIONS_GHC -Wno-x-internalDebugPprMsgEnvelope #-}
    
    4 5
     
    
    5 6
     {-
    
    6 7
     (c) The University of Glasgow 2006
    
    ... ... @@ -1432,7 +1433,7 @@ reportDiagnostics = mapM_ reportDiagnostic
    1432 1433
     
    
    1433 1434
     reportDiagnostic :: MsgEnvelope TcRnMessage -> TcRn ()
    
    1434 1435
     reportDiagnostic msg
    
    1435
    -  = do { traceTc "Adding diagnostic:" (pprLocMsgEnvelopeDefault msg) ;
    
    1436
    +  = do { traceTc "Adding diagnostic:" (internalDebugPprMsgEnvelope msg) ;
    
    1436 1437
              errs_var <- getErrsVar ;
    
    1437 1438
              msgs     <- readTcRef errs_var ;
    
    1438 1439
              writeTcRef errs_var (msg `addMessage` msgs) }
    

  • compiler/GHC/Types/Error.hs
    ... ... @@ -18,7 +18,7 @@ module GHC.Types.Error
    18 18
     
    
    19 19
        -- * Classifying Messages
    
    20 20
     
    
    21
    -   , MessageClass (..)
    
    21
    +   , MessageClass (MCDiagnostic, ..)
    
    22 22
        , Severity (..)
    
    23 23
        , Diagnostic (..)
    
    24 24
        , UnknownDiagnostic (..)
    
    ... ... @@ -482,7 +482,7 @@ data MessageClass
    482 482
         -- ^ Log messages intended for end users.
    
    483 483
         -- No file\/line\/column stuff.
    
    484 484
     
    
    485
    -  | MCDiagnostic Severity ResolvedDiagnosticReason (Maybe DiagnosticCode)
    
    485
    +  | InternalMCDiagnostic Severity ResolvedDiagnosticReason (Maybe DiagnosticCode)
    
    486 486
         -- ^ Diagnostics from the compiler. This constructor is very powerful as
    
    487 487
         -- it allows the construction of a 'MessageClass' with a completely
    
    488 488
         -- arbitrary permutation of 'Severity' and 'DiagnosticReason'. As such,
    
    ... ... @@ -492,10 +492,19 @@ data MessageClass
    492 492
         -- 'GHC.Utils.Error'. In all the other circumstances, /especially/ when
    
    493 493
         -- emitting compiler diagnostics, use higher level primitives.
    
    494 494
         --
    
    495
    +    -- For deconstruction use `MCDiagnostic`.
    
    496
    +    --
    
    495 497
         -- The @Maybe 'DiagnosticCode'@ field carries a code (if available) for
    
    496 498
         -- this diagnostic. If you are creating a message not tied to any
    
    497 499
         -- error-message type, then use Nothing. In the long run, this really
    
    498 500
         -- should always have a 'DiagnosticCode'. See Note [Diagnostic codes].
    
    501
    +    --
    
    502
    +{-# WARNING in "x-InternalMCDiagnostic" InternalMCDiagnostic
    
    503
    +    "This is an internal constructor.  Use `MCDiagnostic` or `GHC.Driver.Errors.printMessages` instead." #-}
    
    504
    +
    
    505
    +{-# COMPLETE MCOutput, MCFatal, MCInteractive, MCDump, MCInfo, MCDiagnostic #-}
    
    506
    +pattern MCDiagnostic :: Severity -> ResolvedDiagnosticReason -> Maybe DiagnosticCode -> MessageClass
    
    507
    +pattern MCDiagnostic severity reason code <- InternalMCDiagnostic severity reason code
    
    499 508
     
    
    500 509
     {-
    
    501 510
     Note [Suppressing Messages]
    

  • compiler/GHC/Types/Error.hs-boot deleted
    1
    -module GHC.Types.Error where
    
    2
    -
    
    3
    -import GHC.Prelude (Maybe, Bool, IO)
    
    4
    -import GHC.Utils.Outputable (SDoc)
    
    5
    -import GHC.Types.SrcLoc (SrcSpan)
    
    6
    -
    
    7
    -data MessageClass
    
    8
    -  = MCOutput
    
    9
    -  | MCFatal
    
    10
    -  | MCInteractive
    
    11
    -  | MCDump
    
    12
    -  | MCInfo
    
    13
    -  | MCDiagnostic Severity ResolvedDiagnosticReason (Maybe DiagnosticCode)
    
    14
    -
    
    15
    -data Severity
    
    16
    -  = SevIgnore
    
    17
    -  | SevWarning
    
    18
    -  | SevError
    
    19
    -
    
    20
    -data DiagnosticCode
    
    21
    -data ResolvedDiagnosticReason
    
    22
    -
    
    23
    -mkLocMessageWarningGroups  :: Bool -> MessageClass -> SrcSpan -> SDoc -> SDoc
    
    24
    -getCaretDiagnostic :: MessageClass -> SrcSpan -> IO SDoc

  • compiler/GHC/Types/SourceError.hs
    1
    +{-# OPTIONS_GHC -Wno-x-internalDebugShowMessages #-}
    
    1 2
     -- | Source errors
    
    2 3
     module GHC.Types.SourceError
    
    3 4
        ( SourceError (..)
    
    ... ... @@ -16,8 +17,7 @@ import GHC.Types.Error
    16 17
     import GHC.Utils.Monad
    
    17 18
     import GHC.Utils.Panic
    
    18 19
     import GHC.Utils.Exception
    
    19
    -import GHC.Utils.Error (pprMsgEnvelopeBagWithLocDefault, DiagOpts, diag_ppr_ctx)
    
    20
    -import GHC.Utils.Outputable
    
    20
    +import GHC.Utils.Error (internalDebugShowMessages, DiagOpts)
    
    21 21
     
    
    22 22
     import GHC.Driver.Config.Diagnostic (initDiagOpts, initPrintConfig)
    
    23 23
     import GHC.Driver.DynFlags (DynFlags, HasDynFlags (getDynFlags))
    
    ... ... @@ -73,15 +73,12 @@ initSourceErrorContext dflags =
    73 73
       in SEC diag_opts print_config
    
    74 74
     
    
    75 75
     instance Show SourceError where
    
    76
    -  -- We implement 'Show' because it's required by the 'Exception' instance, but diagnostics
    
    77
    -  -- shouldn't be shown via the 'Show' typeclass, but rather rendered using the ppr functions.
    
    76
    +  -- We implement 'Show' because it's required by the 'Exception' instance, but
    
    77
    +  -- diagnostics must not be shown via 'Show', but instead reported via
    
    78
    +  -- `GHC.Driver.Errors.printMessages`.
    
    79
    +  --
    
    78 80
       -- This also explains why there is no 'Show' instance for a 'MsgEnvelope'.
    
    79
    -  show (SourceError (SEC diag_opts _) msgs) =
    
    80
    -      renderWithContext (diag_ppr_ctx diag_opts)
    
    81
    -    . vcat
    
    82
    -    . pprMsgEnvelopeBagWithLocDefault
    
    83
    -    . getMessages
    
    84
    -    $ msgs
    
    81
    +  show (SourceError _ msgs) = internalDebugShowMessages msgs
    
    85 82
     
    
    86 83
     instance Exception SourceError
    
    87 84
     
    

  • compiler/GHC/Utils/Error.hs
    1 1
     {-# LANGUAGE ViewPatterns    #-}
    
    2 2
     
    
    3
    +{-# OPTIONS_GHC -Wno-x-InternalMCDiagnostic #-}
    
    4
    +
    
    3 5
     {-
    
    4 6
     (c) The AQUA Project, Glasgow University, 1994-1998
    
    5 7
     
    
    ... ... @@ -22,10 +24,11 @@ module GHC.Utils.Error (
    22 24
             errorsFound, isEmptyMessages,
    
    23 25
     
    
    24 26
             -- ** Formatting
    
    25
    -        pprMessageBag, pprMsgEnvelopeBagWithLoc, pprMsgEnvelopeBagWithLocDefault,
    
    26
    -        pprMessages,
    
    27
    -        pprLocMsgEnvelope, pprLocMsgEnvelopeDefault,
    
    28
    -        formatBulleted,
    
    27
    +        pprMessageBag, formatBulleted,
    
    28
    +        deferredTypeErrorMessage,
    
    29
    +        panicMessage, internalDebugShowMessages, internalDebugPprMsgEnvelope,
    
    30
    +
    
    31
    +        internalPprMessages, -- FIXME: remove this export
    
    29 32
     
    
    30 33
             -- ** Construction
    
    31 34
             DiagOpts (..), emptyDiagOpts, diag_wopt, diag_fatal_wopt,
    
    ... ... @@ -265,29 +268,40 @@ formatBulleted (unDecorated -> docs)
    265 268
         msgs ctx = filter (not . Outputable.isEmpty ctx) docs
    
    266 269
         starred = (bullet<+>)
    
    267 270
     
    
    268
    -pprMessages :: Diagnostic e => DiagnosticOpts e -> Messages e -> SDoc
    
    269
    -pprMessages e = vcat . pprMsgEnvelopeBagWithLoc e . getMessages
    
    270
    -
    
    271
    -pprMsgEnvelopeBagWithLoc :: Diagnostic e => DiagnosticOpts e -> Bag (MsgEnvelope e) -> [SDoc]
    
    272
    -pprMsgEnvelopeBagWithLoc e bag = [ pprLocMsgEnvelope e item | item <- sortMsgBag Nothing bag ]
    
    273
    -
    
    274
    --- | Print the messages with the suitable default configuration, usually not what you want but sometimes you don't really
    
    275
    --- care about what the configuration is (for example, if the message is in a panic).
    
    276
    -pprMsgEnvelopeBagWithLocDefault :: forall e . Diagnostic e => Bag (MsgEnvelope e) -> [SDoc]
    
    277
    -pprMsgEnvelopeBagWithLocDefault bag = [ pprLocMsgEnvelopeDefault item | item <- sortMsgBag Nothing bag ]
    
    278
    -
    
    279
    -pprLocMsgEnvelopeDefault :: forall e . Diagnostic e => MsgEnvelope e -> SDoc
    
    280
    -pprLocMsgEnvelopeDefault = pprLocMsgEnvelope (defaultDiagnosticOpts @e)
    
    281
    -
    
    282
    -pprLocMsgEnvelope :: Diagnostic e => DiagnosticOpts e -> MsgEnvelope e -> SDoc
    
    283
    -pprLocMsgEnvelope opts (MsgEnvelope { errMsgSpan       = s
    
    271
    +deferredTypeErrorMessage :: Diagnostic e => DiagnosticOpts e -> MsgEnvelope e -> SDoc
    
    272
    +deferredTypeErrorMessage opts msg = internalPprMessage opts msg $$ text "(deferred type error)"
    
    273
    +
    
    274
    +panicMessage :: Diagnostic e => String -> Bag (MsgEnvelope e) -> a
    
    275
    +panicMessage name msgs = pprPanic name (vcat $ internalPprMessages msgs)
    
    276
    +
    
    277
    +{-# WARNING in "x-internalDebugShowMessages" internalDebugShowMessages
    
    278
    +    "Don't use this function for reporting diagnostics!  Use `GHC.Driver.Errors.printMessages` instead." #-}
    
    279
    +internalDebugShowMessages :: Diagnostic e => Messages e -> String
    
    280
    +internalDebugShowMessages =
    
    281
    +    renderWithContext defaultSDocContext
    
    282
    +  . vcat
    
    283
    +  . internalPprMessages
    
    284
    +  . getMessages
    
    285
    +
    
    286
    +{-# WARNING in "x-internalDebugPprMsgEnvelope" internalDebugPprMsgEnvelope
    
    287
    +    "Don't use this function for reporting diagnostics!  Use `GHC.Driver.Errors.printMessage` instead." #-}
    
    288
    +internalDebugPprMsgEnvelope :: forall e. Diagnostic e => MsgEnvelope e -> SDoc
    
    289
    +internalDebugPprMsgEnvelope = internalPprMessage (defaultDiagnosticOpts @e)
    
    290
    +
    
    291
    +{-# WARNING in "x-internalPprMessages" internalPprMessages
    
    292
    +    "Don't use this function for new code! It sidesteps the structured error machinery. Use `GHC.Driver.Errors.printMessages` instead." #-}
    
    293
    +internalPprMessages :: forall e . Diagnostic e => Bag (MsgEnvelope e) -> [SDoc]
    
    294
    +internalPprMessages = map (internalPprMessage (defaultDiagnosticOpts @e)) . sortMsgBag Nothing
    
    295
    +
    
    296
    +internalPprMessage :: Diagnostic e => DiagnosticOpts e -> MsgEnvelope e -> SDoc
    
    297
    +internalPprMessage opts (MsgEnvelope { errMsgSpan        = s
    
    284 298
                                         , errMsgDiagnostic = e
    
    285 299
                                         , errMsgSeverity   = sev
    
    286 300
                                         , errMsgContext    = name_ppr_ctx
    
    287 301
                                         , errMsgReason     = reason })
    
    288 302
       = withErrStyle name_ppr_ctx $
    
    289 303
           mkLocMessage
    
    290
    -        (MCDiagnostic sev reason (diagnosticCode e))
    
    304
    +        (InternalMCDiagnostic sev reason (diagnosticCode e))
    
    291 305
             s
    
    292 306
             (formatBulleted $ diagnosticMessage opts e)
    
    293 307
     
    

  • ghc/GHCi/UI/Exception.hs
    1 1
     {-# LANGUAGE OverloadedStrings #-}
    
    2 2
     {-# LANGUAGE TypeFamilyDependencies #-}
    
    3 3
     {-# LANGUAGE UndecidableInstances #-}
    
    4
    +{-# OPTIONS_GHC -Wno-x-internalDebugShowMessages #-}
    
    4 5
     module GHCi.UI.Exception
    
    5 6
       ( GhciCommandError(..)
    
    6 7
       , throwGhciCommandError
    
    ... ... @@ -51,15 +52,12 @@ newtype GhciCommandError = GhciCommandError (Messages GhciMessage)
    51 52
     instance Exception GhciCommandError
    
    52 53
     
    
    53 54
     instance Show GhciCommandError where
    
    54
    -  -- We implement 'Show' because it's required by the 'Exception' instance, but diagnostics
    
    55
    -  -- shouldn't be shown via the 'Show' typeclass, but rather rendered using the ppr functions.
    
    55
    +  -- We implement 'Show' because it's required by the 'Exception' instance, but
    
    56
    +  -- diagnostics must not be shown via 'Show', but instead reported via
    
    57
    +  -- `GHC.Driver.Errors.printMessages`.
    
    58
    +  --
    
    56 59
       -- This also explains why there is no 'Show' instance for a 'MsgEnvelope'.
    
    57
    -  show (GhciCommandError msgs) =
    
    58
    -      renderWithContext defaultSDocContext
    
    59
    -    . vcat
    
    60
    -    . pprMsgEnvelopeBagWithLocDefault
    
    61
    -    . getMessages
    
    62
    -    $ msgs
    
    60
    +  show (GhciCommandError msgs) = internalDebugShowMessages msgs
    
    63 61
     
    
    64 62
     -- | Perform the given action and call the exception handler if the action
    
    65 63
     -- throws a 'GhciCommandError'.  See 'GhciCommandError' for more information.
    

  • utils/check-exact/Main.hs
    ... ... @@ -3,6 +3,7 @@
    3 3
     {-# LANGUAGE StandaloneDeriving #-}
    
    4 4
     {-# LANGUAGE DeriveDataTypeable #-}
    
    5 5
     {-# LANGUAGE BangPatterns #-}
    
    6
    +{-# OPTIONS_GHC -Wno-x-internalDebugShowMessages #-}
    
    6 7
     {-# OPTIONS_GHC -Wno-incomplete-uni-patterns #-}
    
    7 8
     {-# OPTIONS_GHC -Wno-incomplete-patterns #-}
    
    8 9
     {-# OPTIONS_GHC -Wno-orphans #-}
    
    ... ... @@ -11,14 +12,11 @@
    11 12
     import Data.Data
    
    12 13
     import Data.List (intercalate)
    
    13 14
     import GHC hiding (moduleName)
    
    14
    -import GHC.Driver.Errors.Types
    
    15 15
     import GHC.Driver.Ppr
    
    16 16
     import GHC.Hs.Dump
    
    17
    -import GHC.Types.Error
    
    18 17
     import GHC.Types.Name.Occurrence
    
    19 18
     import GHC.Types.Name.Reader
    
    20 19
     import GHC.Utils.Error
    
    21
    -import GHC.Utils.Outputable
    
    22 20
     import System.Environment( getArgs )
    
    23 21
     import System.Exit
    
    24 22
     import System.FilePath
    
    ... ... @@ -369,19 +367,11 @@ parseOneFile :: FilePath -> FilePath -> IO (ParsedSource, [Located Token])
    369 367
     parseOneFile libdir fileName = do
    
    370 368
       res <- parseModuleEpAnnsWithCpp libdir defaultCppOptions fileName
    
    371 369
       case res of
    
    372
    -    Left m -> error (showErrorMessages m)
    
    370
    +    Left m -> error (internalDebugShowMessages m)
    
    373 371
         Right (injectedComments, _dflags, pmod) -> do
    
    374 372
           let !pmodWithComments = insertCppComments pmod injectedComments
    
    375 373
           return (pmodWithComments, [])
    
    376 374
     
    
    377
    -showErrorMessages :: Messages GhcMessage -> String
    
    378
    -showErrorMessages msgs =
    
    379
    -  renderWithContext defaultSDocContext
    
    380
    -    $ vcat
    
    381
    -    $ pprMsgEnvelopeBagWithLocDefault
    
    382
    -    $ getMessages
    
    383
    -    $ msgs
    
    384
    -
    
    385 375
     -- ---------------------------------------------------------------------
    
    386 376
     
    
    387 377
     exactprintWithChange :: FilePath -> Changer -> ParsedSource -> IO (String, ParsedSource)
    

  • utils/check-exact/Preprocess.hs
    1 1
     {-# LANGUAGE RecordWildCards #-}
    
    2 2
     {-# LANGUAGE OverloadedStrings #-}
    
    3 3
     {-# LANGUAGE TypeApplications #-}
    
    4
    +{-# OPTIONS_GHC -Wno-x-internalDebugShowMessages #-}
    
    4 5
     -- | This module provides support for CPP, interpreter directives and line
    
    5 6
     -- pragmas.
    
    6 7
     module Preprocess
    
    ... ... @@ -26,13 +27,11 @@ import qualified GHC.Driver.Phases as GHC
    26 27
     import qualified GHC.Driver.Pipeline   as GHC
    
    27 28
     import qualified GHC.Parser.Lexer      as GHC
    
    28 29
     import qualified GHC.Settings          as GHC
    
    29
    -import qualified GHC.Types.Error       as GHC
    
    30 30
     import qualified GHC.Types.SourceError as GHC
    
    31 31
     import qualified GHC.Types.SourceFile  as GHC
    
    32 32
     import qualified GHC.Types.SrcLoc      as GHC
    
    33 33
     import qualified GHC.Utils.Error       as GHC
    
    34 34
     import qualified GHC.Utils.Fingerprint as GHC
    
    35
    -import qualified GHC.Utils.Outputable  as GHC
    
    36 35
     import GHC.Types.SrcLoc (mkSrcSpan, mkSrcLoc)
    
    37 36
     import GHC.Data.FastString (mkFastString)
    
    38 37
     
    
    ... ... @@ -216,20 +215,12 @@ getPreprocessedSrcDirectPrim cppOptions src_fn = do
    216 215
           new_env = hsc_env { GHC.hsc_dflags = injectCppOptions cppOptions dfs }
    
    217 216
       r <- GHC.liftIO $ GHC.preprocess new_env src_fn Nothing (Just (GHC.Cpp GHC.HsSrcFile))
    
    218 217
       case r of
    
    219
    -    Left err -> error $ showErrorMessages err
    
    218
    +    Left err -> error $ GHC.internalDebugShowMessages err
    
    220 219
         Right (dflags', hspp_fn) -> do
    
    221 220
           buf <- GHC.liftIO $ GHC.hGetStringBuffer hspp_fn
    
    222 221
           txt <- GHC.liftIO $ readFileGhc hspp_fn
    
    223 222
           return (txt, buf, dflags')
    
    224 223
     
    
    225
    -showErrorMessages :: GHC.Messages GHC.DriverMessage -> String
    
    226
    -showErrorMessages msgs =
    
    227
    -  GHC.renderWithContext GHC.defaultSDocContext
    
    228
    -    $ GHC.vcat
    
    229
    -    $ GHC.pprMsgEnvelopeBagWithLocDefault
    
    230
    -    $ GHC.getMessages
    
    231
    -    $ msgs
    
    232
    -
    
    233 224
     injectCppOptions :: CppOptions -> GHC.DynFlags -> GHC.DynFlags
    
    234 225
     injectCppOptions CppOptions{..} dflags = folded_opt
    
    235 226
       where
    

  • utils/haddock/haddock-api/src/Haddock/Backends/Hyperlinker.hs
    ... ... @@ -97,7 +97,7 @@ ppHyperlinkedModuleSource verbosity srcdir pretty srcs iface = do
    97 97
           mast
    
    98 98
             | M.size asts == 1 = snd <$> M.lookupMin asts
    
    99 99
             | otherwise = M.lookup (HiePath (mkFastString file)) asts
    
    100
    -      tokens' = parse parserOpts sDocContext file rawSrc
    
    100
    +      tokens' = parse parserOpts file rawSrc
    
    101 101
           ast = fromMaybe (emptyHieAst fileFs) mast
    
    102 102
           fullAst = recoverFullIfaceTypes sDocContext types ast
    
    103 103
     
    

  • utils/haddock/haddock-api/src/Haddock/Backends/Hyperlinker/Parser.hs
    ... ... @@ -9,7 +9,6 @@ import Control.Monad.Trans.Class
    9 9
     import Control.Monad.Trans.Maybe
    
    10 10
     import qualified Data.ByteString as BS
    
    11 11
     import Data.List (isPrefixOf, isSuffixOf)
    
    12
    -import GHC.Data.Bag (bagToList)
    
    13 12
     import GHC.Data.FastString (mkFastString)
    
    14 13
     import GHC.Data.StringBuffer (StringBuffer, atEnd)
    
    15 14
     import GHC.Parser.Errors.Ppr ()
    
    ... ... @@ -26,10 +25,7 @@ import GHC.Parser.Lexer as Lexer
    26 25
     import qualified GHC.Types.Error as E
    
    27 26
     import GHC.Types.SourceText
    
    28 27
     import GHC.Types.SrcLoc
    
    29
    -import GHC.Utils.Error (pprLocMsgEnvelopeDefault)
    
    30
    -import GHC.Utils.Outputable (SDocContext, text, ($$))
    
    31
    -import qualified GHC.Utils.Outputable as Outputable
    
    32
    -import GHC.Utils.Panic (panic)
    
    28
    +import GHC.Utils.Error (panicMessage)
    
    33 29
     
    
    34 30
     import Haddock.Backends.Hyperlinker.Types as T
    
    35 31
     import Haddock.GhcUtils
    
    ... ... @@ -40,19 +36,14 @@ import Haddock.GhcUtils
    40 36
     -- whitespace, and CPP).
    
    41 37
     parse
    
    42 38
       :: ParserOpts
    
    43
    -  -> SDocContext
    
    44 39
       -> FilePath
    
    45 40
       -- ^ Path to the source of this module
    
    46 41
       -> BS.ByteString
    
    47 42
       -- ^ Raw UTF-8 encoded source of this module
    
    48 43
       -> [T.Token]
    
    49
    -parse parserOpts sDocContext fpath bs = case unP (go False []) initState of
    
    44
    +parse parserOpts fpath bs = case unP (go False []) initState of
    
    50 45
       POk _ toks -> reverse toks
    
    51
    -  PFailed pst ->
    
    52
    -    let err : _ = bagToList (E.getMessages $ getPsErrorMessages pst)
    
    53
    -     in panic $
    
    54
    -          Outputable.renderWithContext sDocContext $
    
    55
    -            text "Hyperlinker parse error:" $$ pprLocMsgEnvelopeDefault err
    
    46
    +  PFailed pst -> panicMessage "Hyperlinker parse error:" (E.getMessages $ getPsErrorMessages pst)
    
    56 47
       where
    
    57 48
         initState = initParserState parserOpts buf start
    
    58 49
         buf = stringBufferFromByteString bs