diff options
author | Sylvain Henry <sylvain@haskus.fr> | 2020-09-24 16:10:16 +0200 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2020-09-30 02:49:41 -0400 |
commit | df3f58807580bc2762086e063e3823b05de6fd64 (patch) | |
tree | 1c59f841d9eb351c20b1abe76e7db82634cc8056 /compiler/GHC/Utils/Panic.hs | |
parent | 6527fc57b8e099703f5bdb5ec7f1dfd421651972 (diff) | |
download | haskell-df3f58807580bc2762086e063e3823b05de6fd64.tar.gz |
Remove unsafeGlobalDynFlags (#17957, #14597)
There are still global variables but only 3 booleans instead of a single
DynFlags.
Diffstat (limited to 'compiler/GHC/Utils/Panic.hs')
-rw-r--r-- | compiler/GHC/Utils/Panic.hs | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/compiler/GHC/Utils/Panic.hs b/compiler/GHC/Utils/Panic.hs index 9f7d81abab..eba104e5b8 100644 --- a/compiler/GHC/Utils/Panic.hs +++ b/compiler/GHC/Utils/Panic.hs @@ -47,8 +47,6 @@ import GHC.Prelude import GHC.Stack import GHC.Utils.Outputable -import {-# SOURCE #-} GHC.Driver.Session (DynFlags, unsafeGlobalDynFlags) -import {-# SOURCE #-} GHC.Driver.Ppr (showSDoc) import GHC.Utils.Panic.Plain import GHC.Utils.Exception as Exception @@ -146,16 +144,14 @@ safeShowException e = do -- | Append a description of the given exception to this string. -- --- Note that this uses 'GHC.Driver.Session.unsafeGlobalDynFlags', which may have some --- uninitialized fields if invoked before 'GHC.initGhcMonad' has been called. --- If the error message to be printed includes a pretty-printer document --- which forces one of these fields this call may bottom. +-- Note that this uses 'defaultSDocContext', which doesn't use the options +-- set by the user via DynFlags. showGhcExceptionUnsafe :: GhcException -> ShowS -showGhcExceptionUnsafe = showGhcException unsafeGlobalDynFlags +showGhcExceptionUnsafe = showGhcException defaultSDocContext -- | Append a description of the given exception to this string. -showGhcException :: DynFlags -> GhcException -> ShowS -showGhcException dflags = showPlainGhcException . \case +showGhcException :: SDocContext -> GhcException -> ShowS +showGhcException ctx = showPlainGhcException . \case Signal n -> PlainSignal n UsageError str -> PlainUsageError str CmdLineError str -> PlainCmdLineError str @@ -165,11 +161,11 @@ showGhcException dflags = showPlainGhcException . \case ProgramError str -> PlainProgramError str PprPanic str sdoc -> PlainPanic $ - concat [str, "\n\n", showSDoc dflags sdoc] + concat [str, "\n\n", renderWithContext ctx sdoc] PprSorry str sdoc -> PlainProgramError $ - concat [str, "\n\n", showSDoc dflags sdoc] + concat [str, "\n\n", renderWithContext ctx sdoc] PprProgramError str sdoc -> PlainProgramError $ - concat [str, "\n\n", showSDoc dflags sdoc] + concat [str, "\n\n", renderWithContext ctx sdoc] throwGhcException :: GhcException -> a throwGhcException = Exception.throw |