diff options
author | Simon Peyton Jones <simonpj@microsoft.com> | 2011-08-02 18:04:22 +0100 |
---|---|---|
committer | Simon Peyton Jones <simonpj@microsoft.com> | 2011-08-02 18:04:22 +0100 |
commit | 8212e0d3e8c3edc90da3f349643cbcdb0a539d3c (patch) | |
tree | 4885dab55fae58e86cbbc06b35b28dd5d18a8d8b /compiler/rename/RnNames.lhs | |
parent | 034b5e95c4c3194e4a6343867b0a45f8037f1c1d (diff) | |
parent | bcfa64ac0d3167f765a632a721d6f6b741cd1c8a (diff) | |
download | haskell-8212e0d3e8c3edc90da3f349643cbcdb0a539d3c.tar.gz |
Merge branch 'master' of http://darcs.haskell.org/ghc
Diffstat (limited to 'compiler/rename/RnNames.lhs')
-rw-r--r-- | compiler/rename/RnNames.lhs | 65 |
1 files changed, 26 insertions, 39 deletions
diff --git a/compiler/rename/RnNames.lhs b/compiler/rename/RnNames.lhs index ab4c1d08d1..9e09751c04 100644 --- a/compiler/rename/RnNames.lhs +++ b/compiler/rename/RnNames.lhs @@ -20,8 +20,6 @@ import RnEnv import RnHsDoc ( rnHsDoc ) import LoadIface ( loadSrcInterface ) import TcRnMonad - -import HeaderInfo ( mkPrelImports ) import PrelNames import Module import Name @@ -131,29 +129,21 @@ with yes we have gone with no for now. \begin{code} -rnImports :: SrcSpan -> [LImportDecl RdrName] - -> RnM ([LImportDecl Name], GlobalRdrEnv, ImportAvails, AnyHpcUsage) +rnImports :: [LImportDecl RdrName] + -> RnM ([LImportDecl Name], GlobalRdrEnv, ImportAvails, AnyHpcUsage) -rnImports prel_imp_loc imports +rnImports imports -- PROCESS IMPORT DECLS -- Do the non {- SOURCE -} ones first, so that we get a helpful -- warning for {- SOURCE -} ones that are unnecessary = do this_mod <- getModule - implicit_prelude <- xoptM Opt_ImplicitPrelude - let prel_imports = mkPrelImports (moduleName this_mod) prel_imp_loc - implicit_prelude imports - (source, ordinary) = partition is_source_import imports - is_source_import (L _ (ImportDecl _ _ is_boot _ _ _ _)) = is_boot - - ifWOptM Opt_WarnImplicitPrelude $ - when (notNull prel_imports) $ addWarn (implicitPreludeWarn) - - stuff1 <- mapM (rnImportDecl this_mod True) prel_imports - stuff2 <- mapM (rnImportDecl this_mod False) ordinary - stuff3 <- mapM (rnImportDecl this_mod False) source + let (source, ordinary) = partition is_source_import imports + is_source_import d = ideclSource (unLoc d) + stuff1 <- mapM (rnImportDecl this_mod) ordinary + stuff2 <- mapM (rnImportDecl this_mod) source -- Safe Haskell: See Note [Tracking Trust Transitively] let (decls, rdr_env, imp_avails, hpc_usage) = - combine (stuff1 ++ stuff2 ++ stuff3) + combine (stuff1 ++ stuff2) return (decls, rdr_env, imp_avails, hpc_usage) where @@ -168,15 +158,15 @@ rnImports prel_imp_loc imports imp_avails1 `plusImportAvails` imp_avails2, hpc_usage1 || hpc_usage2 ) -rnImportDecl :: Module -> Bool +rnImportDecl :: Module -> LImportDecl RdrName -> RnM (LImportDecl Name, GlobalRdrEnv, ImportAvails, AnyHpcUsage) -rnImportDecl this_mod implicit_prelude - (L loc (ImportDecl { ideclName = loc_imp_mod_name, ideclPkgQual = mb_pkg - , ideclSource = want_boot, ideclSafe = mod_safe - , ideclQualified = qual_only - , ideclAs = as_mod, ideclHiding = imp_details })) +rnImportDecl this_mod + (L loc decl@(ImportDecl { ideclName = loc_imp_mod_name, ideclPkgQual = mb_pkg + , ideclSource = want_boot, ideclSafe = mod_safe + , ideclQualified = qual_only, ideclImplicit = implicit + , ideclAs = as_mod, ideclHiding = imp_details })) = setSrcSpan loc $ do when (isJust mb_pkg) $ do @@ -193,11 +183,11 @@ rnImportDecl this_mod implicit_prelude -- (Opt_WarnMissingImportList also checks for T(..) items -- but that is done in checkDodgyImport below) case imp_details of - Just (False, _) -> return () -- Explicit import list - _ | implicit_prelude -> return () - | qual_only -> return () - | otherwise -> ifWOptM Opt_WarnMissingImportList $ - addWarn (missingImportListWarn imp_mod_name) + Just (False, _) -> return () -- Explicit import list + _ | implicit -> return () -- Do not bleat for implicit imports + | qual_only -> return () + | otherwise -> ifWOptM Opt_WarnMissingImportList $ + addWarn (missingImportListWarn imp_mod_name) iface <- loadSrcInterface doc imp_mod_name want_boot mb_pkg @@ -302,8 +292,8 @@ rnImportDecl this_mod implicit_prelude -- should the import be safe? mod_safe' = mod_safe - || (not implicit_prelude && safeDirectImpsReq dflags) - || (implicit_prelude && safeImplicitImpsReq dflags) + || (not implicit && safeDirectImpsReq dflags) + || (implicit && safeImplicitImpsReq dflags) imports = ImportAvails { imp_mods = unitModuleEnv imp_mod @@ -332,8 +322,8 @@ rnImportDecl this_mod implicit_prelude _ -> return () ) - let new_imp_decl = L loc (ImportDecl loc_imp_mod_name mb_pkg want_boot mod_safe' - qual_only as_mod new_imp_details) + let new_imp_decl = L loc (decl { ideclSafe = mod_safe' + , ideclHiding = new_imp_details }) return (new_imp_decl, gbl_env, imports, mi_hpc iface) ) @@ -1672,8 +1662,9 @@ exportClashErr global_env name1 name2 ie1 ie2 , ppr_export ie2' name2' ] where occ = nameOccName name1 - ppr_export ie name = nest 2 (quotes (ppr ie) <+> ptext (sLit "exports") <+> - quotes (ppr name) <+> pprNameProvenance (get_gre name)) + ppr_export ie name = nest 3 (hang (quotes (ppr ie) <+> ptext (sLit "exports") <+> + quotes (ppr name)) + 2 (pprNameProvenance (get_gre name))) -- get_gre finds a GRE for the Name, so that we can show its provenance get_gre name @@ -1746,10 +1737,6 @@ moduleWarn mod (DeprecatedTxt txt) <+> ptext (sLit "is deprecated:"), nest 2 (vcat (map ppr txt)) ] -implicitPreludeWarn :: SDoc -implicitPreludeWarn - = ptext (sLit "Module `Prelude' implicitly imported") - packageImportErr :: SDoc packageImportErr = ptext (sLit "Package-qualified imports are not enabled; use -XPackageImports") |