[project @ 1999-07-05 15:30:25 by simonpj]
[ghc-hetmet.git] / ghc / compiler / rename / Rename.lhs
index 38100f0..ca22b19 100644 (file)
@@ -277,13 +277,10 @@ slurpSourceRefs source_binders source_fvs
                -- No declaration... (already slurped, or local)
            Nothing   -> go decls fvs gates refs
            Just decl -> rnIfaceDecl decl               `thenRn` \ (new_decl, fvs1) ->
-                        let
-                           new_gates = getGates source_fvs new_decl
-                        in
                         go (new_decl : decls)
                            (fvs1 `plusFV` fvs)
-                           (gates `plusFV` new_gates)
-                           (nameSetToList new_gates ++ refs)
+                           (gates `plusFV` getGates source_fvs new_decl)
+                           refs
 
        -- When we find a wired-in name we must load its
        -- home module so that we find any instance decls therein
@@ -312,14 +309,17 @@ but not @Foo@; so we need to chase @Foo@ too.
 
 \begin{code}
 slurpInstDecls decls needed gates
-  | isEmptyFVs gates
-  = returnRn (decls, needed)
-
-  | otherwise
-  = getImportedInstDecls gates                         `thenRn` \ inst_decls ->
-    rnInstDecls decls needed emptyFVs inst_decls       `thenRn` \ (decls1, needed1, gates1) ->
-    slurpInstDecls decls1 needed1 gates1
+  = go decls needed gates gates
   where
+    go decls needed all_gates new_gates
+       | isEmptyFVs new_gates
+       = returnRn (decls, needed)
+
+       | otherwise
+       = getImportedInstDecls all_gates                `thenRn` \ inst_decls ->
+         rnInstDecls decls needed emptyFVs inst_decls  `thenRn` \ (decls1, needed1, new_gates) ->
+         go decls1 needed1 (all_gates `plusFV` new_gates) new_gates
+
     rnInstDecls decls fvs gates []
        = returnRn (decls, fvs, gates)
     rnInstDecls decls fvs gates (d:ds) 
@@ -497,7 +497,7 @@ reportUnusedNames gbl_env avail_env (ExportEnv export_avails _) mentioned_names
                    | sub_name <- nameSetToList used_names,
                      let avail = case lookupNameEnv avail_env sub_name of
                            Just avail -> avail
-                           Nothing -> pprTrace "r.u.n" (ppr sub_name) $
+                           Nothing -> WARN( True, text "reportUnusedName: not in avail_env" <+> ppr sub_name )
                                       Avail sub_name
                    ]