summaryrefslogtreecommitdiff
path: root/compiler/GHC/Tc/Deriv.hs
diff options
context:
space:
mode:
authorAlfredo Di Napoli <alfredo@well-typed.com>2021-03-09 09:11:47 +0100
committerMarge Bot <ben+marge-bot@smart-cactus.org>2021-04-05 20:39:54 -0400
commit495281215ae0fdcb296b2b30c1efd3a683006f42 (patch)
tree721e48d12c7bd79f05eb03f4a4d3c7114a71f9b8 /compiler/GHC/Tc/Deriv.hs
parent77772bb122410ef58ff006a1d18c6f2212216fda (diff)
downloadhaskell-495281215ae0fdcb296b2b30c1efd3a683006f42.tar.gz
Introduce SevIgnore Severity to suppress warnings
This commit introduces a new `Severity` type constructor called `SevIgnore`, which can be used to classify diagnostic messages which are not meant to be displayed to the user, for example suppressed warnings. This extra constructor allows us to get rid of a bunch of redundant checks when emitting diagnostics, typically in the form of the pattern: ``` when (optM Opt_XXX) $ addDiagnosticTc (WarningWithFlag Opt_XXX) ... ``` Fair warning! Not all checks should be omitted/skipped, as evaluating some data structures used to produce a diagnostic might still be expensive (e.g. zonking, etc). Therefore, a case-by-case analysis must be conducted when deciding if a check can be removed or not. Last but not least, we remove the unnecessary `CmdLine.WarnReason` type, which is now redundant with `DiagnosticReason`.
Diffstat (limited to 'compiler/GHC/Tc/Deriv.hs')
-rw-r--r--compiler/GHC/Tc/Deriv.hs10
1 files changed, 4 insertions, 6 deletions
diff --git a/compiler/GHC/Tc/Deriv.hs b/compiler/GHC/Tc/Deriv.hs
index 198bfa2477..40761ed38c 100644
--- a/compiler/GHC/Tc/Deriv.hs
+++ b/compiler/GHC/Tc/Deriv.hs
@@ -738,10 +738,9 @@ tcStandaloneDerivInstType ctxt
warnUselessTypeable :: TcM ()
warnUselessTypeable
- = do { warn <- woptM Opt_WarnDerivingTypeable
- ; when warn $ addDiagnosticTc (WarningWithFlag Opt_WarnDerivingTypeable)
- $ text "Deriving" <+> quotes (ppr typeableClassName) <+>
- text "has no effect: all types now auto-derive Typeable" }
+ = do { addDiagnosticTc (WarningWithFlag Opt_WarnDerivingTypeable)
+ $ text "Deriving" <+> quotes (ppr typeableClassName) <+>
+ text "has no effect: all types now auto-derive Typeable" }
------------------------------------------------------------------
deriveTyData :: TyCon -> [Type] -- LHS of data or data instance
@@ -1610,8 +1609,7 @@ mkNewTypeEqn newtype_strat dit@(DerivInstTys { dit_cls_tys = cls_tys
-- DeriveAnyClass, but emitting a warning about the choice.
-- See Note [Deriving strategies]
when (newtype_deriving && deriveAnyClass) $
- lift $ whenWOptM Opt_WarnDerivingDefaults $
- addDiagnosticTc (WarningWithFlag Opt_WarnDerivingDefaults) $ sep
+ lift $ addDiagnosticTc (WarningWithFlag Opt_WarnDerivingDefaults) $ sep
[ text "Both DeriveAnyClass and"
<+> text "GeneralizedNewtypeDeriving are enabled"
, text "Defaulting to the DeriveAnyClass strategy"