summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKrzysztof Gogolewski <krzysztof.gogolewski@tweag.io>2023-05-16 21:53:43 +0200
committerKrzysztof Gogolewski <krzysztof.gogolewski@tweag.io>2023-05-16 22:05:45 +0200
commit3aee23cb2969a9626b6401664e2acc82086c960b (patch)
tree81185671028a4b39e61143ed213c538077f78a17
parent67330303714ab64751e538f318932a70c36392b6 (diff)
downloadhaskell-wip/lint-stderr.tar.gz
Output Lint errors to stderr instead of stdoutwip/lint-stderr
This is a continuation of 7b095b99, which fixed warnings but not errors. Refs #13342
-rw-r--r--compiler/GHC/Core/Lint.hs10
-rw-r--r--compiler/GHC/Driver/CodeOutput.hs2
-rw-r--r--compiler/GHC/Stg/Lint.hs2
3 files changed, 8 insertions, 6 deletions
diff --git a/compiler/GHC/Core/Lint.hs b/compiler/GHC/Core/Lint.hs
index 7bb1eb43aa..566b0985e2 100644
--- a/compiler/GHC/Core/Lint.hs
+++ b/compiler/GHC/Core/Lint.hs
@@ -302,6 +302,10 @@ path does not result in allocation in the hot path. This can be surprisingly
impactful. Changing `lint_app` reduced allocations for one test program I was
looking at by ~4%.
+Note [MCInfo for Lint]
+~~~~~~~~~~~~~~~~~~~~~~
+When printing a Lint message, use the MCInfo severity so that the
+message is printed on stderr rather than stdout (#13342).
************************************************************************
* *
@@ -425,7 +429,7 @@ displayLintResults :: Logger
-> IO ()
displayLintResults logger display_warnings pp_what pp_pgm (warns, errs)
| not (isEmptyBag errs)
- = do { logMsg logger Err.MCDump noSrcSpan
+ = do { logMsg logger Err.MCInfo noSrcSpan -- See Note [MCInfo for Lint]
$ withPprStyle defaultDumpStyle
(vcat [ lint_banner "errors" pp_what, Err.pprMessageBag errs
, text "*** Offending Program ***"
@@ -436,9 +440,7 @@ displayLintResults logger display_warnings pp_what pp_pgm (warns, errs)
| not (isEmptyBag warns)
, log_enable_debug (logFlags logger)
, display_warnings
- -- If the Core linter encounters an error, output to stderr instead of
- -- stdout (#13342)
- = logMsg logger Err.MCInfo noSrcSpan
+ = logMsg logger Err.MCInfo noSrcSpan -- See Note [MCInfo for Lint]
$ withPprStyle defaultDumpStyle
(lint_banner "warnings" pp_what $$ Err.pprMessageBag (mapBag ($$ blankLine) warns))
diff --git a/compiler/GHC/Driver/CodeOutput.hs b/compiler/GHC/Driver/CodeOutput.hs
index c5c0534d20..458409a204 100644
--- a/compiler/GHC/Driver/CodeOutput.hs
+++ b/compiler/GHC/Driver/CodeOutput.hs
@@ -105,7 +105,7 @@ codeOutput logger tmpfs llvm_config dflags unit_state this_mod filenm location g
(const ()) $ do
{ case cmmLint (targetPlatform dflags) cmm of
Just err -> do { logMsg logger
- MCDump
+ MCInfo -- See Note [MCInfo for Lint] in "GHC.Core.Lint"
noSrcSpan
$ withPprStyle defaultDumpStyle err
; ghcExit logger 1
diff --git a/compiler/GHC/Stg/Lint.hs b/compiler/GHC/Stg/Lint.hs
index 8315e185e0..04d18ac5a5 100644
--- a/compiler/GHC/Stg/Lint.hs
+++ b/compiler/GHC/Stg/Lint.hs
@@ -149,7 +149,7 @@ lintStgTopBindings platform logger diag_opts opts extra_vars this_mod unarised w
Nothing ->
return ()
Just msg -> do
- logMsg logger Err.MCDump noSrcSpan
+ logMsg logger Err.MCInfo noSrcSpan -- See Note [MCInfo for Lint] in "GHC.Core.Lint"
$ withPprStyle defaultDumpStyle
(vcat [ text "*** Stg Lint ErrMsgs: in" <+>
text whodunit <+> text "***",