summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Pickering <matthewtpickering@gmail.com>2022-09-14 11:58:32 +0100
committerMatthew Pickering <matthewtpickering@gmail.com>2022-09-14 13:28:06 +0100
commitda515eca7e4b191dc75f5f78e24e196dfbea9bed (patch)
tree95c78530fe3c2e313a1e15dacd77617b5211f04c
parentdc6af9ed87e619d754bfc385df931c81cba6d93a (diff)
downloadhaskell-wip/unused-imports.tar.gz
Split up -Wunused-imports into three warningswip/unused-imports
This splits up `-Wunused-imports` into three warnings: `-Wunused-explicit-imports`: Warn when an explicitly imported identifier is not used. import Foo (bar) `-Wredundant-imports`: Warn when nothing from an import is used. -- Nothing from Foo is used import Foo `-Wunused-source-imports`: Warn when a source import is unecessary -- Can just `import Foo`. import {-# SOURCE #-} Foo These three flags are implied by `-Wunused-imports` The motiviation for this is that some library authors don't want to always enable `-Wredundant-imports` as it makes downstream library changes introduce warnings in libraries. Fixes #21879 Also fixes #22182 by supporting -Werror=unused-imports and -Werror=unused-binds
-rw-r--r--compiler/GHC/Driver/Errors/Ppr.hs2
-rw-r--r--compiler/GHC/Driver/Flags.hs21
-rw-r--r--compiler/GHC/Driver/Make.hs2
-rw-r--r--compiler/GHC/Driver/Session.hs30
-rw-r--r--compiler/GHC/Rename/Names.hs29
-rw-r--r--testsuite/tests/deriving/should_compile/T17324.stderr2
-rw-r--r--testsuite/tests/ghci/prog018/prog018.stdout2
-rw-r--r--testsuite/tests/module/T1074.stderr2
-rw-r--r--testsuite/tests/module/T11970A.stderr2
-rw-r--r--testsuite/tests/module/mod176.stderr2
-rw-r--r--testsuite/tests/module/mod177.stderr2
-rw-r--r--testsuite/tests/overloadedrecflds/should_fail/overloadedrecfldsfail06.stderr8
-rw-r--r--testsuite/tests/rename/should_compile/T13064.stderr2
-rw-r--r--testsuite/tests/rename/should_compile/T14881.stderr2
-rw-r--r--testsuite/tests/rename/should_compile/rn037.stderr2
-rw-r--r--testsuite/tests/rename/should_compile/rn046.stderr4
-rw-r--r--testsuite/tests/rename/should_fail/T5211.stderr2
-rw-r--r--testsuite/tests/rename/should_fail/T7454.stderr2
-rw-r--r--testsuite/tests/rename/should_fail/T8149.stderr2
-rw-r--r--testsuite/tests/warnings/should_compile/T10637/T10637.stderr2
-rw-r--r--testsuite/tests/warnings/should_compile/T10890/T10890_2.stderr2
21 files changed, 83 insertions, 41 deletions
diff --git a/compiler/GHC/Driver/Errors/Ppr.hs b/compiler/GHC/Driver/Errors/Ppr.hs
index 8f0ffa4a4d..e5aee036c3 100644
--- a/compiler/GHC/Driver/Errors/Ppr.hs
+++ b/compiler/GHC/Driver/Errors/Ppr.hs
@@ -222,7 +222,7 @@ instance Diagnostic DriverMessage where
DriverUnusedPackages{}
-> WarningWithFlag Opt_WarnUnusedPackages
DriverUnnecessarySourceImports{}
- -> WarningWithFlag Opt_WarnUnusedImports
+ -> WarningWithFlag Opt_WarnUnusedSourceImports
DriverDuplicatedModuleDeclaration{}
-> ErrorWithoutFlag
DriverModuleNotFound{}
diff --git a/compiler/GHC/Driver/Flags.hs b/compiler/GHC/Driver/Flags.hs
index fd23d2e81e..279dacc681 100644
--- a/compiler/GHC/Driver/Flags.hs
+++ b/compiler/GHC/Driver/Flags.hs
@@ -18,6 +18,7 @@ module GHC.Driver.Flags
, minusWeverythingOpts
, minusWcompatOpts
, unusedBindsFlags
+ , unusedImportsFlags
)
where
@@ -538,7 +539,9 @@ data WarningFlag =
| Opt_WarnUnusedTopBinds
| Opt_WarnUnusedLocalBinds
| Opt_WarnUnusedPatternBinds
- | Opt_WarnUnusedImports
+ | Opt_WarnUnusedSourceImports
+ | Opt_WarnUnusedExplicitImports
+ | Opt_WarnRedundantImports
| Opt_WarnUnusedMatches
| Opt_WarnUnusedTypePatterns
| Opt_WarnUnusedForalls
@@ -685,7 +688,9 @@ warnFlagNames wflag = case wflag of
Opt_WarnUntickedPromotedConstructors -> "unticked-promoted-constructors" :| []
Opt_WarnUnusedDoBind -> "unused-do-bind" :| []
Opt_WarnUnusedForalls -> "unused-foralls" :| []
- Opt_WarnUnusedImports -> "unused-imports" :| []
+ Opt_WarnUnusedExplicitImports -> "unused-explicit-imports" :| []
+ Opt_WarnUnusedSourceImports -> "unused-source-imports" :| []
+ Opt_WarnRedundantImports -> "redundant-imports" :| []
Opt_WarnUnusedLocalBinds -> "unused-local-binds" :| []
Opt_WarnUnusedMatches -> "unused-matches" :| []
Opt_WarnUnusedPatternBinds -> "unused-pattern-binds" :| []
@@ -738,6 +743,7 @@ warningGroups :: [(String, [WarningFlag])]
warningGroups =
[ ("compat", minusWcompatOpts)
, ("unused-binds", unusedBindsFlags)
+ , ("unused-imports", unusedImportsFlags)
, ("default", standardWarnings)
, ("extra", minusWOpts)
, ("all", minusWallOpts)
@@ -825,7 +831,9 @@ minusWOpts
Opt_WarnUnusedPatternBinds,
Opt_WarnUnusedMatches,
Opt_WarnUnusedForalls,
- Opt_WarnUnusedImports,
+ Opt_WarnUnusedExplicitImports,
+ Opt_WarnUnusedSourceImports,
+ Opt_WarnRedundantImports,
Opt_WarnIncompletePatterns,
Opt_WarnDodgyExports,
Opt_WarnDodgyImports,
@@ -875,3 +883,10 @@ unusedBindsFlags = [ Opt_WarnUnusedTopBinds
, Opt_WarnUnusedLocalBinds
, Opt_WarnUnusedPatternBinds
]
+
+-- | Things you get with -Wunused-binds
+unusedImportsFlags :: [WarningFlag]
+unusedImportsFlags = [ Opt_WarnUnusedExplicitImports
+ , Opt_WarnUnusedSourceImports
+ , Opt_WarnRedundantImports
+ ]
diff --git a/compiler/GHC/Driver/Make.hs b/compiler/GHC/Driver/Make.hs
index d1f9ba0104..9a259d9e96 100644
--- a/compiler/GHC/Driver/Make.hs
+++ b/compiler/GHC/Driver/Make.hs
@@ -1483,7 +1483,7 @@ modNodeMapUnionWith f (ModNodeMap m) (ModNodeMap n) = ModNodeMap (M.unionWith f
warnUnnecessarySourceImports :: GhcMonad m => [SCC ModSummary] -> m ()
warnUnnecessarySourceImports sccs = do
diag_opts <- initDiagOpts <$> getDynFlags
- when (diag_wopt Opt_WarnUnusedImports diag_opts) $ do
+ when (diag_wopt Opt_WarnUnusedSourceImports diag_opts) $ do
let check ms =
let mods_in_this_cycle = map ms_mod_name ms in
[ warn i | m <- ms, i <- ms_home_srcimps m,
diff --git a/compiler/GHC/Driver/Session.hs b/compiler/GHC/Driver/Session.hs
index 9d03c434f6..864e93e35b 100644
--- a/compiler/GHC/Driver/Session.hs
+++ b/compiler/GHC/Driver/Session.hs
@@ -2916,6 +2916,10 @@ dynamic_flags_deps = [
, make_ord_flag defHiddenFlag "fwarn-unused-binds" (NoArg enableUnusedBinds)
, make_ord_flag defHiddenFlag "fno-warn-unused-binds" (NoArg
disableUnusedBinds)
+ , make_ord_flag defFlag "Wunused-imports" (NoArg enableUnusedImports)
+ , make_ord_flag defFlag "Wno-unused-imports" (NoArg disableUnusedImports)
+ , make_ord_flag defHiddenFlag "fwarn-unused-imports" (NoArg enableUnusedImports)
+ , make_ord_flag defHiddenFlag "fno-warn-unused-imports" (NoArg disableUnusedImports)
------ Safe Haskell flags -------------------------------------------
, make_ord_flag defFlag "fpackage-trust" (NoArg setPackageTrust)
@@ -2952,12 +2956,7 @@ dynamic_flags_deps = [
++ [ (NotDeprecated, unrecognisedWarning "W"),
(Deprecated, unrecognisedWarning "fwarn-"),
(Deprecated, unrecognisedWarning "fno-warn-") ]
- ++ [ make_ord_flag defFlag "Werror=compat"
- (NoArg (mapM_ setWErrorFlag minusWcompatOpts))
- , make_ord_flag defFlag "Wno-error=compat"
- (NoArg (mapM_ unSetFatalWarningFlag minusWcompatOpts))
- , make_ord_flag defFlag "Wwarn=compat"
- (NoArg (mapM_ unSetFatalWarningFlag minusWcompatOpts)) ]
+ ++ concatMap werrorFlagGroup ["compat", "unused-binds", "unused-imports"]
++ map (mkFlag turnOn "f" setExtensionFlag ) fLangFlagsDeps
++ map (mkFlag turnOff "fno-" unSetExtensionFlag) fLangFlagsDeps
++ map (mkFlag turnOn "X" setExtensionFlag ) xFlagsDeps
@@ -2965,6 +2964,16 @@ dynamic_flags_deps = [
++ map (mkFlag turnOn "X" setLanguage ) languageFlagsDeps
++ map (mkFlag turnOn "X" setSafeHaskell ) safeHaskellFlagsDeps
+werrorFlagGroup :: String -> [(Deprecation, Flag (CmdLineP DynFlags))]
+werrorFlagGroup name =
+ let Just opts = lookup name warningGroups
+ in [ make_ord_flag defFlag ("Werror=" ++ name)
+ (NoArg (mapM_ setWErrorFlag opts))
+ , make_ord_flag defFlag ("Wno-error=" ++ name)
+ (NoArg (mapM_ unSetFatalWarningFlag opts))
+ , make_ord_flag defFlag ("Wwarn=" ++ name)
+ (NoArg (mapM_ unSetFatalWarningFlag opts)) ]
+
-- | This is where we handle unrecognised warning flags. We only issue a warning
-- if -Wunrecognised-warning-flags is set. See #11429 for context.
unrecognisedWarning :: String -> Flag (CmdLineP DynFlags)
@@ -3291,7 +3300,9 @@ wWarningFlagsDeps = mconcat [
warnSpec Opt_WarnUntickedPromotedConstructors,
warnSpec Opt_WarnUnusedDoBind,
warnSpec Opt_WarnUnusedForalls,
- warnSpec Opt_WarnUnusedImports,
+ warnSpec Opt_WarnUnusedSourceImports,
+ warnSpec Opt_WarnUnusedExplicitImports,
+ warnSpec Opt_WarnRedundantImports,
warnSpec Opt_WarnUnusedLocalBinds,
warnSpec Opt_WarnUnusedMatches,
warnSpec Opt_WarnUnusedPatternBinds,
@@ -4034,6 +4045,11 @@ enableUnusedBinds = mapM_ setWarningFlag unusedBindsFlags
disableUnusedBinds :: DynP ()
disableUnusedBinds = mapM_ unSetWarningFlag unusedBindsFlags
+enableUnusedImports, disableUnusedImports :: DynP ()
+enableUnusedImports = mapM_ setWarningFlag unusedImportsFlags
+disableUnusedImports = mapM_ unSetWarningFlag unusedImportsFlags
+
+
-- | Things you get with `-dlint`.
enableDLint :: DynP ()
enableDLint = do
diff --git a/compiler/GHC/Rename/Names.hs b/compiler/GHC/Rename/Names.hs
index dce4daa562..ace32e7314 100644
--- a/compiler/GHC/Rename/Names.hs
+++ b/compiler/GHC/Rename/Names.hs
@@ -1725,8 +1725,8 @@ warnUnusedImportDecls gbl_env hsc_src
(vcat [ text "Uses:" <+> ppr uses
, text "Import usage" <+> ppr usage])
- ; whenWOptM Opt_WarnUnusedImports $
- mapM_ (warnUnusedImport Opt_WarnUnusedImports fld_env) usage
+ ; unused_flags <- mkUnusedImportFlags
+ ; mapM_ (warnUnusedImport unused_flags fld_env) usage
; whenGOptM Opt_D_dump_minimal_imports $
printMinimalImports hsc_src usage }
@@ -1828,9 +1828,15 @@ mkImportMap gres
best_imp_spec = bestImport (bagToList imp_specs)
add _ gres = gre : gres
-warnUnusedImport :: WarningFlag -> NameEnv (FieldLabelString, Parent)
+data UnusedImportFlags = UnusedImportFlags { warnRedundantImports :: Bool, warnUnusedExplicitImports :: Bool }
+
+mkUnusedImportFlags :: RnM UnusedImportFlags
+mkUnusedImportFlags = UnusedImportFlags <$> woptM Opt_WarnRedundantImports <*> woptM Opt_WarnUnusedExplicitImports
+
+warnUnusedImport :: UnusedImportFlags -> NameEnv (FieldLabelString, Parent)
-> ImportDeclUsage -> RnM ()
-warnUnusedImport flag fld_env (L loc decl, used, unused)
+warnUnusedImport (UnusedImportFlags False False) _ _ = return ()
+warnUnusedImport flags fld_env (L loc decl, used, unused)
-- Do not warn for 'import M()'
| Just (Exactly, L _ []) <- ideclImportList decl
@@ -1844,8 +1850,9 @@ warnUnusedImport flag fld_env (L loc decl, used, unused)
-- Nothing used; drop entire declaration
| null used
+ , warnRedundantImports flags
= let dia = mkTcRnUnknownMessage $
- mkPlainDiagnostic (WarningWithFlag flag) noHints msg1
+ mkPlainDiagnostic (WarningWithFlag Opt_WarnRedundantImports) noHints msg1
in addDiagnosticAt (locA loc) dia
-- Everything imported is used; nop
@@ -1854,17 +1861,21 @@ warnUnusedImport flag fld_env (L loc decl, used, unused)
-- Only one import is unused, with `SrcSpan` covering only the unused item instead of
-- the whole import statement
- | Just (_, L _ imports) <- ideclImportList decl
+ | warnUnusedExplicitImports flags
+ , Just (_, L _ imports) <- ideclImportList decl
, length unused == 1
, Just (L loc _) <- find (\(L _ ie) -> ((ieName ie) :: Name) `elem` unused) imports
- = let dia = mkTcRnUnknownMessage $ mkPlainDiagnostic (WarningWithFlag flag) noHints msg2
+ = let dia = mkTcRnUnknownMessage $ mkPlainDiagnostic (WarningWithFlag Opt_WarnUnusedExplicitImports) noHints msg2
in addDiagnosticAt (locA loc) dia
-- Some imports are unused
- | otherwise
- = let dia = mkTcRnUnknownMessage $ mkPlainDiagnostic (WarningWithFlag flag) noHints msg2
+ | warnUnusedExplicitImports flags
+ = let dia = mkTcRnUnknownMessage $ mkPlainDiagnostic (WarningWithFlag Opt_WarnUnusedExplicitImports) noHints msg2
in addDiagnosticAt (locA loc) dia
+ | otherwise
+ = return ()
+
where
msg1 = vcat [ pp_herald <+> quotes pp_mod <+> is_redundant
, nest 2 (text "except perhaps to import instances from"
diff --git a/testsuite/tests/deriving/should_compile/T17324.stderr b/testsuite/tests/deriving/should_compile/T17324.stderr
index 54e6534462..0c1d314f57 100644
--- a/testsuite/tests/deriving/should_compile/T17324.stderr
+++ b/testsuite/tests/deriving/should_compile/T17324.stderr
@@ -1,4 +1,4 @@
-T17324.hs:8:1: warning: [-Wunused-imports (in -Wextra)]
+T17324.hs:8:1: warning: [-Wunused-explicit-imports (in -Wextra, -Wunused-imports)]
The import of ‘Dual, Product, Sum’
from module ‘Data.Monoid’ is redundant
diff --git a/testsuite/tests/ghci/prog018/prog018.stdout b/testsuite/tests/ghci/prog018/prog018.stdout
index da160be432..9847a2117a 100644
--- a/testsuite/tests/ghci/prog018/prog018.stdout
+++ b/testsuite/tests/ghci/prog018/prog018.stdout
@@ -9,7 +9,7 @@ A.hs:8:15: warning: [-Wunused-matches (in -Wextra)]
Defined but not used: ‘x’
[2 of 3] Compiling B ( B.hs, interpreted )
-B.hs:7:1: warning: [-Wunused-imports (in -Wextra)]
+B.hs:7:1: warning: [-Wredundant-imports (in -Wextra, -Wunused-imports)]
The import of ‘Data.Tuple’ is redundant
except perhaps to import instances from ‘Data.Tuple’
To import instances alone, use: import Data.Tuple()
diff --git a/testsuite/tests/module/T1074.stderr b/testsuite/tests/module/T1074.stderr
index 14e56e8c07..c4563bd9e6 100644
--- a/testsuite/tests/module/T1074.stderr
+++ b/testsuite/tests/module/T1074.stderr
@@ -1,5 +1,5 @@
-T1074.hs:6:1: warning: [-Wunused-imports (in -Wextra)]
+T1074.hs:6:1: warning: [-Wredundant-imports (in -Wextra, -Wunused-imports)]
The qualified import of ‘Control.Monad.Reader’ is redundant
except perhaps to import instances from ‘Control.Monad.Reader’
To import instances alone, use: import Control.Monad.Reader()
diff --git a/testsuite/tests/module/T11970A.stderr b/testsuite/tests/module/T11970A.stderr
index 6b478a7335..49e0d8d49c 100644
--- a/testsuite/tests/module/T11970A.stderr
+++ b/testsuite/tests/module/T11970A.stderr
@@ -1,5 +1,5 @@
[1 of 2] Compiling T11970A1 ( T11970A1.hs, T11970A1.o )
[2 of 2] Compiling T11970A ( T11970A.hs, T11970A.o )
-T11970A.hs:3:1: warning: [-Wunused-imports (in -Wextra)]
+T11970A.hs:3:1: warning: [-Wunused-explicit-imports (in -Wextra, -Wunused-imports)]
The import of ‘Fail(b)’ from module ‘T11970A1’ is redundant
diff --git a/testsuite/tests/module/mod176.stderr b/testsuite/tests/module/mod176.stderr
index 20ccfc1ffb..3cc6d6ec3d 100644
--- a/testsuite/tests/module/mod176.stderr
+++ b/testsuite/tests/module/mod176.stderr
@@ -1,4 +1,4 @@
-mod176.hs:4:1: warning: [-Wunused-imports (in -Wextra)]
+mod176.hs:4:1: warning: [-Wunused-explicit-imports (in -Wextra, -Wunused-imports)]
The import of ‘Monad, return’
from module ‘Control.Monad’ is redundant
diff --git a/testsuite/tests/module/mod177.stderr b/testsuite/tests/module/mod177.stderr
index ea9306aa76..ed5d950aca 100644
--- a/testsuite/tests/module/mod177.stderr
+++ b/testsuite/tests/module/mod177.stderr
@@ -1,5 +1,5 @@
-mod177.hs:4:1: warning: [-Wunused-imports (in -Wextra)]
+mod177.hs:4:1: warning: [-Wredundant-imports (in -Wextra, -Wunused-imports)]
The import of ‘Data.Maybe’ is redundant
except perhaps to import instances from ‘Data.Maybe’
To import instances alone, use: import Data.Maybe()
diff --git a/testsuite/tests/overloadedrecflds/should_fail/overloadedrecfldsfail06.stderr b/testsuite/tests/overloadedrecflds/should_fail/overloadedrecfldsfail06.stderr
index 7567a038b4..adcdde354f 100644
--- a/testsuite/tests/overloadedrecflds/should_fail/overloadedrecfldsfail06.stderr
+++ b/testsuite/tests/overloadedrecflds/should_fail/overloadedrecfldsfail06.stderr
@@ -10,20 +10,20 @@ OverloadedRecFldsFail06_A.hs:9:59: warning: [-Wunused-top-binds (in -Wextra, -Wu
Defined but not used: ‘used_locally’
[2 of 3] Compiling Main ( overloadedrecfldsfail06.hs, overloadedrecfldsfail06.o )
-overloadedrecfldsfail06.hs:7:1: error: [-Wunused-imports (in -Wextra), Werror=unused-imports]
+overloadedrecfldsfail06.hs:7:1: error: [-Wunused-explicit-imports (in -Wextra, -Wunused-imports), Werror=unused-explicit-imports]
The import of ‘Unused(unused), V(x), U(y), MkV, Unused’
from module ‘OverloadedRecFldsFail06_A’ is redundant
-overloadedrecfldsfail06.hs:8:1: error: [-Wunused-imports (in -Wextra), Werror=unused-imports]
+overloadedrecfldsfail06.hs:8:1: error: [-Wredundant-imports (in -Wextra, -Wunused-imports), Werror=redundant-imports]
The qualified import of ‘OverloadedRecFldsFail06_A’ is redundant
except perhaps to import instances from ‘OverloadedRecFldsFail06_A’
To import instances alone, use: import OverloadedRecFldsFail06_A()
-overloadedrecfldsfail06.hs:9:1: error: [-Wunused-imports (in -Wextra), Werror=unused-imports]
+overloadedrecfldsfail06.hs:9:1: error: [-Wunused-explicit-imports (in -Wextra, -Wunused-imports), Werror=unused-explicit-imports]
The qualified import of ‘V(y)’
from module ‘OverloadedRecFldsFail06_A’ is redundant
-overloadedrecfldsfail06.hs:10:1: error: [-Wunused-imports (in -Wextra), Werror=unused-imports]
+overloadedrecfldsfail06.hs:10:1: error: [-Wunused-explicit-imports (in -Wextra, -Wunused-imports), Werror=unused-explicit-imports]
The qualified import of ‘U(x), U’
from module ‘OverloadedRecFldsFail06_A’ is redundant
diff --git a/testsuite/tests/rename/should_compile/T13064.stderr b/testsuite/tests/rename/should_compile/T13064.stderr
index a94e5b70d5..2e8cc16236 100644
--- a/testsuite/tests/rename/should_compile/T13064.stderr
+++ b/testsuite/tests/rename/should_compile/T13064.stderr
@@ -1,3 +1,3 @@
-T13064.hs:5:21: warning: [-Wunused-imports (in -Wextra)]
+T13064.hs:5:21: warning: [-Wunused-explicit-imports (in -Wextra, -Wunused-imports)]
The import of ‘pure’ from module ‘Prelude’ is redundant
diff --git a/testsuite/tests/rename/should_compile/T14881.stderr b/testsuite/tests/rename/should_compile/T14881.stderr
index bfb6ca913f..44906dd6fb 100644
--- a/testsuite/tests/rename/should_compile/T14881.stderr
+++ b/testsuite/tests/rename/should_compile/T14881.stderr
@@ -1,6 +1,6 @@
[1 of 2] Compiling T14881Aux ( T14881Aux.hs, T14881Aux.o )
[2 of 2] Compiling T14881 ( T14881.hs, T14881.o )
-T14881.hs:3:1: warning: [-Wunused-imports (in -Wextra)]
+T14881.hs:3:1: warning: [-Wunused-explicit-imports (in -Wextra, -Wunused-imports)]
The qualified import of ‘adjust, length, L(tail), L(x)’
from module ‘T14881Aux’ is redundant
diff --git a/testsuite/tests/rename/should_compile/rn037.stderr b/testsuite/tests/rename/should_compile/rn037.stderr
index c386e896de..cfd3e04877 100644
--- a/testsuite/tests/rename/should_compile/rn037.stderr
+++ b/testsuite/tests/rename/should_compile/rn037.stderr
@@ -1,5 +1,5 @@
-rn037.hs:3:1: warning: [-Wunused-imports (in -Wextra)]
+rn037.hs:3:1: warning: [-Wredundant-imports (in -Wextra, -Wunused-imports)]
The import of ‘Data.Tuple’ is redundant
except perhaps to import instances from ‘Data.Tuple’
To import instances alone, use: import Data.Tuple()
diff --git a/testsuite/tests/rename/should_compile/rn046.stderr b/testsuite/tests/rename/should_compile/rn046.stderr
index e1947d914d..681b6630d9 100644
--- a/testsuite/tests/rename/should_compile/rn046.stderr
+++ b/testsuite/tests/rename/should_compile/rn046.stderr
@@ -1,8 +1,8 @@
-rn046.hs:2:1: warning: [-Wunused-imports (in -Wextra)]
+rn046.hs:2:1: warning: [-Wredundant-imports (in -Wextra, -Wunused-imports)]
The import of ‘Data.List’ is redundant
except perhaps to import instances from ‘Data.List’
To import instances alone, use: import Data.List()
-rn046.hs:3:19: warning: [-Wunused-imports (in -Wextra)]
+rn046.hs:3:19: warning: [-Wunused-explicit-imports (in -Wextra, -Wunused-imports)]
The import of ‘ord’ from module ‘Data.Char’ is redundant
diff --git a/testsuite/tests/rename/should_fail/T5211.stderr b/testsuite/tests/rename/should_fail/T5211.stderr
index dc02ab4085..6d6a84fc5d 100644
--- a/testsuite/tests/rename/should_fail/T5211.stderr
+++ b/testsuite/tests/rename/should_fail/T5211.stderr
@@ -1,5 +1,5 @@
-T5211.hs:5:1: warning: [-Wunused-imports (in -Wextra)]
+T5211.hs:5:1: warning: [-Wredundant-imports (in -Wextra, -Wunused-imports)]
The qualified import of ‘Foreign.Storable’ is redundant
except perhaps to import instances from ‘Foreign.Storable’
To import instances alone, use: import Foreign.Storable()
diff --git a/testsuite/tests/rename/should_fail/T7454.stderr b/testsuite/tests/rename/should_fail/T7454.stderr
index ba9666cf35..dbceb03c47 100644
--- a/testsuite/tests/rename/should_fail/T7454.stderr
+++ b/testsuite/tests/rename/should_fail/T7454.stderr
@@ -1,3 +1,3 @@
-T7454.hs:5:23: warning: [-Wunused-imports (in -Wextra)]
+T7454.hs:5:23: warning: [-Wunused-explicit-imports (in -Wextra, -Wunused-imports)]
The import of ‘Arrow’ from module ‘Control.Arrow’ is redundant
diff --git a/testsuite/tests/rename/should_fail/T8149.stderr b/testsuite/tests/rename/should_fail/T8149.stderr
index 33b45e9598..a095e3d7a0 100644
--- a/testsuite/tests/rename/should_fail/T8149.stderr
+++ b/testsuite/tests/rename/should_fail/T8149.stderr
@@ -1,4 +1,4 @@
-T8149.hs:5:36: warning: [-Wunused-imports (in -Wextra)]
+T8149.hs:5:36: warning: [-Wunused-explicit-imports (in -Wextra, -Wunused-imports)]
The import of ‘WriterT’
from module ‘Control.Monad.Trans.Writer’ is redundant
diff --git a/testsuite/tests/warnings/should_compile/T10637/T10637.stderr b/testsuite/tests/warnings/should_compile/T10637/T10637.stderr
index d0b53d1ff2..e61e78496c 100644
--- a/testsuite/tests/warnings/should_compile/T10637/T10637.stderr
+++ b/testsuite/tests/warnings/should_compile/T10637/T10637.stderr
@@ -1,3 +1,3 @@
-T10637.hs:3:23: warning: [GHC-88907] [-Wunused-imports (in -Wextra)]
+T10637.hs:3:23: warning: [GHC-88907] [-Wunused-source-imports (in -Wextra, -Wunused-imports)]
{-# SOURCE #-} unnecessary in import of ‘A’
diff --git a/testsuite/tests/warnings/should_compile/T10890/T10890_2.stderr b/testsuite/tests/warnings/should_compile/T10890/T10890_2.stderr
index d676ca9556..7763f72d43 100644
--- a/testsuite/tests/warnings/should_compile/T10890/T10890_2.stderr
+++ b/testsuite/tests/warnings/should_compile/T10890/T10890_2.stderr
@@ -1,5 +1,5 @@
-T10890_2.hs:12:1: warning: [-Wunused-imports (in -Wextra)]
+T10890_2.hs:12:1: warning: [-Wredundant-imports (in -Wextra, -Wunused-imports)]
The import of ‘T10890_2B’ is redundant
except perhaps to import instances from ‘T10890_2B’
To import instances alone, use: import T10890_2B()