From 5943a1ad1ad1296251c1576722d41df83b0c8380 Mon Sep 17 00:00:00 2001 From: simonpj Date: Mon, 20 Oct 2003 14:02:21 +0000 Subject: [PATCH] [project @ 2003-10-20 14:02:19 by simonpj] Suppress renamer warnings (such as unused variables) when renaming stuff generated by 'deriving' code. --- ghc/compiler/typecheck/TcDeriv.lhs | 5 +++-- ghc/compiler/typecheck/TcRnMonad.lhs | 12 ++++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/ghc/compiler/typecheck/TcDeriv.lhs b/ghc/compiler/typecheck/TcDeriv.lhs index 2f63cf7..012a5d0 100644 --- a/ghc/compiler/typecheck/TcDeriv.lhs +++ b/ghc/compiler/typecheck/TcDeriv.lhs @@ -248,8 +248,9 @@ deriveOrdinaryStuff eqns ; tcg_env <- getGblEnv ; let gen_binds = mkGenericBinds (typeEnvTyCons (tcg_type_env tcg_env)) - -- Rename these extra bindings - ; (rn_binds, _fvs1) <- rnTopMonoBinds (extra_binds `AndMonoBinds` gen_binds) [] + -- Rename these extra bindings, discarding warnings about unused bindings etc + ; (rn_binds, _fvs1) <- discardWarnings $ + rnTopMonoBinds (extra_binds `AndMonoBinds` gen_binds) [] ; let all_binds = rn_binds `ThenBinds` foldr ThenBinds EmptyBinds aux_binds_s diff --git a/ghc/compiler/typecheck/TcRnMonad.lhs b/ghc/compiler/typecheck/TcRnMonad.lhs index 4d2e8bf..c30ead5 100644 --- a/ghc/compiler/typecheck/TcRnMonad.lhs +++ b/ghc/compiler/typecheck/TcRnMonad.lhs @@ -403,6 +403,18 @@ addMessages (m_warns, m_errs) (warns, errs) <- readMutVar errs_var ; writeMutVar errs_var (warns `unionBags` m_warns, errs `unionBags` m_errs) } + +discardWarnings :: TcRn a -> TcRn a +-- Ignore warnings inside the thing inside; +-- used to ignore-unused-variable warnings inside derived code +-- With -dppr-debug, the effects is switched off, so you can still see +-- what warnings derived code would give +discardWarnings thing_inside + = do { errs_var <- newMutVar emptyMessages + ; result <- setErrsVar errs_var thing_inside + ; (_warns, errs) <- readMutVar errs_var + ; addMessages (emptyBag, errs) + ; return result } \end{code} -- 1.7.10.4