+
+%*********************************************************
+%* *
+\subsection{The main function: rename}
+%* *
+%*********************************************************
+
+\begin{code}
+renameSource :: DynFlags
+ -> HomeIfaceTable -> HomeSymbolTable
+ -> PersistentCompilerState
+ -> Module
+ -> RnMG (Maybe (PrintUnqualified, r))
+ -> IO (PersistentCompilerState, Maybe (PrintUnqualified, r))
+ -- Nothing => some error occurred in the renamer
+
+renameSource dflags hit hst old_pcs this_module thing_inside
+ = do { showPass dflags "Renamer"
+
+ -- Initialise the renamer monad
+ ; (new_pcs, msgs, maybe_rn_stuff) <- initRn dflags hit hst old_pcs this_module thing_inside
+
+ -- Print errors from renaming
+ ; let print_unqual = case maybe_rn_stuff of
+ Just (unqual, _) -> unqual
+ Nothing -> alwaysQualify
+
+ ; printErrorsAndWarnings print_unqual msgs ;
+
+ -- Return results. No harm in updating the PCS
+ ; if errorsFound msgs then