diff options
author | Alp Mestanogullari <alp@well-typed.com> | 2020-06-01 20:52:19 +0200 |
---|---|---|
committer | Alp Mestanogullari <alp@well-typed.com> | 2020-06-01 20:52:19 +0200 |
commit | a779f7a9f5da8a59305ce917ca567e94837f7b27 (patch) | |
tree | 1cb1aab73d5aba855fdd5ccb6bf2b619fed3b32f | |
parent | 99edec6764e667153b3bbacf4c0a053b48acdfbc (diff) | |
download | haskell-a779f7a9f5da8a59305ce917ca567e94837f7b27.tar.gz |
first attempt at decreasing allocations furtherwip/alp/18379
-rw-r--r-- | compiler/GHC/Tc/Gen/Expr.hs | 12 | ||||
-rw-r--r-- | compiler/GHC/Types/SrcLoc.hs | 2 |
2 files changed, 11 insertions, 3 deletions
diff --git a/compiler/GHC/Tc/Gen/Expr.hs b/compiler/GHC/Tc/Gen/Expr.hs index e1998d426f..5f611eaf6f 100644 --- a/compiler/GHC/Tc/Gen/Expr.hs +++ b/compiler/GHC/Tc/Gen/Expr.hs @@ -168,8 +168,16 @@ tcLExpr, tcLExprNC -- Definitely no foralls at the top -> TcM (LHsExpr GhcTc) -tcLExpr expr res_ty - = setSrcSpan (getLoc expr) $ addExprCtxt expr (tcLExprNC expr res_ty) +tcLExpr e@(L loc expr) res_ty + -- We duplicate tcLExprNC so as to avoid setting the + -- source span twice. + -- It is however necessary to set the span before adding + -- the context, as depending on loc's value, we might + -- actually not add the context at all. See + -- Note [Rebindable syntax and HsExpansion] for details. + = setSrcSpan loc $ addExprCtxt e $ + do { expr' <- tcExpr expr res_ty + ; return (L loc expr') } tcLExprNC (L loc expr) res_ty = setSrcSpan loc $ diff --git a/compiler/GHC/Types/SrcLoc.hs b/compiler/GHC/Types/SrcLoc.hs index 15671e2c27..19966039c4 100644 --- a/compiler/GHC/Types/SrcLoc.hs +++ b/compiler/GHC/Types/SrcLoc.hs @@ -314,7 +314,7 @@ data UnhelpfulSpanReason | UnhelpfulWiredIn | UnhelpfulInteractive | UnhelpfulGenerated - | UnhelpfulOther !FastString + | UnhelpfulOther {-# UNPACK #-} !FastString deriving (Eq, Show) {- Note [Why Maybe BufPos] |