diff options
author | Ryan Scott <ryan.gl.scott@gmail.com> | 2021-03-19 11:39:55 -0400 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2021-03-21 19:40:02 -0400 |
commit | adbaa9a9e3d952d21be74178e2e4405e0777d456 (patch) | |
tree | b214f4c3032b0e6bcd92699f39b45fca5b2fe7e1 | |
parent | 6a375b5365b3d0c74198dbd702beda6632890454 (diff) | |
download | haskell-adbaa9a9e3d952d21be74178e2e4405e0777d456.tar.gz |
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.
-rw-r--r-- | compiler/GHC/Rename/Bind.hs | 4 | ||||
-rw-r--r-- | compiler/GHC/Rename/Module.hs | 6 | ||||
-rw-r--r-- | 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 @@ -102,11 +102,6 @@ bindLocalNamesFV 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 checkDupRdrNames rdr_names_w_loc |