Skip to content

driver: Improve -Wunused-packages error message (and simplify implementation)

Matthew Pickering requested to merge wip/t21037 into master

In the past I improved the part of -Wunused-packages which found which packages were used. Now I improve the part which detects which ones were specified. The key innovation is to use the explicitUnits field from UnitState which has the result of resolving the package flags, so we don't need to mess about with the flag arguments from DynFlags anymore.

The output now always includes the package name and version (and the flag which exposed it).

    The following packages were specified via -package or -package-id flags,
    but were not needed for compilation:
      - bytestring-0.11.2.0 (exposed by flag -package bytestring)
      - ghc-9.3 (exposed by flag -package ghc)
      - process-1.6.13.2 (exposed by flag -package process)

Fixes #21307 (closed)

Merge request reports