Skip to content

Commit a68768a

Browse files
committed
Remove Unsafe Dynflags deadcode, they don't exist any more!
1 parent 2df8775 commit a68768a

File tree

3 files changed

+5
-25
lines changed

3 files changed

+5
-25
lines changed

Diff for: ghcide/session-loader/Development/IDE/Session.hs

+1-12
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ module Development.IDE.Session
88
(SessionLoadingOptions(..)
99
,CacheDirs(..)
1010
,loadSessionWithOptions
11-
,setInitialDynFlags
11+
,getInitialGhcLibDirDefault
1212
,getHieDbLoc
1313
,retryOnSqliteBusy
1414
,retryOnException
@@ -113,13 +113,11 @@ import Development.IDE.Types.Shake (WithHieDb,
113113
import GHC.Data.Graph.Directed
114114
import HieDb.Create
115115
import HieDb.Types
116-
import HieDb.Utils
117116
import Ide.PluginUtils (toAbsolute)
118117
import qualified System.Random as Random
119118
import System.Random (RandomGen)
120119
import Text.ParserCombinators.ReadP (readP_to_S)
121120

122-
import GHC.Data.Bag
123121
import GHC.Driver.Env (hsc_all_home_unit_ids)
124122
import GHC.Driver.Errors.Types
125123
import GHC.Types.Error (errMsgDiagnostic,
@@ -286,15 +284,6 @@ getInitialGhcLibDirDefault recorder rootDir = do
286284
logWith recorder Warning LogGetInitialGhcLibDirDefaultCradleNone
287285
pure Nothing
288286

289-
-- | Sets `unsafeGlobalDynFlags` on using the hie-bios cradle and returns the GHC libdir
290-
setInitialDynFlags :: Recorder (WithPriority Log) -> FilePath -> SessionLoadingOptions -> IO (Maybe LibDir)
291-
setInitialDynFlags recorder rootDir SessionLoadingOptions{..} = do
292-
libdir <- getInitialGhcLibDir recorder rootDir
293-
dynFlags <- mapM dynFlagsForPrinting libdir
294-
logWith recorder Debug LogSettingInitialDynFlags
295-
mapM_ setUnsafeGlobalDynFlags dynFlags
296-
pure libdir
297-
298287
-- | If the action throws exception that satisfies predicate then we sleep for
299288
-- a duration determined by the random exponential backoff formula,
300289
-- `uniformRandom(0, min (maxDelay, (baseDelay * 2) ^ retryAttempt))`, and try

Diff for: ghcide/src/Development/IDE/GHC/Util.hs

-1
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,6 @@ ioe_dupHandlesNotCompatible h =
255255
-- Tracing exactprint terms
256256

257257
-- | Print a GHC value in `defaultUserStyle` without unique symbols.
258-
-- It uses `showSDocUnsafe` with `unsafeGlobalDynFlags` internally.
259258
--
260259
-- This is the most common print utility.
261260
-- It will do something additionally compared to what the 'Outputable' instance does.

Diff for: ghcide/src/Development/IDE/Main.hs

+4-12
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import Control.Concurrent.MVar (newEmptyMVar,
1616
putMVar, tryReadMVar)
1717
import Control.Concurrent.STM.Stats (dumpSTMStats)
1818
import Control.Exception.Safe (SomeException,
19-
catchAny,
2019
displayException)
2120
import Control.Monad.Extra (concatMapM, unless,
2221
when)
@@ -32,7 +31,7 @@ import Data.List.Extra (intercalate,
3231
import Data.Maybe (catMaybes, isJust)
3332
import qualified Data.Text as T
3433
import Development.IDE (Action,
35-
Priority (Debug, Error),
34+
Priority (Debug),
3635
Rules, hDuplicateTo')
3736
import Development.IDE.Core.Debouncer (Debouncer,
3837
newAsyncDebouncer)
@@ -72,9 +71,9 @@ import qualified Development.IDE.Plugin.HLS.GhcIde as GhcIde
7271
import qualified Development.IDE.Plugin.Test as Test
7372
import Development.IDE.Session (SessionLoadingOptions,
7473
getHieDbLoc,
74+
getInitialGhcLibDirDefault,
7575
loadSessionWithOptions,
76-
retryOnSqliteBusy,
77-
setInitialDynFlags)
76+
retryOnSqliteBusy)
7877
import qualified Development.IDE.Session as Session
7978
import Development.IDE.Types.Location (NormalizedUri,
8079
toNormalizedFilePath')
@@ -329,13 +328,6 @@ defaultMain recorder Arguments{..} = withHeapStats (cmapWithPrio LogHeapStats re
329328
getIdeState env rootPath withHieDb threadQueue = do
330329
t <- ioT
331330
logWith recorder Info $ LogLspStartDuration t
332-
-- We want to set the global DynFlags right now, so that we can use
333-
-- `unsafeGlobalDynFlags` even before the project is configured
334-
_mlibdir <-
335-
setInitialDynFlags (cmapWithPrio LogSession recorder) rootPath argsSessionLoadingOptions
336-
-- TODO: should probably catch/log/rethrow at top level instead
337-
`catchAny` (\e -> logWith recorder Error (LogSetInitialDynFlagsException e) >> pure Nothing)
338-
339331
sessionLoader <- loadSessionWithOptions (cmapWithPrio LogSession recorder) argsSessionLoadingOptions rootPath (tLoaderQueue threadQueue)
340332
config <- LSP.runLspT env LSP.getConfig
341333
let def_options = argsIdeOptions config sessionLoader
@@ -435,7 +427,7 @@ defaultMain recorder Arguments{..} = withHeapStats (cmapWithPrio LogHeapStats re
435427
let root = argsProjectRoot
436428
dbLoc <- getHieDbLoc root
437429
hPutStrLn stderr $ "Using hiedb at: " ++ dbLoc
438-
mlibdir <- setInitialDynFlags (cmapWithPrio LogSession recorder) root def
430+
mlibdir <- getInitialGhcLibDirDefault (cmapWithPrio LogSession recorder) root
439431
rng <- newStdGen
440432
case mlibdir of
441433
Nothing -> exitWith $ ExitFailure 1

0 commit comments

Comments
 (0)