Errors thrown in one-shot mode do not take into account DynFlags
If you look at all the code that is responsible for emitting errors in one-shot mode, it uses the following machinery:
```hs
newtype SourceError = SourceError (Messages GhcMessage)
mkSrcErr :: Messages GhcMessage -> SourceError
mkSrcErr = SourceError
instance Show SourceError where
-- We implement 'Show' because it's required by the 'Exception' instance, but diagnostics
-- shouldn't be shown via the 'Show' typeclass, but rather rendered using the ppr functions.
-- This also explains why there is no 'Show' instance for a 'MsgEnvelope'.
show (SourceError msgs) =
renderWithContext defaultSDocContext -- !!!!!!!!!!!
. vcat
. pprMsgEnvelopeBagWithLocDefault
. getMessages
$ msgs
throwErrors :: MonadIO io => Messages GhcMessage -> io a
throwErrors = liftIO . throwIO . mkSrcErr
```
That is, we display all `SDoc`s with the `defaultSDocContext`, completely ignoring any options the user has enabled in the file. This is because `throwIO` goes through the `Exception` typeclass which will use the above `Show` instance. Instead, we should thread through the appropriate `SDocContext` constructed from the module's `DynFlags`/`DiagOpts`.
Here's a random example I came up with to demonstrate the problem:
```hs
{-# OPTIONS_GHC -fprint-explicit-kinds #-}
module T26387 where
import Data.Proxy
f :: _
f = Proxy @Int
```
With `-fprint-explicit-kinds`, we expect GHC to give us the explicit kind application of `Proxy`:
```
error: [GHC-88464]
* Found type wildcard `_' standing for `Proxy @{*} Int'
To use the inferred type, enable PartialTypeSignatures
* In the type signature: f :: _
```
Note the `Proxy @{*} Int`: the `@{*}` part is included because the user has set `-fprint-explicit-kinds`.
However, if you compile this module in one-shot mode with `ghc -c T26387.hs`, we fall-back to `sdocShowExplicitKinds = False` and we get:
```
error: [GHC-88464]
* Found type wildcard `_' standing for `Proxy Int'
To use the inferred type, enable PartialTypeSignatures
* In the type signature: f :: _
```
This is a random example but it demonstrates that we completely ignore the per-module `DynFlags` when it comes to setting the appropriate `SDocContext` for error messages.
issue