Fix unused-import warnings
ClosedPublic

Authored by DavidEichmann on Nov 8 2018, 12:03 PM.

Details

Summary

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 Trac #13064 and Trac #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 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

Diff Detail

Repository
rGHC Glasgow Haskell Compiler
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
DavidEichmann created this revision.Nov 8 2018, 12:03 PM

Update commit message explaining why ieLWrappedName change was reverted.

More commit message fiddling (I'm not sure how arcanist handles this).

  • Bump Cabal, bytestring, containers, and text.
  • Fix unused matches error.

There seems to be some errors when I validate locally. I'm working on this now.

  • Bump Cabal, bytestring, containers, and text.
  • Fix unused matches error.
  • Remove unused imprt after rebase.
  • Fix GHC.Magic validation errors.
  • Fix T4437 by removing DerivingVia from expectedGhcOnlyExtensions. Update comment in GHC.Magic.

Validate now passes locally for me.

This revision was not accepted when it landed; it landed in state Needs Review.Thu, Nov 22, 3:10 PM
Closed by commit rGHC6353efc7694b: Fix unused-import warnings (authored by DavidEichmann, committed by bgamari). · Explain Why
This revision was automatically updated to reflect the committed changes.