Fix misattribution of `-Wunused-local-binds` warnings
authorHerbert Valerio Riedel <hvr@gnu.org>
Tue, 5 Apr 2016 13:15:47 +0000 (15:15 +0200)
committerBen Gamari <ben@smart-cactus.org>
Tue, 5 Apr 2016 13:46:58 +0000 (15:46 +0200)
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

19 files changed:
compiler/rename/RnEnv.hs
testsuite/tests/deSugar/should_compile/ds053.stderr
testsuite/tests/driver/werror.stderr
testsuite/tests/indexed-types/should_compile/UnusedTyVarWarnings.stderr
testsuite/tests/indexed-types/should_compile/UnusedTyVarWarningsNamedWCs.stderr
testsuite/tests/overloadedrecflds/should_fail/overloadedrecfldsfail05.stderr
testsuite/tests/overloadedrecflds/should_fail/overloadedrecfldsfail06.stderr
testsuite/tests/parser/should_compile/read014.stderr
testsuite/tests/rename/should_compile/T17a.stderr
testsuite/tests/rename/should_compile/T17d.stderr
testsuite/tests/rename/should_compile/T17e.stderr
testsuite/tests/rename/should_compile/T3371.stderr
testsuite/tests/rename/should_compile/T3449.stderr
testsuite/tests/rename/should_compile/T7145b.stderr
testsuite/tests/rename/should_compile/mc10.stderr
testsuite/tests/rename/should_compile/rn040.stderr
testsuite/tests/rename/should_compile/rn041.stderr
testsuite/tests/rename/should_compile/rn047.stderr
testsuite/tests/typecheck/should_compile/T2497.stderr

index a2fd926..4c9940d 100644 (file)
@@ -2107,22 +2107,23 @@ warnUnusedTypePatterns = check_unused Opt_WarnUnusedTypePatterns
 
 check_unused :: WarningFlag -> [Name] -> FreeVars -> RnM ()
 check_unused flag bound_names used_names
 
 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
 
 
 -------------------------
 --      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
     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) $
   = when (reportable name) $
-    addUnusedWarning Opt_WarnUnusedLocalBinds
+    addUnusedWarning flag
                      occ (nameSrcSpan name)
                      (text "Defined but not used")
   where
                      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
 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
   | otherwise = when (reportable name) (mapM_ warn is)
   where
     occ = greOccName gre
index 6e7cb25..841c6da 100644 (file)
@@ -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’
     Defined but not used: ‘f’
index 39dddee..398d885 100644 (file)
@@ -13,7 +13,7 @@ werror.hs:8:1: warning: [-Wtabs (in -Wdefault)]
     Tab character found here.
     Please use spaces instead.
 
     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)]
     Defined but not used: ‘f’
 
 werror.hs:10:1: warning: [-Wmissing-signatures (in -Wall)]
index 1ff5858..5881145 100644 (file)
@@ -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’
 
     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’
 
     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’
 
     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’
     Defined but not used: type variable ‘b’
index 889f192..6cbc861 100644 (file)
@@ -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’
 
     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’
 
     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’
 
     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’
     Defined but not used: type variable ‘b’
index 90d38fd..e3fbbcf 100644 (file)
@@ -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: 
     Defined but not used: ‘foo’
 
 <no location info>: error: 
index 6161755..dc8a9d6 100644 (file)
@@ -1,12 +1,12 @@
 [1 of 2] Compiling OverloadedRecFldsFail06_A ( OverloadedRecFldsFail06_A.hs, OverloadedRecFldsFail06_A.o )
 
 [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’
 
     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’
 
     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 )
 
     Defined but not used: ‘used_locally’
 [2 of 2] Compiling Main             ( overloadedrecfldsfail06.hs, overloadedrecfldsfail06.o )
 
index f7a6508..4b324b1 100644 (file)
@@ -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
 
     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)]
     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)’
 
         ‘+’, ‘*’, ‘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’
     Defined but not used: ‘x’
index 9d0457e..4e88e2e 100644 (file)
@@ -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’
     Defined but not used: ‘top’
index 6c99f17..4fbc9ab 100644 (file)
@@ -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’
     Defined but not used: ‘match’
index e63f479..2d0e0bd 100644 (file)
@@ -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)]
     Defined but not used: ‘top’
 
 T17e.hs:11:11: warning: [-Wunused-pattern-binds (in -Wextra, -Wunused-binds)]
index d543404..b563291 100644 (file)
@@ -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’
     Defined but not used: ‘a’
index 4f854d1..afc8d92 100644 (file)
@@ -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’
     Defined but not used: ‘unused’
index 3327446..013d931 100644 (file)
@@ -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’
     Defined but not used: ‘pure’
index aa33c14..285bd34 100644 (file)
@@ -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’
     Defined but not used: ‘y’
index 1e0d4a3..01d6a10 100644 (file)
@@ -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’
 
     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’
     Defined but not used: ‘w’
index 891a2b2..559da82 100644 (file)
@@ -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’
 
     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’
 
     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’
     Defined but not used: ‘h’
index 168adb5..17f59a1 100644 (file)
@@ -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’
     Defined but not used: ‘y’
index 2fefbbd..5810081 100644 (file)
@@ -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’
     Defined but not used: ‘beq’