summaryrefslogtreecommitdiff
path: root/testsuite
diff options
context:
space:
mode:
authorMatthew Pickering <matthewtpickering@gmail.com>2022-06-15 11:45:33 +0100
committersheaf <sam.derbyshire@gmail.com>2022-10-18 16:15:49 +0200
commite1bbd36841e19812c7ed544b66256da82ce68fd5 (patch)
tree5e524caae7e938509097b95bf0069317ed58db91 /testsuite
parentba4bd4a48223bc9b215cfda138a5de9f99c87cdf (diff)
downloadhaskell-e1bbd36841e19812c7ed544b66256da82ce68fd5.tar.gz
Allow configuration of error message printing
This MR implements the idea of #21731 that the printing of a diagnostic method should be configurable at the printing time. The interface of the `Diagnostic` class is modified from: ``` class Diagnostic a where diagnosticMessage :: a -> DecoratedSDoc diagnosticReason :: a -> DiagnosticReason diagnosticHints :: a -> [GhcHint] ``` to ``` class Diagnostic a where type DiagnosticOpts a defaultDiagnosticOpts :: DiagnosticOpts a diagnosticMessage :: DiagnosticOpts a -> a -> DecoratedSDoc diagnosticReason :: a -> DiagnosticReason diagnosticHints :: a -> [GhcHint] ``` and so each `Diagnostic` can implement their own configuration record which can then be supplied by a client in order to dictate how to print out the error message. At the moment this only allows us to implement #21722 nicely but in future it is more natural to separate the configuration of how much information we put into an error message and how much we decide to print out of it. Updates Haddock submodule
Diffstat (limited to 'testsuite')
-rw-r--r--testsuite/tests/ghc-api/T18522-dbg-ppr.hs5
-rw-r--r--testsuite/tests/regalloc/regalloc_unit_tests.hs3
2 files changed, 5 insertions, 3 deletions
diff --git a/testsuite/tests/ghc-api/T18522-dbg-ppr.hs b/testsuite/tests/ghc-api/T18522-dbg-ppr.hs
index 8e89a63cc6..32bad7c8e0 100644
--- a/testsuite/tests/ghc-api/T18522-dbg-ppr.hs
+++ b/testsuite/tests/ghc-api/T18522-dbg-ppr.hs
@@ -51,7 +51,8 @@ main = do
case mres of
Nothing -> do
let diag_opts = initDiagOpts dflags
- printMessages logger diag_opts warnings
- printMessages logger diag_opts errors
+ print_config = initTcMessageOpts dflags
+ printMessages logger print_config diag_opts warnings
+ printMessages logger print_config diag_opts errors
Just (t, _) -> do
putStrLn $ showSDoc dflags (debugPprType t)
diff --git a/testsuite/tests/regalloc/regalloc_unit_tests.hs b/testsuite/tests/regalloc/regalloc_unit_tests.hs
index 0238b5d03c..f3294bfd35 100644
--- a/testsuite/tests/regalloc/regalloc_unit_tests.hs
+++ b/testsuite/tests/regalloc/regalloc_unit_tests.hs
@@ -140,7 +140,8 @@ compileCmmForRegAllocStats logger home_unit dflags cmmFile ncgImplF us = do
-- print parser errors or warnings
let !diag_opts = initDiagOpts dflags
- mapM_ (printMessages logger diag_opts) [warnings, errors]
+ !print_config = initPsMessageOpts dflags
+ mapM_ (printMessages logger print_config diag_opts) [warnings, errors]
let initTopSRT = emptySRT thisMod
cmmGroup <- fmap snd $ cmmPipeline logger cmm_config initTopSRT $ fst $ fromJust parsedCmm