[project @ 2001-02-20 09:41:48 by simonpj]
authorsimonpj <unknown>
Tue, 20 Feb 2001 09:41:48 +0000 (09:41 +0000)
committersimonpj <unknown>
Tue, 20 Feb 2001 09:41:48 +0000 (09:41 +0000)
Deprecations [HscTypes, MkIface, Rename, RnEnv, RnIfaces]
~~~~~~~~~~~~
* Arrange that a change in deprecations is treated as a
  hi-file difference.

* Warn about deprecations at the usage site.  This entailed
  changing HscTypes.GlobalRdrEnv to include deprecations.
  While I was at it, I changed the range of GlobalRdrEnv
  to a data type, GlobalRdrElt, instead a of a pair.

ghc/compiler/main/HscTypes.lhs
ghc/compiler/main/MkIface.lhs
ghc/compiler/rename/RnIfaces.lhs

index 228f12c..dff8e23 100644 (file)
@@ -34,7 +34,7 @@ module HscTypes (
        InstEnv, ClsInstEnv, DFunId,
        PackageInstEnv, PackageRuleBase,
 
-       GlobalRdrEnv, RdrAvailInfo, pprGlobalRdrEnv,
+       GlobalRdrEnv, GlobalRdrElt(..), RdrAvailInfo, pprGlobalRdrEnv,
 
        -- Provenance
        Provenance(..), ImportReason(..), 
@@ -328,6 +328,13 @@ lookupDeprec (DeprecAll  txt) name = Just txt
 lookupDeprec (DeprecSome env) name = case lookupNameEnv env name of
                                            Just (_, txt) -> Just txt
                                            Nothing       -> Nothing
+
+instance Eq Deprecations where
+  -- Used when checking whether we need write a new interface
+  NoDeprecs       == NoDeprecs      = True
+  (DeprecAll t1)  == (DeprecAll t2)  = t1 == t2
+  (DeprecSome e1) == (DeprecSome e2) = nameEnvElts e1 == nameEnvElts e2
+  d1             == d2              = False
 \end{code}
 
 
@@ -427,7 +434,6 @@ data PersistentCompilerState
 
         pcs_PRS :: PersistentRenamerState
      }
-
 \end{code}
 
 The @PersistentRenamerState@ persists across successive calls to the
@@ -528,15 +534,18 @@ The GlobalRdrEnv gives maps RdrNames to Names.  There is a separate
 one for each module, corresponding to that module's top-level scope.
 
 \begin{code}
-type GlobalRdrEnv = RdrNameEnv [(Name,Provenance)]     -- The list is because there may be name clashes
-                                                       -- These only get reported on lookup,
-                                                       -- not on construction
+type GlobalRdrEnv = RdrNameEnv [GlobalRdrElt]
+       -- The list is because there may be name clashes
+       -- These only get reported on lookup, not on construction
+
+data GlobalRdrElt = GRE Name Provenance (Maybe DeprecTxt)
+       -- The Maybe DeprecTxt tells whether this name is deprecated
 
 pprGlobalRdrEnv env
   = vcat (map pp (rdrEnvToList env))
   where
     pp (rn, nps) = ppr rn <> colon <+> 
-                  vcat [ppr n <+> pprNameProvenance n p | (n,p) <- nps]
+                  vcat [ppr n <+> pprNameProvenance n p | (GRE n p _) <- nps]
 \end{code}
 
 The "provenance" of something says how it came to be in scope.
index 2061b98..a77ce51 100644 (file)
@@ -29,8 +29,8 @@ import HscTypes               ( VersionInfo(..), ModIface(..), ModDetails(..),
                        )
 
 import CmdLineOpts
