From 3d3622fc3207932eb21950baac434996165191aa Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?H=C3=A9cate=20Moonlight?=
 <Kleidukos@users.noreply.github.com>
Date: Tue, 13 Feb 2024 22:53:38 +0100
Subject: [PATCH] Add -Wunused-packages to the packages (#9663)

* Add -Wunused-packages to the packages

Cabal, Cabal-syntax, cabal-install, cabal-install-solver

* Remove unused text dependency

* remove unguarded warning

* Remove 8.10 condition for unused-packages

---------

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
---
 Cabal-syntax/Cabal-syntax.cabal                 | 3 +++
 Cabal/Cabal.cabal                               | 4 +++-
 cabal-install-solver/cabal-install-solver.cabal | 1 +
 cabal-install/cabal-install.cabal               | 2 ++
 4 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/Cabal-syntax/Cabal-syntax.cabal b/Cabal-syntax/Cabal-syntax.cabal
index d4e1a75f9fc..9d402b0c8d5 100644
--- a/Cabal-syntax/Cabal-syntax.cabal
+++ b/Cabal-syntax/Cabal-syntax.cabal
@@ -53,6 +53,9 @@ library
   if impl(ghc >= 8.0) && impl(ghc < 8.8)
     ghc-options: -Wnoncanonical-monadfail-instances
 
+  if impl(ghc >= 8.10)
+    ghc-options: -Wunused-packages
+
   build-tool-depends: alex:alex
 
   exposed-modules:
diff --git a/Cabal/Cabal.cabal b/Cabal/Cabal.cabal
index 6f1586cffd0..42f0a298984 100644
--- a/Cabal/Cabal.cabal
+++ b/Cabal/Cabal.cabal
@@ -59,6 +59,9 @@ library
   if impl(ghc >= 8.0) && impl(ghc < 8.8)
     ghc-options: -Wnoncanonical-monadfail-instances
 
+  if impl(ghc >= 8.10)
+    ghc-options: -Wunused-packages
+
   exposed-modules:
     Distribution.Backpack.Configure
     Distribution.Backpack.ComponentsGraph
@@ -306,7 +309,6 @@ library
     -- See also https://github.com/ekmett/transformers-compat/issues/35
     transformers (>= 0.3      && < 0.4) || (>=0.4.1.0 && <0.7),
     mtl           >= 2.1      && < 2.4,
-    text         (>= 1.2.3.0  && < 1.3) || (>= 2.0 && < 2.2),
     parsec        >= 3.1.13.0 && < 3.2
 
   other-modules:
diff --git a/cabal-install-solver/cabal-install-solver.cabal b/cabal-install-solver/cabal-install-solver.cabal
index 2f1e8d6bdf1..95cb28206ec 100644
--- a/cabal-install-solver/cabal-install-solver.cabal
+++ b/cabal-install-solver/cabal-install-solver.cabal
@@ -42,6 +42,7 @@ library
 
   if impl(ghc <8.8)
     ghc-options: -Wnoncanonical-monadfail-instances
+
   if impl(ghc >=8.10)
     ghc-options: -Wunused-packages
 
diff --git a/cabal-install/cabal-install.cabal b/cabal-install/cabal-install.cabal
index 72764c89eb9..38401ed7adb 100644
--- a/cabal-install/cabal-install.cabal
+++ b/cabal-install/cabal-install.cabal
@@ -40,8 +40,10 @@ Flag lukko
 
 common warnings
     ghc-options: -Wall -Wcompat -Wnoncanonical-monad-instances -Wincomplete-uni-patterns -Wincomplete-record-updates
+
     if impl(ghc < 8.8)
       ghc-options: -Wnoncanonical-monadfail-instances
+
     if impl(ghc >=9.0)
       -- Warning: even though introduced with GHC 8.10, -Wunused-packages
       -- gives false positives with GHC 8.10.