From: simonpj Date: Wed, 25 Sep 2002 11:55:07 +0000 (+0000) Subject: [project @ 2002-09-25 11:55:07 by simonpj] X-Git-Tag: Approx_11550_changesets_converted~1639 X-Git-Url: http://git.megacz.com/?a=commitdiff_plain;h=32c62212b35b2b631f3753d432b508de5c79c783;p=ghc-hetmet.git [project @ 2002-09-25 11:55:07 by simonpj] Better reporting of unused imports --- diff --git a/ghc/compiler/rename/RnNames.lhs b/ghc/compiler/rename/RnNames.lhs index a5b0f84..6b10dd8 100644 --- a/ghc/compiler/rename/RnNames.lhs +++ b/ghc/compiler/rename/RnNames.lhs @@ -681,9 +681,11 @@ reportUnusedNames gbl_env used_names -- from which we have sucked only instance decls -- unused_imp_mods are the directly-imported modules - -- that are not mentioned in minimal_imports + -- that are not mentioned in minimal_imports1 + -- [Note: not 'minimal_imports', because that includes direcly-imported + -- modules even if we use nothing from them; see notes above] unused_imp_mods = [m | m <- direct_import_mods, - not (maybeToBool (lookupFM minimal_imports m)), + not (maybeToBool (lookupFM minimal_imports1 m)), m /= pRELUDE_Name] module_unused :: Module -> Bool @@ -708,9 +710,11 @@ printMinimalImports imps ppr_mod_ie (mod_name, ies) | mod_name == pRELUDE_Name = empty + | null ies -- Nothing except instances comes from here + = ptext SLIT("import") <+> ppr mod_name <> ptext SLIT("() -- Instances only") | otherwise = ptext SLIT("import") <+> ppr mod_name <> - parens (fsep (punctuate comma (map ppr ies))) + parens (fsep (punctuate comma (map ppr ies))) to_ies (mod, avail_env) = mappM to_ie (availEnvElts avail_env) `thenM` \ ies -> returnM (mod, ies)