summaryrefslogtreecommitdiff
path: root/compiler/GHC/Driver/Config
diff options
context:
space:
mode:
authorMatthew Pickering <matthewtpickering@gmail.com>2023-03-14 17:34:30 +0000
committerGHC GitLab CI <ghc-ci@gitlab-haskell.org>2023-04-17 14:57:04 +0100
commitec9b7dd7b80b9637a84e60ce9425bfd223b4c379 (patch)
tree62e79864d016a6e5105e395ee19a2202d4892ce6 /compiler/GHC/Driver/Config
parent1532a8b2b222fee73959a0760ac8867be7f19ce6 (diff)
downloadhaskell-wip/interface-loading-errs.tar.gz
Convert interface file loading errors into proper diagnosticswip/interface-loading-errs
This patch converts all the errors to do with loading interface files into proper structured diagnostics. * DriverMessage: Sometimes in the driver we attempt to load an interface file so we embed the IfaceMessage into the DriverMessage. * TcRnMessage: Most the time we are loading interface files during typechecking, so we embed the IfaceMessage This patch also removes the TcRnInterfaceLookupError constructor which is superceded by the IfaceMessage, which is now structured compared to just storing an SDoc before.
Diffstat (limited to 'compiler/GHC/Driver/Config')
-rw-r--r--compiler/GHC/Driver/Config/Diagnostic.hs14
-rw-r--r--compiler/GHC/Driver/Config/Tidy.hs15
2 files changed, 16 insertions, 13 deletions
diff --git a/compiler/GHC/Driver/Config/Diagnostic.hs b/compiler/GHC/Driver/Config/Diagnostic.hs
index f4b709301b..1e8b5a1e67 100644
--- a/compiler/GHC/Driver/Config/Diagnostic.hs
+++ b/compiler/GHC/Driver/Config/Diagnostic.hs
@@ -8,11 +8,13 @@ module GHC.Driver.Config.Diagnostic
, initDsMessageOpts
, initTcMessageOpts
, initDriverMessageOpts
+ , initIfaceMessageOpts
)
where
import GHC.Driver.Flags
import GHC.Driver.Session
+import GHC.Prelude
import GHC.Utils.Outputable
import GHC.Utils.Error (DiagOpts (..))
@@ -22,6 +24,8 @@ import GHC.Tc.Errors.Types
import GHC.HsToCore.Errors.Types
import GHC.Types.Error
import GHC.Tc.Errors.Ppr
+import GHC.Iface.Errors.Types
+import GHC.Iface.Errors.Ppr
-- | Initialise the general configuration for printing diagnostic messages
-- For example, this configuration controls things like whether warnings are
@@ -50,11 +54,17 @@ initPsMessageOpts :: DynFlags -> DiagnosticOpts PsMessage
initPsMessageOpts _ = NoDiagnosticOpts
initTcMessageOpts :: DynFlags -> DiagnosticOpts TcRnMessage
-initTcMessageOpts dflags = TcRnMessageOpts { tcOptsShowContext = gopt Opt_ShowErrorContext dflags }
+initTcMessageOpts dflags =
+ TcRnMessageOpts { tcOptsShowContext = gopt Opt_ShowErrorContext dflags
+ , tcOptsIfaceOpts = initIfaceMessageOpts dflags }
initDsMessageOpts :: DynFlags -> DiagnosticOpts DsMessage
initDsMessageOpts _ = NoDiagnosticOpts
+initIfaceMessageOpts :: DynFlags -> DiagnosticOpts IfaceMessage
+initIfaceMessageOpts dflags =
+ IfaceMessageOpts { ifaceShowTriedFiles = verbosity dflags >= 3 }
+
initDriverMessageOpts :: DynFlags -> DiagnosticOpts DriverMessage
-initDriverMessageOpts dflags = DriverMessageOpts (initPsMessageOpts dflags)
+initDriverMessageOpts dflags = DriverMessageOpts (initPsMessageOpts dflags) (initIfaceMessageOpts dflags)
diff --git a/compiler/GHC/Driver/Config/Tidy.hs b/compiler/GHC/Driver/Config/Tidy.hs
index 89bdf31b2c..a02321ab78 100644
--- a/compiler/GHC/Driver/Config/Tidy.hs
+++ b/compiler/GHC/Driver/Config/Tidy.hs
@@ -17,11 +17,8 @@ import GHC.Driver.Env
import GHC.Driver.Backend
import GHC.Core.Make (getMkStringIds)
-import GHC.Data.Maybe
-import GHC.Utils.Panic
-import GHC.Utils.Outputable
import GHC.Builtin.Names
-import GHC.Tc.Utils.Env (lookupGlobal_maybe)
+import GHC.Tc.Utils.Env (lookupGlobal)
import GHC.Types.TyThing
import GHC.Platform.Ways
@@ -49,13 +46,9 @@ initStaticPtrOpts :: HscEnv -> IO StaticPtrOpts
initStaticPtrOpts hsc_env = do
let dflags = hsc_dflags hsc_env
- let lookupM n = lookupGlobal_maybe hsc_env n >>= \case
- Succeeded r -> pure r
- Failed err -> pprPanic "initStaticPtrOpts: couldn't find" (ppr (err,n))
-
- mk_string <- getMkStringIds (fmap tyThingId . lookupM)
- static_ptr_info_datacon <- tyThingDataCon <$> lookupM staticPtrInfoDataConName
- static_ptr_datacon <- tyThingDataCon <$> lookupM staticPtrDataConName
+ mk_string <- getMkStringIds (fmap tyThingId . lookupGlobal hsc_env )
+ static_ptr_info_datacon <- tyThingDataCon <$> lookupGlobal hsc_env staticPtrInfoDataConName
+ static_ptr_datacon <- tyThingDataCon <$> lookupGlobal hsc_env staticPtrDataConName
pure $ StaticPtrOpts
{ opt_platform = targetPlatform dflags