\begin{code}
module RnNames (
rnImports, getLocalNonValBinders,
- rnExports, extendGlobalRdrEnvRn,
+ rnExports, extendGlobalRdrEnvRn,
+ gresFromAvails,
reportUnusedNames, finishWarnings,
) where
when (notNull prel_imports) $ addWarn (implicitPreludeWarn)
)
- stuff1 <- mapM (rnImportDecl this_mod) (prel_imports ++ ordinary)
- stuff2 <- mapM (rnImportDecl this_mod) source
- let (decls, rdr_env, imp_avails,hpc_usage) = combine (stuff1 ++ stuff2)
- return (decls, rdr_env, imp_avails,hpc_usage)
+ stuff1 <- mapM (rnImportDecl this_mod True) prel_imports
+ stuff2 <- mapM (rnImportDecl this_mod False) ordinary
+ stuff3 <- mapM (rnImportDecl this_mod False) source
+ let (decls, rdr_env, imp_avails, hpc_usage) = combine (stuff1 ++ stuff2 ++ stuff3)
+ return (decls, rdr_env, imp_avails, hpc_usage)
where
combine :: [(LImportDecl Name, GlobalRdrEnv, ImportAvails,AnyHpcUsage)]
imp_avails1 `plusImportAvails` imp_avails2,
hpc_usage1 || hpc_usage2)
-rnImportDecl :: Module
+rnImportDecl :: Module -> Bool
-> LImportDecl RdrName
-> RnM (LImportDecl Name, GlobalRdrEnv, ImportAvails,AnyHpcUsage)
-rnImportDecl this_mod (L loc (ImportDecl loc_imp_mod_name mb_pkg want_boot
+rnImportDecl this_mod implicit_prelude (L loc (ImportDecl loc_imp_mod_name mb_pkg want_boot
qual_only as_mod imp_details))
= setSrcSpan loc $ do
imp_mod_name = unLoc loc_imp_mod_name
doc = ppr imp_mod_name <+> ptext (sLit "is directly imported")
+ let isExplicit lie = case unLoc lie of
+ IEThingAll _ -> False
+ _ -> True
+ case imp_details of
+ Just (False, lies)
+ | all isExplicit lies ->
+ return ()
+ _ ->
+ unless implicit_prelude $
+ ifOptM Opt_WarnMissingImportList (addWarn (missingImportListWarn imp_mod_name))
+
iface <- loadSrcInterface doc imp_mod_name want_boot mb_pkg
-- Compiler sanity check: if the import didn't say
; val_names <- mapM new_simple val_bndrs
; return (val_names ++ tc_names ++ ti_names) }
where
- mod = tcg_mod gbl_env
is_hs_boot = isHsBoot (tcg_src gbl_env) ;
for_hs_bndrs :: [Located RdrName]
new_simple :: Located RdrName -> RnM (GenAvailInfo Name)
new_simple rdr_name = do
- nm <- newTopSrcBinder mod rdr_name
+ nm <- newTopSrcBinder rdr_name
return (Avail nm)
new_tc tc_decl -- NOT for type/data instances
- = do { main_name <- newTopSrcBinder mod main_rdr
- ; sub_names <- mapM (newTopSrcBinder mod) sub_rdrs
+ = do { main_name <- newTopSrcBinder main_rdr
+ ; sub_names <- mapM newTopSrcBinder sub_rdrs
; return (AvailTC main_name (main_name : sub_names)) }
where
(main_rdr : sub_rdrs) = hsTyClDeclBinders tc_decl
new_ti tc_name_env ti_decl -- ONLY for type/data instances
= do { main_name <- lookupFamInstDeclBndr tc_name_env main_rdr
- ; sub_names <- mapM (newTopSrcBinder mod) sub_rdrs
+ ; sub_names <- mapM newTopSrcBinder sub_rdrs
; return (AvailTC main_name sub_names) }
-- main_name is not bound here!
where
nullModuleExport mod
= ptext (sLit "The export item `module") <+> ppr mod <> ptext (sLit "' exports nothing")
+missingImportListWarn :: ModuleName -> SDoc
+missingImportListWarn mod
+ = ptext (sLit "The module") <+> quotes (ppr mod) <+> ptext (sLit "does not have an explicit import list")
+
moduleWarn :: ModuleName -> WarningTxt -> SDoc
moduleWarn mod (WarningTxt txt)
= sep [ ptext (sLit "Module") <+> quotes (ppr mod) <> ptext (sLit ":"),