Note [CorePrepEnv: cpe_subst]

GHC/CoreToStg/Prep.hs:2463 compiler 1 ticket

CorePrepEnv carries a substitution `Subst` in the `cpe_subst1 field,
for these reasons:

1. To support cloning of local Ids so that they are
   all unique (see Note [Cloning in CorePrep])

2. To support beta-reduction of runRW, see Note [runRW magic] and
   Note [runRW arg].

3. To let us inline trivial RHSs of non top-level let-bindings,
   see Note [lazyId magic], Note [Inlining in CorePrep] (#12076)

   Note that, if (y::forall a. a->a), we could get
      x = lazy @(forall a.a) y @Bool
   so after eliminating `lazy`, we need to replace occurrences of `x` with
   `y @Bool`, not just `y`.  Situations like this can easily arise with
   higher-rank types; thus, `cpe_subst` must map to CoreExprs, not Ids, which
   oc course it does

4. The TyCoVar part of the substitution is used only for
   Note [Cloning CoVars and TyVars]

References 6

Referenced by 1