Skip to content

Commit

Permalink
Actually force usages
Browse files Browse the repository at this point in the history
In 00f4e61 we attempted to share the filepaths in GHC's usage field.
Unfortunately the `mi_usages` field is lazy and so these turned out to not actually be shared because
the thunk responsible for sharing was never evaluated.

Add the right strictness annotations to ensure these are actually shared
  • Loading branch information
wz1000 committed Jul 12, 2023
1 parent 27f46d7 commit 69c0587
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
3 changes: 2 additions & 1 deletion ghcide/src/Development/IDE/Core/Compile.hs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ module Development.IDE.Core.Compile
, TypecheckHelpers(..)
, sourceTypecheck
, sourceParser
, shareUsages
) where

import Control.Monad.IO.Class
Expand Down Expand Up @@ -469,7 +470,7 @@ filterUsages = id

-- | Mitigation for https://gitlab.haskell.org/ghc/ghc/-/issues/22744
shareUsages :: ModIface -> ModIface
shareUsages iface = iface {mi_usages = usages}
shareUsages iface = rnf usages `seq` iface {mi_usages = usages}
where usages = map go (mi_usages iface)
go usg@UsageFile{} = usg {usg_file_path = fp}
where !fp = shareFilePath (usg_file_path usg)
Expand Down
4 changes: 4 additions & 0 deletions ghcide/src/Development/IDE/GHC/Orphans.hs
Original file line number Diff line number Diff line change
Expand Up @@ -242,3 +242,7 @@ instance NFData (HsExpr (GhcPass 'Renamed)) where

instance NFData Extension where
rnf = rwhnf

instance NFData Usage where
rnf (UsageFile a b c) = rnf a `seq` rnf b `seq` rnf c
rnf x = ()

0 comments on commit 69c0587

Please sign in to comment.