From 9aaa8971de7e8438ec0854d198f22385e1687076 Mon Sep 17 00:00:00 2001 From: Simon Peyton Jones Date: Tue, 23 Oct 2018 09:10:50 +0100 Subject: Remove unnecessary free-var-set deletion In TcSimplify.neededEvVars, in add_implic_seeds we were deleting the 'givens'; but they are already deleted, so this is a no-op. This patch just remove the redundant delete. --- compiler/typecheck/TcEvidence.hs | 15 +++++++-------- compiler/typecheck/TcSMonad.hs | 4 ++-- compiler/typecheck/TcSimplify.hs | 4 ++-- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/compiler/typecheck/TcEvidence.hs b/compiler/typecheck/TcEvidence.hs index fa1908983a..1d6098dbf5 100644 --- a/compiler/typecheck/TcEvidence.hs +++ b/compiler/typecheck/TcEvidence.hs @@ -399,19 +399,16 @@ data EvBindsVar -- Some Given, some Wanted ebv_tcvs :: IORef CoVarSet - -- The free coercion vars of the (rhss of) the coercion bindings - -- All of these are Wanted - -- - -- Coercions don't actually have bindings - -- because we plug them in-place (via a mutable - -- variable); but we keep their free variables - -- so that we can report unused given constraints + -- The free Given coercion vars needed by Wanted coercions that + -- are solved by filling in their HoleDest in-place. Since they + -- don't appear in ebv_binds, we keep track of their free + -- variables so that we can report unused given constraints -- See Note [Tracking redundant constraints] in TcSimplify } | CoEvBindsVar { -- See Note [Coercion evidence only] - -- See above for comments on ebv_uniq, evb_tcvs + -- See above for comments on ebv_uniq, ebv_tcvs ebv_uniq :: Unique, ebv_tcvs :: IORef CoVarSet } @@ -834,6 +831,8 @@ evTermCoercion tm = case evTermCoercion_maybe tm of ********************************************************************* -} findNeededEvVars :: EvBindMap -> VarSet -> VarSet +-- Find all the Given evidence needed by seeds, +-- looking transitively through binds findNeededEvVars ev_binds seeds = transCloVarSet also_needs seeds where diff --git a/compiler/typecheck/TcSMonad.hs b/compiler/typecheck/TcSMonad.hs index 3e50569633..43e8512d82 100644 --- a/compiler/typecheck/TcSMonad.hs +++ b/compiler/typecheck/TcSMonad.hs @@ -3340,12 +3340,12 @@ setEvBind ev_bind -- | Mark variables as used filling a coercion hole useVars :: CoVarSet -> TcS () -useVars vars +useVars co_vars = do { ev_binds_var <- getTcEvBindsVar ; let ref = ebv_tcvs ev_binds_var ; wrapTcS $ do { tcvs <- TcM.readTcRef ref - ; let tcvs' = tcvs `unionVarSet` vars + ; let tcvs' = tcvs `unionVarSet` co_vars ; TcM.writeTcRef ref tcvs' } } -- | Equalities only diff --git a/compiler/typecheck/TcSimplify.hs b/compiler/typecheck/TcSimplify.hs index 92da1ac2b8..562340f0da 100644 --- a/compiler/typecheck/TcSimplify.hs +++ b/compiler/typecheck/TcSimplify.hs @@ -1775,8 +1775,8 @@ neededEvVars implic@(Implic { ic_given = givens ; return (implic { ic_need_inner = need_inner , ic_need_outer = need_outer }) } where - add_implic_seeds (Implic { ic_need_outer = needs, ic_given = givens }) acc - = (needs `delVarSetList` givens) `unionVarSet` acc + add_implic_seeds (Implic { ic_need_outer = needs }) acc + = needs `unionVarSet` acc needed_ev_bind needed (EvBind { eb_lhs = ev_var , eb_is_given = is_given }) -- cgit v1.2.1