From adbaa9a9e3d952d21be74178e2e4405e0777d456 Mon Sep 17 00:00:00 2001 From: Ryan Scott Date: Fri, 19 Mar 2021 11:39:55 -0400 Subject: Remove unnecessary extendTyVarEnvFVRn function The `extendTyVarEnvFVRn` function does the exact same thing as `bindLocalNamesFV`. I see no meaningful distinction between the two functions, so let's just remove the former (which is only used in a handful of places) in favor of the latter. Historical note: `extendTyVarEnvFVRn` and `bindLocalNamesFV` used to be distinct functions, but their implementations were synchronized in 2004 as a part of commit 20e39e0e07e4a8e9395894b2785d6675e4e3e3b3. --- compiler/GHC/Rename/Bind.hs | 4 ++-- compiler/GHC/Rename/Module.hs | 6 +++--- compiler/GHC/Rename/Utils.hs | 7 +------ 3 files changed, 6 insertions(+), 11 deletions(-) diff --git a/compiler/GHC/Rename/Bind.hs b/compiler/GHC/Rename/Bind.hs index d98c9a05c3..23f201f120 100644 --- a/compiler/GHC/Rename/Bind.hs +++ b/compiler/GHC/Rename/Bind.hs @@ -41,7 +41,7 @@ import GHC.Rename.Pat import GHC.Rename.Names import GHC.Rename.Env import GHC.Rename.Fixity -import GHC.Rename.Utils ( HsDocContext(..), mapFvRn, extendTyVarEnvFVRn +import GHC.Rename.Utils ( HsDocContext(..), mapFvRn , checkDupRdrNames, checkDupRdrNamesN, warnUnusedLocalBinds , checkUnusedRecordWildcard , checkDupAndShadowedNames, bindLocalNamesFV @@ -869,7 +869,7 @@ rnMethodBinds is_cls_decl cls ktv_names binds sigs sig_ctxt | is_cls_decl = ClsDeclCtxt cls | otherwise = InstDeclCtxt bound_nms ; (spec_inst_prags', sip_fvs) <- renameSigs sig_ctxt spec_inst_prags - ; (other_sigs', sig_fvs) <- extendTyVarEnvFVRn ktv_names $ + ; (other_sigs', sig_fvs) <- bindLocalNamesFV ktv_names $ renameSigs sig_ctxt other_sigs -- Rename the bindings RHSs. Again there's an issue about whether the diff --git a/compiler/GHC/Rename/Module.hs b/compiler/GHC/Rename/Module.hs index 4d6734ae38..00482b7c93 100644 --- a/compiler/GHC/Rename/Module.hs +++ b/compiler/GHC/Rename/Module.hs @@ -32,7 +32,7 @@ import GHC.Rename.Env import GHC.Rename.Utils ( HsDocContext(..), mapFvRn, bindLocalNames , checkDupRdrNamesN, bindLocalNamesFV , checkShadowedRdrNames, warnUnusedTypePatterns - , extendTyVarEnvFVRn, newLocalBndrsRn + , newLocalBndrsRn , withHsDocContext, noNestedForallsContextsErr , addNoNestedForallsContextsErr, checkInferredVars ) import GHC.Rename.Unbound ( mkUnboundName, notInScopeErr ) @@ -628,7 +628,7 @@ rnClsInstDecl (ClsInstDecl { cid_poly_ty = inst_ty, cid_binds = mbinds -- Both need to have the instance type variables in scope ; traceRn "rnSrcInstDecl" (ppr inst_ty' $$ ppr ktv_names) ; ((ats', adts'), more_fvs) - <- extendTyVarEnvFVRn ktv_names $ + <- bindLocalNamesFV ktv_names $ do { (ats', at_fvs) <- rnATInstDecls rnTyFamInstDecl cls ktv_names ats ; (adts', adt_fvs) <- rnATInstDecls rnDataFamInstDecl cls ktv_names adts ; return ( (ats', adts'), at_fvs `plusFV` adt_fvs) } @@ -2043,7 +2043,7 @@ rnLDerivStrategy doc mds thing_inside -- (Wrinkle: Derived instances) in GHC.Hs.Type. addNoNestedForallsContextsErr doc (quotes (text "via") <+> text "type") via_body - (thing, fvs2) <- extendTyVarEnvFVRn via_tvs thing_inside + (thing, fvs2) <- bindLocalNamesFV via_tvs thing_inside pure (ViaStrategy via_ty', thing, fvs1 `plusFV` fvs2) inf_err = Just (text "Inferred type variables are not allowed") diff --git a/compiler/GHC/Rename/Utils.hs b/compiler/GHC/Rename/Utils.hs index 5787335514..3db88858e0 100644 --- a/compiler/GHC/Rename/Utils.hs +++ b/compiler/GHC/Rename/Utils.hs @@ -25,7 +25,7 @@ module GHC.Rename.Utils ( bindLocalNames, bindLocalNamesFV, - addNameClashErrRn, extendTyVarEnvFVRn, + addNameClashErrRn, checkInferredVars, noNestedForallsContextsErr, addNoNestedForallsContextsErr @@ -101,11 +101,6 @@ bindLocalNamesFV names enclosed_scope = do { (result, fvs) <- bindLocalNames names enclosed_scope ; return (result, delFVs names fvs) } -------------------------------------- - -extendTyVarEnvFVRn :: [Name] -> RnM (a, FreeVars) -> RnM (a, FreeVars) -extendTyVarEnvFVRn tyvars thing_inside = bindLocalNamesFV tyvars thing_inside - ------------------------------------- checkDupRdrNames :: [LocatedN RdrName] -> RnM () -- Check for duplicated names in a binding group -- cgit v1.2.1