summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHerbert Valerio Riedel <hvr@gnu.org>2016-04-05 15:15:47 +0200
committerBen Gamari <ben@smart-cactus.org>2016-04-05 15:46:58 +0200
commit1e6ec1249b4da88fec9024598c2183e6fc0e96cd (patch)
treeabf58c7119b1f7ec2400e97c15c6e1cdeddd81ee
parent2f3b8039e43bd1e2ce7d5af166301441e25b40c4 (diff)
downloadhaskell-1e6ec1249b4da88fec9024598c2183e6fc0e96cd.tar.gz
Fix misattribution of `-Wunused-local-binds` warnings
This fixes a bug where warnings actually controlled by - `Opt_WarnUnusedMatches` - `Opt_WarnUnusedTypePatterns` - `Opt_WarnUnusedTopBinds` were incorrectly reported as being controlled by `Opt_WarnUnusedLocalBinds` as well This bug was introduced in bb5afd3c274011c5ea302210b4c290ec1f83209c while implementing #10752 Test Plan: ./validate still running -- testsuite output wiggles expected Reviewers: barrucadu, quchen, austin, bgamari Reviewed By: bgamari Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2077
-rw-r--r--compiler/rename/RnEnv.hs17
-rw-r--r--testsuite/tests/deSugar/should_compile/ds053.stderr2
-rw-r--r--testsuite/tests/driver/werror.stderr2
-rw-r--r--testsuite/tests/indexed-types/should_compile/UnusedTyVarWarnings.stderr8
-rw-r--r--testsuite/tests/indexed-types/should_compile/UnusedTyVarWarningsNamedWCs.stderr8
-rw-r--r--testsuite/tests/overloadedrecflds/should_fail/overloadedrecfldsfail05.stderr2
-rw-r--r--testsuite/tests/overloadedrecflds/should_fail/overloadedrecfldsfail06.stderr6
-rw-r--r--testsuite/tests/parser/should_compile/read014.stderr4
-rw-r--r--testsuite/tests/rename/should_compile/T17a.stderr2
-rw-r--r--testsuite/tests/rename/should_compile/T17d.stderr2
-rw-r--r--testsuite/tests/rename/should_compile/T17e.stderr2
-rw-r--r--testsuite/tests/rename/should_compile/T3371.stderr2
-rw-r--r--testsuite/tests/rename/should_compile/T3449.stderr2
-rw-r--r--testsuite/tests/rename/should_compile/T7145b.stderr2
-rw-r--r--testsuite/tests/rename/should_compile/mc10.stderr2
-rw-r--r--testsuite/tests/rename/should_compile/rn040.stderr4
-rw-r--r--testsuite/tests/rename/should_compile/rn041.stderr6
-rw-r--r--testsuite/tests/rename/should_compile/rn047.stderr2
-rw-r--r--testsuite/tests/typecheck/should_compile/T2497.stderr2
19 files changed, 39 insertions, 38 deletions
diff --git a/compiler/rename/RnEnv.hs b/compiler/rename/RnEnv.hs
index a2fd926cba..4c9940d894 100644
--- a/compiler/rename/RnEnv.hs
+++ b/compiler/rename/RnEnv.hs
@@ -2107,22 +2107,23 @@ warnUnusedTypePatterns = check_unused Opt_WarnUnusedTypePatterns
check_unused :: WarningFlag -> [Name] -> FreeVars -> RnM ()
check_unused flag bound_names used_names
- = whenWOptM flag (warnUnusedLocals (filterOut (`elemNameSet` used_names) bound_names))
+ = whenWOptM flag (warnUnused flag (filterOut (`elemNameSet` used_names)
+ bound_names))
-------------------------
-- Helpers
warnUnusedGREs :: [GlobalRdrElt] -> RnM ()
warnUnusedGREs gres = mapM_ warnUnusedGRE gres
-warnUnusedLocals :: [Name] -> RnM ()
-warnUnusedLocals names = do
+warnUnused :: WarningFlag -> [Name] -> RnM ()
+warnUnused flag names = do
fld_env <- mkFieldEnv <$> getGlobalRdrEnv
- mapM_ (warnUnusedLocal fld_env) names
+ mapM_ (warnUnused1 flag fld_env) names
-warnUnusedLocal :: NameEnv (FieldLabelString, Name) -> Name -> RnM ()
-warnUnusedLocal fld_env name
+warnUnused1 :: WarningFlag -> NameEnv (FieldLabelString, Name) -> Name -> RnM ()
+warnUnused1 flag fld_env name
= when (reportable name) $
- addUnusedWarning Opt_WarnUnusedLocalBinds
+ addUnusedWarning flag
occ (nameSrcSpan name)
(text "Defined but not used")
where
@@ -2133,7 +2134,7 @@ warnUnusedLocal fld_env name
warnUnusedGRE :: GlobalRdrElt -> RnM ()
warnUnusedGRE gre@(GRE { gre_name = name, gre_lcl = lcl, gre_imp = is })
| lcl = do fld_env <- mkFieldEnv <$> getGlobalRdrEnv
- warnUnusedLocal fld_env name
+ warnUnused1 Opt_WarnUnusedTopBinds fld_env name
| otherwise = when (reportable name) (mapM_ warn is)
where
occ = greOccName gre
diff --git a/testsuite/tests/deSugar/should_compile/ds053.stderr b/testsuite/tests/deSugar/should_compile/ds053.stderr
index 6e7cb2572c..841c6da753 100644
--- a/testsuite/tests/deSugar/should_compile/ds053.stderr
+++ b/testsuite/tests/deSugar/should_compile/ds053.stderr
@@ -1,3 +1,3 @@
-ds053.hs:5:1: warning: [-Wunused-local-binds (in -Wextra, -Wunused-binds)]
+ds053.hs:5:1: warning: [-Wunused-top-binds (in -Wextra, -Wunused-binds)]
Defined but not used: ‘f’
diff --git a/testsuite/tests/driver/werror.stderr b/testsuite/tests/driver/werror.stderr
index 39dddee619..398d885438 100644
--- a/testsuite/tests/driver/werror.stderr
+++ b/testsuite/tests/driver/werror.stderr
@@ -13,7 +13,7 @@ werror.hs:8:1: warning: [-Wtabs (in -Wdefault)]
Tab character found here.
Please use spaces instead.
-werror.hs:10:1: warning: [-Wunused-local-binds (in -Wextra, -Wunused-binds)]
+werror.hs:10:1: warning: [-Wunused-top-binds (in -Wextra, -Wunused-binds)]
Defined but not used: ‘f’
werror.hs:10:1: warning: [-Wmissing-signatures (in -Wall)]
diff --git a/testsuite/tests/indexed-types/should_compile/UnusedTyVarWarnings.stderr b/testsuite/tests/indexed-types/should_compile/UnusedTyVarWarnings.stderr
index 1ff5858094..5881145e23 100644
--- a/testsuite/tests/indexed-types/should_compile/UnusedTyVarWarnings.stderr
+++ b/testsuite/tests/indexed-types/should_compile/UnusedTyVarWarnings.stderr
@@ -1,12 +1,12 @@
-UnusedTyVarWarnings.hs:8:5: warning: [-Wunused-local-binds (in -Wextra, -Wunused-binds)]
+UnusedTyVarWarnings.hs:8:5: warning: [-Wunused-type-patterns]
Defined but not used: type variable ‘b’
-UnusedTyVarWarnings.hs:11:18: warning: [-Wunused-local-binds (in -Wextra, -Wunused-binds)]
+UnusedTyVarWarnings.hs:11:18: warning: [-Wunused-type-patterns]
Defined but not used: type variable ‘b’
-UnusedTyVarWarnings.hs:27:5: warning: [-Wunused-local-binds (in -Wextra, -Wunused-binds)]
+UnusedTyVarWarnings.hs:27:5: warning: [-Wunused-type-patterns]
Defined but not used: type variable ‘a’
-UnusedTyVarWarnings.hs:33:17: warning: [-Wunused-local-binds (in -Wextra, -Wunused-binds)]
+UnusedTyVarWarnings.hs:33:17: warning: [-Wunused-type-patterns]
Defined but not used: type variable ‘b’
diff --git a/testsuite/tests/indexed-types/should_compile/UnusedTyVarWarningsNamedWCs.stderr b/testsuite/tests/indexed-types/should_compile/UnusedTyVarWarningsNamedWCs.stderr
index 889f1921f9..6cbc861b28 100644
--- a/testsuite/tests/indexed-types/should_compile/UnusedTyVarWarningsNamedWCs.stderr
+++ b/testsuite/tests/indexed-types/should_compile/UnusedTyVarWarningsNamedWCs.stderr
@@ -1,12 +1,12 @@
-UnusedTyVarWarningsNamedWCs.hs:8:5: warning: [-Wunused-local-binds (in -Wextra, -Wunused-binds)]
+UnusedTyVarWarningsNamedWCs.hs:8:5: warning: [-Wunused-type-patterns]
Defined but not used: type variable ‘b’
-UnusedTyVarWarningsNamedWCs.hs:11:18: warning: [-Wunused-local-binds (in -Wextra, -Wunused-binds)]
+UnusedTyVarWarningsNamedWCs.hs:11:18: warning: [-Wunused-type-patterns]
Defined but not used: type variable ‘b’
-UnusedTyVarWarningsNamedWCs.hs:27:5: warning: [-Wunused-local-binds (in -Wextra, -Wunused-binds)]
+UnusedTyVarWarningsNamedWCs.hs:27:5: warning: [-Wunused-type-patterns]
Defined but not used: type variable ‘a’
-UnusedTyVarWarningsNamedWCs.hs:33:17: warning: [-Wunused-local-binds (in -Wextra, -Wunused-binds)]
+UnusedTyVarWarningsNamedWCs.hs:33:17: warning: [-Wunused-type-patterns]
Defined but not used: type variable ‘b’
diff --git a/testsuite/tests/overloadedrecflds/should_fail/overloadedrecfldsfail05.stderr b/testsuite/tests/overloadedrecflds/should_fail/overloadedrecfldsfail05.stderr
index 90d38fd712..e3fbbcfd9e 100644
--- a/testsuite/tests/overloadedrecflds/should_fail/overloadedrecfldsfail05.stderr
+++ b/testsuite/tests/overloadedrecflds/should_fail/overloadedrecfldsfail05.stderr
@@ -1,5 +1,5 @@
-overloadedrecfldsfail05.hs:7:16: warning: [-Wunused-local-binds (in -Wextra, -Wunused-binds)]
+overloadedrecfldsfail05.hs:7:16: warning: [-Wunused-top-binds (in -Wextra, -Wunused-binds)]
Defined but not used: ‘foo’
<no location info>: error:
diff --git a/testsuite/tests/overloadedrecflds/should_fail/overloadedrecfldsfail06.stderr b/testsuite/tests/overloadedrecflds/should_fail/overloadedrecfldsfail06.stderr
index 6161755562..dc8a9d6bbc 100644
--- a/testsuite/tests/overloadedrecflds/should_fail/overloadedrecfldsfail06.stderr
+++ b/testsuite/tests/overloadedrecflds/should_fail/overloadedrecfldsfail06.stderr
@@ -1,12 +1,12 @@
[1 of 2] Compiling OverloadedRecFldsFail06_A ( OverloadedRecFldsFail06_A.hs, OverloadedRecFldsFail06_A.o )
-OverloadedRecFldsFail06_A.hs:9:15: warning: [-Wunused-local-binds (in -Wextra, -Wunused-binds)]
+OverloadedRecFldsFail06_A.hs:9:15: warning: [-Wunused-top-binds (in -Wextra, -Wunused-binds)]
Defined but not used: data constructor ‘MkUnused’
-OverloadedRecFldsFail06_A.hs:9:42: warning: [-Wunused-local-binds (in -Wextra, -Wunused-binds)]
+OverloadedRecFldsFail06_A.hs:9:42: warning: [-Wunused-top-binds (in -Wextra, -Wunused-binds)]
Defined but not used: ‘unused2’
-OverloadedRecFldsFail06_A.hs:9:59: warning: [-Wunused-local-binds (in -Wextra, -Wunused-binds)]
+OverloadedRecFldsFail06_A.hs:9:59: warning: [-Wunused-top-binds (in -Wextra, -Wunused-binds)]
Defined but not used: ‘used_locally’
[2 of 2] Compiling Main ( overloadedrecfldsfail06.hs, overloadedrecfldsfail06.o )
diff --git a/testsuite/tests/parser/should_compile/read014.stderr b/testsuite/tests/parser/should_compile/read014.stderr
index f7a6508d2a..4b324b1b2a 100644
--- a/testsuite/tests/parser/should_compile/read014.stderr
+++ b/testsuite/tests/parser/should_compile/read014.stderr
@@ -3,7 +3,7 @@ read014.hs:4:1: warning: [-Wmissing-signatures (in -Wall)]
Top-level binding with no type signature:
ng1 :: forall t a. Num a => t -> a -> a
-read014.hs:4:5: warning: [-Wunused-local-binds (in -Wextra, -Wunused-binds)]
+read014.hs:4:5: warning: [-Wunused-matches (in -Wextra)]
Defined but not used: ‘x’
read014.hs:6:10: warning: [-Wmissing-methods (in -Wdefault)]
@@ -11,5 +11,5 @@ read014.hs:6:10: warning: [-Wmissing-methods (in -Wdefault)]
‘+’, ‘*’, ‘abs’, ‘signum’, and ‘fromInteger’
• In the instance declaration for ‘Num (a, b)’
-read014.hs:8:53: warning: [-Wunused-local-binds (in -Wextra, -Wunused-binds)]
+read014.hs:8:53: warning: [-Wunused-matches (in -Wextra)]
Defined but not used: ‘x’
diff --git a/testsuite/tests/rename/should_compile/T17a.stderr b/testsuite/tests/rename/should_compile/T17a.stderr
index 9d0457ee15..4e88e2e440 100644
--- a/testsuite/tests/rename/should_compile/T17a.stderr
+++ b/testsuite/tests/rename/should_compile/T17a.stderr
@@ -1,3 +1,3 @@
-T17a.hs:8:1: warning: [-Wunused-local-binds (in -Wextra, -Wunused-binds)]
+T17a.hs:8:1: warning: [-Wunused-top-binds (in -Wextra, -Wunused-binds)]
Defined but not used: ‘top’
diff --git a/testsuite/tests/rename/should_compile/T17d.stderr b/testsuite/tests/rename/should_compile/T17d.stderr
index 6c99f1798d..4fbc9ab8a2 100644
--- a/testsuite/tests/rename/should_compile/T17d.stderr
+++ b/testsuite/tests/rename/should_compile/T17d.stderr
@@ -1,3 +1,3 @@
-T17d.hs:14:5: warning: [-Wunused-local-binds (in -Wextra, -Wunused-binds)]
+T17d.hs:14:5: warning: [-Wunused-matches (in -Wextra)]
Defined but not used: ‘match’
diff --git a/testsuite/tests/rename/should_compile/T17e.stderr b/testsuite/tests/rename/should_compile/T17e.stderr
index e63f479db5..2d0e0bdc87 100644
--- a/testsuite/tests/rename/should_compile/T17e.stderr
+++ b/testsuite/tests/rename/should_compile/T17e.stderr
@@ -1,5 +1,5 @@
-T17e.hs:8:1: warning: [-Wunused-local-binds (in -Wextra, -Wunused-binds)]
+T17e.hs:8:1: warning: [-Wunused-top-binds (in -Wextra, -Wunused-binds)]
Defined but not used: ‘top’
T17e.hs:11:11: warning: [-Wunused-pattern-binds (in -Wextra, -Wunused-binds)]
diff --git a/testsuite/tests/rename/should_compile/T3371.stderr b/testsuite/tests/rename/should_compile/T3371.stderr
index d5434040b5..b563291965 100644
--- a/testsuite/tests/rename/should_compile/T3371.stderr
+++ b/testsuite/tests/rename/should_compile/T3371.stderr
@@ -1,3 +1,3 @@
-T3371.hs:10:14: warning: [-Wunused-local-binds (in -Wextra, -Wunused-binds)]
+T3371.hs:10:14: warning: [-Wunused-matches (in -Wextra)]
Defined but not used: ‘a’
diff --git a/testsuite/tests/rename/should_compile/T3449.stderr b/testsuite/tests/rename/should_compile/T3449.stderr
index 4f854d1455..afc8d92515 100644
--- a/testsuite/tests/rename/should_compile/T3449.stderr
+++ b/testsuite/tests/rename/should_compile/T3449.stderr
@@ -1,3 +1,3 @@
-T3449.hs-boot:8:1: warning: [-Wunused-local-binds (in -Wextra, -Wunused-binds)]
+T3449.hs-boot:8:1: warning: [-Wunused-top-binds (in -Wextra, -Wunused-binds)]
Defined but not used: ‘unused’
diff --git a/testsuite/tests/rename/should_compile/T7145b.stderr b/testsuite/tests/rename/should_compile/T7145b.stderr
index 3327446b3b..013d93174d 100644
--- a/testsuite/tests/rename/should_compile/T7145b.stderr
+++ b/testsuite/tests/rename/should_compile/T7145b.stderr
@@ -1,3 +1,3 @@
-T7145b.hs:7:1: warning: [-Wunused-local-binds (in -Wextra, -Wunused-binds)]
+T7145b.hs:7:1: warning: [-Wunused-top-binds (in -Wextra, -Wunused-binds)]
Defined but not used: ‘pure’
diff --git a/testsuite/tests/rename/should_compile/mc10.stderr b/testsuite/tests/rename/should_compile/mc10.stderr
index aa33c1447b..285bd34aeb 100644
--- a/testsuite/tests/rename/should_compile/mc10.stderr
+++ b/testsuite/tests/rename/should_compile/mc10.stderr
@@ -1,3 +1,3 @@
-mc10.hs:14:11: warning: [-Wunused-local-binds (in -Wextra, -Wunused-binds)]
+mc10.hs:14:11: warning: [-Wunused-matches (in -Wextra)]
Defined but not used: ‘y’
diff --git a/testsuite/tests/rename/should_compile/rn040.stderr b/testsuite/tests/rename/should_compile/rn040.stderr
index 1e0d4a341a..01d6a10e16 100644
--- a/testsuite/tests/rename/should_compile/rn040.stderr
+++ b/testsuite/tests/rename/should_compile/rn040.stderr
@@ -1,6 +1,6 @@
-rn040.hs:6:12: warning: [-Wunused-local-binds (in -Wextra, -Wunused-binds)]
+rn040.hs:6:12: warning: [-Wunused-matches (in -Wextra)]
Defined but not used: ‘y’
-rn040.hs:8:8: warning: [-Wunused-local-binds (in -Wextra, -Wunused-binds)]
+rn040.hs:8:8: warning: [-Wunused-matches (in -Wextra)]
Defined but not used: ‘w’
diff --git a/testsuite/tests/rename/should_compile/rn041.stderr b/testsuite/tests/rename/should_compile/rn041.stderr
index 891a2b21f0..559da82a98 100644
--- a/testsuite/tests/rename/should_compile/rn041.stderr
+++ b/testsuite/tests/rename/should_compile/rn041.stderr
@@ -1,9 +1,9 @@
-rn041.hs:7:1: warning: [-Wunused-local-binds (in -Wextra, -Wunused-binds)]
+rn041.hs:7:1: warning: [-Wunused-top-binds (in -Wextra, -Wunused-binds)]
Defined but not used: ‘f’
-rn041.hs:9:1: warning: [-Wunused-local-binds (in -Wextra, -Wunused-binds)]
+rn041.hs:9:1: warning: [-Wunused-top-binds (in -Wextra, -Wunused-binds)]
Defined but not used: ‘g’
-rn041.hs:10:1: warning: [-Wunused-local-binds (in -Wextra, -Wunused-binds)]
+rn041.hs:10:1: warning: [-Wunused-top-binds (in -Wextra, -Wunused-binds)]
Defined but not used: ‘h’
diff --git a/testsuite/tests/rename/should_compile/rn047.stderr b/testsuite/tests/rename/should_compile/rn047.stderr
index 168adb5877..17f59a1c24 100644
--- a/testsuite/tests/rename/should_compile/rn047.stderr
+++ b/testsuite/tests/rename/should_compile/rn047.stderr
@@ -1,3 +1,3 @@
-rn047.hs:12:11: warning: [-Wunused-local-binds (in -Wextra, -Wunused-binds)]
+rn047.hs:12:11: warning: [-Wunused-matches (in -Wextra)]
Defined but not used: ‘y’
diff --git a/testsuite/tests/typecheck/should_compile/T2497.stderr b/testsuite/tests/typecheck/should_compile/T2497.stderr
index 2fefbbd8af..581008128b 100644
--- a/testsuite/tests/typecheck/should_compile/T2497.stderr
+++ b/testsuite/tests/typecheck/should_compile/T2497.stderr
@@ -1,3 +1,3 @@
-T2497.hs:22:1: warning: [-Wunused-local-binds (in -Wextra, -Wunused-binds)]
+T2497.hs:22:1: warning: [-Wunused-top-binds (in -Wextra, -Wunused-binds)]
Defined but not used: ‘beq’