Commit 2b341fc4 authored by pcapriotti's avatar pcapriotti
Browse files

Remove hPrintDump and make rule dump output more consistent (#7060)

The only difference between SevDump and SevOutput in defaultLogAction is
an extra blank line, so we don't need a separate hPrintDump function.

Also make -ddump-to-file consistent with the stdout version, by avoiding
to add the extra empty line when dumping rules.
parent f8a00d0e
......@@ -1017,7 +1017,7 @@ defaultLogAction :: LogAction
defaultLogAction dflags severity srcSpan style msg
= case severity of
SevOutput -> printSDoc msg style
SevDump -> hPrintDump dflags stdout msg
SevDump -> printSDoc (msg $$ blankLine) style
SevInfo -> printErrs msg style
SevFatal -> printErrs msg style
_ -> do hPutChar stderr '\n'
......
......@@ -230,6 +230,9 @@ mkDumpDoc hdr doc
-- | Write out a dump.
-- If --dump-to-file is set then this goes to a file.
-- otherwise emit to stdout.
--
-- When hdr is empty, we print in a more compact format (no separators and
-- blank lines)
dumpSDoc :: DynFlags -> DynFlag -> String -> SDoc -> IO ()
dumpSDoc dflags dflag hdr doc
= do let mFile = chooseDumpFile dflags dflag
......@@ -247,7 +250,10 @@ dumpSDoc dflags dflag hdr doc
writeIORef gdref (Set.insert fileName gd)
createDirectoryIfMissing True (takeDirectory fileName)
handle <- openFile fileName mode
hPrintDump dflags handle doc
let doc'
| null hdr = doc
| otherwise = doc $$ blankLine
defaultLogActionHPrintDoc dflags handle doc' defaultDumpStyle
hClose handle
-- write the dump to stdout
......
......@@ -38,7 +38,6 @@ module Outputable (
colBinder, bold, keyword,
-- * Converting 'SDoc' into strings and outputing it
hPrintDump,
printForC, printForAsm, printForUser, printForUserPartWay,
pprCode, mkCodeStyle,
showSDoc, showSDocOneLine,
......@@ -91,7 +90,7 @@ import qualified Data.IntMap as IM
import Data.Set (Set)
import qualified Data.Set as Set
import Data.Word
import System.IO ( Handle, hFlush )
import System.IO ( Handle )
import System.FilePath
......@@ -330,13 +329,6 @@ ifPprDebug d = SDoc $ \ctx ->
\end{code}
\begin{code}
hPrintDump :: DynFlags -> Handle -> SDoc -> IO ()
hPrintDump dflags h doc = do
Pretty.printDoc PageMode (pprCols dflags) h
(runSDoc better_doc (initSDocContext dflags defaultDumpStyle))
hFlush h
where
better_doc = doc $$ blankLine
printForUser :: DynFlags -> Handle -> PrintUnqualified -> SDoc -> IO ()
printForUser dflags handle unqual doc
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment