summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaolo Capriotti <p.capriotti@gmail.com>2012-07-24 16:59:50 +0100
committerPaolo Capriotti <p.capriotti@gmail.com>2012-07-24 16:59:50 +0100
commitc9733e263906eaf13b3cc585e76f42e8bddbde4c (patch)
tree8c64cb57c464cab10f53e4aea508a5fa440d2344
parentb498b9983b75b8b7c3a365c1b44e85cbddd09648 (diff)
downloadhaskell-c9733e263906eaf13b3cc585e76f42e8bddbde4c.tar.gz
Add flag to disable rule shadowing warning.
Also, temporarely disable that warning for validate builds, until we finish fixing them all.
-rw-r--r--compiler/deSugar/Desugar.lhs4
-rw-r--r--compiler/main/DynFlags.hs4
-rw-r--r--mk/validate-settings.mk2
3 files changed, 8 insertions, 2 deletions
diff --git a/compiler/deSugar/Desugar.lhs b/compiler/deSugar/Desugar.lhs
index 2b068bbd46..ae9b0ec16f 100644
--- a/compiler/deSugar/Desugar.lhs
+++ b/compiler/deSugar/Desugar.lhs
@@ -364,6 +364,7 @@ dsRule (L loc (HsRule name act vars lhs _tv_lhs rhs _fv_rhs))
dsLExpr lhs -- Note [Desugaring RULE left hand sides]
; rhs' <- dsLExpr rhs
+ ; dflags <- getDynFlags
-- Substitute the dict bindings eagerly,
-- and take the body apart into a (f args) form
@@ -381,6 +382,7 @@ dsRule (L loc (HsRule name act vars lhs _tv_lhs rhs _fv_rhs))
name act fn_name final_bndrs args final_rhs
inline_shadows_rule -- Function can be inlined before rule fires
+ | wopt Opt_WarnInlineRuleShadowing dflags
= case (idInlineActivation fn_id, act) of
(NeverActive, _) -> False
(AlwaysActive, _) -> True
@@ -389,7 +391,7 @@ dsRule (L loc (HsRule name act vars lhs _tv_lhs rhs _fv_rhs))
(ActiveAfter n, ActiveAfter r) -> r < n -- Rule active strictly first
(ActiveAfter {}, AlwaysActive) -> False
(ActiveAfter {}, ActiveBefore {}) -> False
-
+ | otherwise = False
; when inline_shadows_rule $
warnDs (vcat [ hang (ptext (sLit "Rule") <+> doubleQuotes (ftext name)
diff --git a/compiler/main/DynFlags.hs b/compiler/main/DynFlags.hs
index fc11f2d52d..b75f743c79 100644
--- a/compiler/main/DynFlags.hs
+++ b/compiler/main/DynFlags.hs
@@ -383,6 +383,7 @@ data WarningFlag =
| Opt_WarnSafe
| Opt_WarnPointlessPragmas
| Opt_WarnUnsupportedCallingConventions
+ | Opt_WarnInlineRuleShadowing
deriving (Eq, Show, Enum)
data Language = Haskell98 | Haskell2010
@@ -1981,7 +1982,8 @@ fWarningFlags = [
( "warn-unsafe", Opt_WarnUnsafe, setWarnUnsafe ),
( "warn-safe", Opt_WarnSafe, setWarnSafe ),
( "warn-pointless-pragmas", Opt_WarnPointlessPragmas, nop ),
- ( "warn-unsupported-calling-conventions", Opt_WarnUnsupportedCallingConventions, nop ) ]
+ ( "warn-unsupported-calling-conventions", Opt_WarnUnsupportedCallingConventions, nop ),
+ ( "warn-inline-rule-shadowing", Opt_WarnInlineRuleShadowing, nop ) ]
-- | These @-\<blah\>@ flags can all be reversed with @-no-\<blah\>@
negatableFlags :: [FlagSpec DynFlag]
diff --git a/mk/validate-settings.mk b/mk/validate-settings.mk
index b8a48394b9..cd7ef1a9c1 100644
--- a/mk/validate-settings.mk
+++ b/mk/validate-settings.mk
@@ -123,3 +123,5 @@ libraries/binary/src/Data/Binary/Get_HC_OPTS += -fno-warn-warnings-deprecations
GhcLibHcOpts += -fno-warn-deprecated-flags
GhcBootLibHcOpts += -fno-warn-deprecated-flags
+# Temporarely disable rule shadowing warning
+GhcLibHcOpts += -fno-warn-inline-rule-shadowing