-import Id              ( Id, idType, idInfo, isImplicitId, isDictFunId,
-                         idSpecialisation, setIdInfo, isLocalId, idName, hasNoBinding
+import Id              ( idType, idInfo, isImplicitId, isDictFunId,
+                         idSpecialisation, isLocalId, idName, hasNoBinding
                        )
 import Var             ( isId )
 import VarSet
@@ -362,11 +362,13 @@ addVersionInfo Nothing new_iface
 -- No old interface, so definitely write a new one!
   = (new_iface, Just (text "No old interface available"))
 
-addVersionInfo (Just old_iface@(ModIface { mi_version = old_version, 
-                                          mi_decls   = old_decls,
-                                          mi_fixities = old_fixities }))
-              new_iface@(ModIface { mi_decls = new_decls,
-                                    mi_fixities = new_fixities })
+addVersionInfo (Just old_iface@(ModIface { mi_version  = old_version, 
+                                          mi_decls    = old_decls,
+                                          mi_fixities = old_fixities,
+                                          mi_deprecs  = old_deprecs }))
+              new_iface@(ModIface { mi_decls    = new_decls,
+                                    mi_fixities = new_fixities,
+                                    mi_deprecs  = new_deprecs })
 
   | no_output_change && no_usage_change
   = (new_iface, Nothing)
@@ -384,11 +386,12 @@ addVersionInfo (Just old_iface@(ModIface { mi_version = old_version,
                                vers_rules   = bumpVersion no_rule_change   (vers_rules   old_version),
                                vers_decls   = tc_vers }
 
-    no_output_change = no_tc_change && no_rule_change && no_export_change
+    no_output_change = no_tc_change && no_rule_change && no_export_change && no_deprec_change
     no_usage_change  = mi_usages old_iface == mi_usages new_iface
 
     no_export_change = mi_exports old_iface == mi_exports new_iface            -- Kept sorted
     no_rule_change   = dcl_rules old_decls  == dcl_rules  new_decls            -- Ditto
+    no_deprec_change = old_deprecs         == new_deprecs
 
        -- Fill in the version number on the new declarations by looking at the old declarations.
        -- Set the flag if anything changes. 
@@ -399,6 +402,7 @@ addVersionInfo (Just old_iface@(ModIface { mi_version = old_version,
     pp_diffs = vcat [pp_tc_diffs,
                     pp_change no_export_change "Export list",
                     pp_change no_rule_change   "Rules",
+                    pp_change no_deprec_change "Deprecations",
                     pp_change no_usage_change  "Usages"]
     pp_change True  what = empty
     pp_change False what = text what <+> ptext SLIT("changed")
index 32d61d7..a81e8b6 100644 (file)
@@ -6,7 +6,6 @@
 \begin{code}
 module RnIfaces
      (
-       getInterfaceExports,
        recordLocalSlurps, 
        mkImportInfo, 
 
@@ -29,7 +28,7 @@ import RnHsSyn                ( RenamedHsDecl, RenamedTyClDecl,
                          extractHsTyNames, extractHsCtxtTyNames, 
                          tyClDeclFVs, ruleDeclFVs, instDeclFVs
                        )
-import RnHiFiles       ( tryLoadInterface, loadHomeInterface, loadInterface, 
+import RnHiFiles       ( tryLoadInterface, loadHomeInterface, 
                          loadOrphanModules
                        )
 import RnSource                ( rnTyClDecl, rnInstDecl, rnIfaceRuleDecl )
@@ -63,24 +62,6 @@ import Util          ( sortLt )
 
 %*********************************************************
 %*                                                     *
-\subsection{Getting what a module exports}
-%*                                                     *
-%*********************************************************
-
-@getInterfaceExports@ is called only for directly-imported modules.
-
-\begin{code}
-getInterfaceExports :: ModuleName -> WhereFrom -> RnMG (Module, [(ModuleName,Avails)])
-getInterfaceExports mod_name from
-  = loadInterface doc_str mod_name from        `thenRn` \ iface ->
-    returnRn (mi_module iface, mi_exports iface)
-  where
-      doc_str = sep [ppr mod_name, ptext SLIT("is directly imported")]
-\end{code}
-
-
-%*********************************************************
-%*                                                     *
 \subsection{Keeping track of what we've slurped, and version numbers}
 %*                                                     *
 %*********************************************************