summaryrefslogtreecommitdiff
path: root/testsuite/tests/rename
diff options
context:
space:
mode:
authorDavid Eichmann <EichmannD@gmail.com>2018-11-22 14:48:05 -0500
committerBen Gamari <ben@smart-cactus.org>2018-11-22 16:10:06 -0500
commit6353efc7694ba8ec86c091918e02595662169ae2 (patch)
tree13a255193a5a9685a97e99c020578144df21af39 /testsuite/tests/rename
parent8d008b71db53f7a59673f894f329b8d71f84c8ee (diff)
downloadhaskell-6353efc7694ba8ec86c091918e02595662169ae2.tar.gz
Fix unused-import warnings
This patch fixes a fairly long-standing bug (dating back to 2015) in RdrName.bestImport, namely commit 9376249b6b78610db055a10d05f6592d6bbbea2f Author: Simon Peyton Jones <simonpj@microsoft.com> Date: Wed Oct 28 17:16:55 2015 +0000 Fix unused-import stuff in a better way In that patch got the sense of the comparison back to front, and thereby failed to implement the unused-import rules described in Note [Choosing the best import declaration] in RdrName This led to Trac #13064 and #15393 Fixing this bug revealed a bunch of unused imports in libraries; the ones in the GHC repo are part of this commit. The two important changes are * Fix the bug in bestImport * Modified the rules by adding (a) in Note [Choosing the best import declaration] in RdrName Reason: the previosu rules made Trac #5211 go bad again. And the new rule (a) makes sense to me. In unravalling this I also ended up doing a few other things * Refactor RnNames.ImportDeclUsage to use a [GlobalRdrElt] for the things that are used, rather than [AvailInfo]. This is simpler and more direct. * Rename greParentName to greParent_maybe, to follow GHC naming conventions * Delete dead code RdrName.greUsedRdrName Bumps a few submodules. Reviewers: hvr, goldfire, bgamari, simonmar, jrtc27 Subscribers: rwbarton, carter Differential Revision: https://phabricator.haskell.org/D5312
Diffstat (limited to 'testsuite/tests/rename')
-rw-r--r--testsuite/tests/rename/should_compile/T13064.hs8
-rw-r--r--testsuite/tests/rename/should_compile/T13064.stderr3
-rw-r--r--testsuite/tests/rename/should_compile/T4239.stdout2
-rw-r--r--testsuite/tests/rename/should_compile/all.T1
4 files changed, 13 insertions, 1 deletions
diff --git a/testsuite/tests/rename/should_compile/T13064.hs b/testsuite/tests/rename/should_compile/T13064.hs
new file mode 100644
index 0000000000..6c8d79fb17
--- /dev/null
+++ b/testsuite/tests/rename/should_compile/T13064.hs
@@ -0,0 +1,8 @@
+{-# OPTIONS_GHC -Wunused-imports #-}
+module T13064 where
+
+import Control.Applicative
+import Prelude (IO, pure) -- Import of 'pure' is redundant
+
+foo :: IO ()
+foo = () <$ pure ()
diff --git a/testsuite/tests/rename/should_compile/T13064.stderr b/testsuite/tests/rename/should_compile/T13064.stderr
new file mode 100644
index 0000000000..3175a8563f
--- /dev/null
+++ b/testsuite/tests/rename/should_compile/T13064.stderr
@@ -0,0 +1,3 @@
+
+T13064.hs:5:1: warning: [-Wunused-imports (in -Wextra)]
+ The import of ‘pure’ from module ‘Prelude’ is redundant
diff --git a/testsuite/tests/rename/should_compile/T4239.stdout b/testsuite/tests/rename/should_compile/T4239.stdout
index a1f53d2c9e..d8f8909bc3 100644
--- a/testsuite/tests/rename/should_compile/T4239.stdout
+++ b/testsuite/tests/rename/should_compile/T4239.stdout
@@ -1 +1 @@
-import T4239A ( (·), type (:+++)((:---), X, (:+++)) )
+import T4239A ( (·), type (:+++)((:---), (:+++), X) )
diff --git a/testsuite/tests/rename/should_compile/all.T b/testsuite/tests/rename/should_compile/all.T
index a3f862f8a4..86f04d0ea9 100644
--- a/testsuite/tests/rename/should_compile/all.T
+++ b/testsuite/tests/rename/should_compile/all.T
@@ -161,3 +161,4 @@ test('T14881', [], multimod_compile, ['T14881', '-W'])
test('T14487', [], multimod_compile, ['T14487', '-v0'])
test('T14747', [], multimod_compile, ['T14747', '-v0'])
test('T15149', [], multimod_compile, ['T15149', '-v0'])
+test('T13064', normal, compile, [''])