summaryrefslogtreecommitdiff
path: root/compiler/GHC/Tc/Errors
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/GHC/Tc/Errors')
-rw-r--r--compiler/GHC/Tc/Errors/Ppr.hs21
-rw-r--r--compiler/GHC/Tc/Errors/Types.hs16
2 files changed, 20 insertions, 17 deletions
diff --git a/compiler/GHC/Tc/Errors/Ppr.hs b/compiler/GHC/Tc/Errors/Ppr.hs
index 0d253cbf6b..5cc8ab5f64 100644
--- a/compiler/GHC/Tc/Errors/Ppr.hs
+++ b/compiler/GHC/Tc/Errors/Ppr.hs
@@ -76,7 +76,7 @@ import GHC.Types.Var.Set
import GHC.Types.Var.Env
import GHC.Types.Fixity (defaultFixity)
-import GHC.Unit.State (pprWithUnitState, UnitState)
+import GHC.Unit.State
import GHC.Unit.Module
import GHC.Unit.Module.Warnings ( warningTxtCategory, pprWarningTxtForMsg )
@@ -101,13 +101,16 @@ import Data.Ord ( comparing )
import Data.Bifunctor
import qualified Language.Haskell.TH as TH
import {-# SOURCE #-} GHC.Tc.Types (pprTcTyThingCategory)
+import GHC.Iface.Errors.Types
+import GHC.Iface.Errors.Ppr
data TcRnMessageOpts = TcRnMessageOpts { tcOptsShowContext :: !Bool -- ^ Whether we show the error context or not
+ , tcOptsIfaceOpts :: !IfaceMessageOpts
}
defaultTcRnMessageOpts :: TcRnMessageOpts
-defaultTcRnMessageOpts = TcRnMessageOpts { tcOptsShowContext = True }
-
+defaultTcRnMessageOpts = TcRnMessageOpts { tcOptsShowContext = True
+ , tcOptsIfaceOpts = defaultDiagnosticOpts @IfaceMessage }
instance Diagnostic TcRnMessage where
type DiagnosticOpts TcRnMessage = TcRnMessageOpts
@@ -1245,7 +1248,6 @@ instance Diagnostic TcRnMessage where
True -> text (show item)
False -> text (TH.pprint item))
TcRnReportCustomQuasiError _ msg -> mkSimpleDecorated $ text msg
- TcRnInterfaceLookupError _ sdoc -> mkSimpleDecorated sdoc
TcRnUnsatisfiedMinimalDef mindef
-> mkSimpleDecorated $
vcat [text "No explicit implementation for"
@@ -1733,6 +1735,8 @@ instance Diagnostic TcRnMessage where
ppr (frr_context frr) $$
text "cannot be assigned a fixed runtime representation," <+>
text "not even by defaulting."
+ TcRnInterfaceError reason
+ -> diagnosticMessage (tcOptsIfaceOpts opts) reason
diagnosticReason = \case
TcRnUnknownMessage m
@@ -2105,8 +2109,6 @@ instance Diagnostic TcRnMessage where
-> ErrorWithoutFlag
TcRnReportCustomQuasiError isError _
-> if isError then ErrorWithoutFlag else WarningWithoutFlag
- TcRnInterfaceLookupError{}
- -> ErrorWithoutFlag
TcRnUnsatisfiedMinimalDef{}
-> WarningWithFlag (Opt_WarnMissingMethods)
TcRnMisplacedInstSig{}
@@ -2307,6 +2309,9 @@ instance Diagnostic TcRnMessage where
-> ErrorWithoutFlag
TcRnCannotDefaultConcrete{}
-> ErrorWithoutFlag
+ TcRnInterfaceError err
+ -> interfaceErrorReason err
+
diagnosticHints = \case
TcRnUnknownMessage m
@@ -2685,8 +2690,6 @@ instance Diagnostic TcRnMessage where
-> noHints
TcRnReportCustomQuasiError{}
-> noHints
- TcRnInterfaceLookupError{}
- -> noHints
TcRnUnsatisfiedMinimalDef{}
-> noHints
TcRnMisplacedInstSig{}
@@ -2908,6 +2911,8 @@ instance Diagnostic TcRnMessage where
-> noHints
TcRnCannotDefaultConcrete{}
-> [SuggestAddTypeSignatures UnnamedBinding]
+ TcRnInterfaceError reason
+ -> interfaceErrorHints reason
diagnosticCode = constructorCode
diff --git a/compiler/GHC/Tc/Errors/Types.hs b/compiler/GHC/Tc/Errors/Types.hs
index a8d7c30846..38615d0f0d 100644
--- a/compiler/GHC/Tc/Errors/Types.hs
+++ b/compiler/GHC/Tc/Errors/Types.hs
@@ -124,6 +124,7 @@ import GHC.Tc.Types.Origin ( CtOrigin (ProvCtxtOrigin), SkolemInfoAnon (SigSkol)
import GHC.Tc.Types.Rank (Rank)
import GHC.Tc.Utils.TcType (IllegalForeignTypeReason, TcType, TcSigmaType, TcPredType)
import GHC.Types.Avail (AvailInfo)
+import GHC.Types.Basic
import GHC.Types.Error
import GHC.Types.Hint (UntickedPromotedThing(..))
import GHC.Types.ForeignCall (CLabelString)
@@ -151,7 +152,6 @@ import GHC.Core.TyCon (TyCon, Role)
import GHC.Core.Type (Kind, Type, ThetaType, PredType)
import GHC.Driver.Backend (Backend)
import GHC.Unit.State (UnitState)
-import GHC.Types.Basic
import GHC.Utils.Misc (capitalise, filterOut)
import qualified GHC.LanguageExtensions as LangExt
import GHC.Data.FastString (FastString)
@@ -166,6 +166,7 @@ import qualified Language.Haskell.TH.Syntax as TH
import GHC.Generics ( Generic )
import GHC.Types.Name.Env (NameEnv)
+import GHC.Iface.Errors.Types
{-
Note [Migrating TcM Messages]
@@ -232,6 +233,11 @@ data TcRnMessage where
-}
TcRnUnknownMessage :: UnknownDiagnostic -> TcRnMessage
+ {-| Wrap an 'IfaceMessage' to a 'TcRnMessage' for when we attempt to load interface
+ files during typechecking but encounter an error. -}
+
+ TcRnInterfaceError :: !IfaceMessage -> TcRnMessage
+
{-| TcRnMessageWithInfo is a constructor which is used when extra information is needed
to be provided in order to qualify a diagnostic and where it was originated (and why).
It carries an extra 'UnitState' which can be used to pretty-print some names
@@ -2723,14 +2729,6 @@ data TcRnMessage where
-> !String -- Error body
-> TcRnMessage
- {-| TcRnInterfaceLookupError is an error resulting from looking up a name in an interface file.
-
- Example(s):
-
- Test cases:
- -}
- TcRnInterfaceLookupError :: !Name -> !SDoc -> TcRnMessage
-
{- | TcRnUnsatisfiedMinimalDef is a warning that occurs when a class instance
is missing methods that are required by the minimal definition.