[project @ 2002-09-27 08:20:43 by simonpj]
[ghc-hetmet.git] / ghc / compiler / rename / RnNames.lhs
index a5b0f84..8eef805 100644 (file)
@@ -40,7 +40,6 @@ import HscTypes               ( Provenance(..), ImportReason(..), GlobalRdrEnv,
                          GlobalRdrElt(..), unQualInScope, isLocalGRE
                        )
 import RdrName         ( rdrNameOcc, setRdrNameSpace, emptyRdrEnv, foldRdrEnv, isQual )
-import SrcLoc          ( noSrcLoc )
 import Outputable
 import Maybes          ( maybeToBool, catMaybes )
 import ListSetOps      ( removeDups )
@@ -681,9 +680,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 +709,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)