summaryrefslogtreecommitdiff
path: root/ghc
diff options
context:
space:
mode:
authorsimonpj <unknown>2002-09-25 11:55:07 +0000
committersimonpj <unknown>2002-09-25 11:55:07 +0000
commit32c62212b35b2b631f3753d432b508de5c79c783 (patch)
tree646a687ffcf58d6eb79653a7ee0abeab9118251f /ghc
parentf3a5e6da3f50e6afdde52988bfabe6ea7b581ac1 (diff)
downloadhaskell-32c62212b35b2b631f3753d432b508de5c79c783.tar.gz
[project @ 2002-09-25 11:55:07 by simonpj]
Better reporting of unused imports
Diffstat (limited to 'ghc')
-rw-r--r--ghc/compiler/rename/RnNames.lhs10
1 files changed, 7 insertions, 3 deletions
diff --git a/ghc/compiler/rename/RnNames.lhs b/ghc/compiler/rename/RnNames.lhs
index a5b0f84864..6b10dd852d 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)