diff options
author | Matthew Pickering <matthewtpickering@gmail.com> | 2023-03-14 17:34:30 +0000 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2023-04-18 10:31:02 -0400 |
commit | 5e1d33d7a428965c7024290cebb3d77b84230169 (patch) | |
tree | 8b9a35d5c0905ad7a67cd588b7fd991cb783b1a3 /ghc | |
parent | 1036481824fed7f8d5c9f70816b3dadd22098e42 (diff) | |
download | haskell-5e1d33d7a428965c7024290cebb3d77b84230169.tar.gz |
Convert interface file loading errors into proper diagnostics
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 'ghc')
-rw-r--r-- | ghc/Main.hs | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/ghc/Main.hs b/ghc/Main.hs index ae862a7014..ef3de102c0 100644 --- a/ghc/Main.hs +++ b/ghc/Main.hs @@ -79,12 +79,13 @@ import GHC.Iface.Load import GHC.Iface.Recomp.Binary ( fingerprintBinMem ) import GHC.Tc.Utils.Monad ( initIfaceCheck ) -import System.FilePath +import GHC.Iface.Errors.Ppr -- Standard Haskell libraries import System.IO import System.Environment import System.Exit +import System.FilePath import Control.Monad import Control.Monad.Trans.Class import Control.Monad.Trans.Except (throwE, runExceptT) @@ -1100,8 +1101,11 @@ abiHash strs = do r <- findImportedModule hsc_env modname NoPkgQual case r of Found _ m -> return m - _error -> throwGhcException $ CmdLineError $ showSDoc dflags $ - cannotFindModule hsc_env modname r + _error -> + let opts = initIfaceMessageOpts dflags + err_txt = missingInterfaceErrorDiagnostic opts + $ cannotFindModule hsc_env modname r + in throwGhcException . CmdLineError $ showSDoc dflags err_txt mods <- mapM find_it strs |