summaryrefslogtreecommitdiff
path: root/compiler/GHC/Driver/Errors
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/GHC/Driver/Errors')
-rw-r--r--compiler/GHC/Driver/Errors/Ppr.hs9
-rw-r--r--compiler/GHC/Driver/Errors/Types.hs18
2 files changed, 15 insertions, 12 deletions
diff --git a/compiler/GHC/Driver/Errors/Ppr.hs b/compiler/GHC/Driver/Errors/Ppr.hs
index 9e3822e460..a89e7992b1 100644
--- a/compiler/GHC/Driver/Errors/Ppr.hs
+++ b/compiler/GHC/Driver/Errors/Ppr.hs
@@ -16,7 +16,6 @@ import GHC.Driver.Flags
import GHC.Driver.Session
import GHC.HsToCore.Errors.Ppr ()
import GHC.Parser.Errors.Ppr ()
-import GHC.Tc.Errors.Ppr ()
import GHC.Types.Error
import GHC.Types.Error.Codes ( constructorCode )
import GHC.Unit.Types
@@ -30,6 +29,9 @@ import Data.Version
import Language.Haskell.Syntax.Decls (RuleDecl(..))
import GHC.Tc.Errors.Types (TcRnMessage)
import GHC.HsToCore.Errors.Types (DsMessage)
+import GHC.Iface.Errors.Types
+import GHC.Tc.Errors.Ppr ()
+import GHC.Iface.Errors.Ppr ()
--
-- Suggestions
@@ -86,7 +88,7 @@ instance Diagnostic GhcMessage where
instance Diagnostic DriverMessage where
type DiagnosticOpts DriverMessage = DriverMessageOpts
- defaultDiagnosticOpts = DriverMessageOpts (defaultDiagnosticOpts @PsMessage)
+ defaultDiagnosticOpts = DriverMessageOpts (defaultDiagnosticOpts @PsMessage) (defaultDiagnosticOpts @IfaceMessage)
diagnosticMessage opts = \case
DriverUnknownMessage (UnknownDiagnostic @e m)
-> diagnosticMessage (defaultDiagnosticOpts @e) m
@@ -218,6 +220,7 @@ instance Diagnostic DriverMessage where
-> mkSimpleDecorated $ vcat ([text "Home units are not closed."
, text "It is necessary to also load the following units:" ]
++ map (\uid -> text "-" <+> ppr uid) needed_unit_ids)
+ DriverInterfaceError reason -> diagnosticMessage (ifaceDiagnosticOpts opts) reason
diagnosticReason = \case
DriverUnknownMessage m
@@ -272,6 +275,7 @@ instance Diagnostic DriverMessage where
-> ErrorWithoutFlag
DriverHomePackagesNotClosed {}
-> ErrorWithoutFlag
+ DriverInterfaceError reason -> diagnosticReason reason
diagnosticHints = \case
DriverUnknownMessage m
@@ -328,5 +332,6 @@ instance Diagnostic DriverMessage where
-> noHints
DriverHomePackagesNotClosed {}
-> noHints
+ DriverInterfaceError reason -> diagnosticHints reason
diagnosticCode = constructorCode
diff --git a/compiler/GHC/Driver/Errors/Types.hs b/compiler/GHC/Driver/Errors/Types.hs
index c2ec9cbb0c..cbf0622025 100644
--- a/compiler/GHC/Driver/Errors/Types.hs
+++ b/compiler/GHC/Driver/Errors/Types.hs
@@ -8,7 +8,6 @@ module GHC.Driver.Errors.Types (
, DriverMessage(..)
, DriverMessageOpts(..)
, DriverMessages, PsMessage(PsHeaderMessage)
- , BuildingCabalPackage(..)
, WarningMessages
, ErrorMessages
, WarnMsg
@@ -32,7 +31,6 @@ import GHC.Unit.Module
import GHC.Unit.State
import GHC.Parser.Errors.Types ( PsMessage(PsHeaderMessage) )
-import GHC.Tc.Errors.Types ( TcRnMessage )
import GHC.HsToCore.Errors.Types ( DsMessage )
import GHC.Hs.Extension (GhcTc)
@@ -40,6 +38,9 @@ import Language.Haskell.Syntax.Decls (RuleDecl)
import GHC.Generics ( Generic )
+import GHC.Tc.Errors.Types
+import GHC.Iface.Errors.Types
+
-- | A collection of warning messages.
-- /INVARIANT/: Each 'GhcMessage' in the collection should have 'SevWarning' severity.
type WarningMessages = Messages GhcMessage
@@ -369,21 +370,18 @@ data DriverMessage where
DriverHomePackagesNotClosed :: ![UnitId] -> DriverMessage
+ DriverInterfaceError :: !IfaceMessage -> DriverMessage
+
deriving instance Generic DriverMessage
data DriverMessageOpts =
- DriverMessageOpts { psDiagnosticOpts :: DiagnosticOpts PsMessage }
+ DriverMessageOpts { psDiagnosticOpts :: DiagnosticOpts PsMessage
+ , ifaceDiagnosticOpts :: DiagnosticOpts IfaceMessage }
--- | Pass to a 'DriverMessage' the information whether or not the
--- '-fbuilding-cabal-package' flag is set.
-data BuildingCabalPackage
- = YesBuildingCabalPackage
- | NoBuildingCabalPackage
- deriving Eq
-- | Checks if we are building a cabal package by consulting the 'DynFlags'.
checkBuildingCabalPackage :: DynFlags -> BuildingCabalPackage
checkBuildingCabalPackage dflags =
if gopt Opt_BuildingCabalPackage dflags
then YesBuildingCabalPackage
- else NoBuildingCabalPackage
+ else NoBuildingCabalPackage \ No newline at end of file