Skip to content

Commit d75400d

Browse files
authored
Remove Unsafe Dynflags deadcode, they don't exist any more! (#4480)
1 parent b24ae0a commit d75400d

File tree

3 files changed

+5
-28
lines changed

3 files changed

+5
-28
lines changed

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

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.

ghcide/src/Development/IDE/Main.hs

+4-15
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')
@@ -136,7 +135,6 @@ data Log
136135
| LogLspStart [PluginId]
137136
| LogLspStartDuration !Seconds
138137
| LogShouldRunSubset !Bool
139-
| LogSetInitialDynFlagsException !SomeException
140138
| LogConfigurationChange T.Text
141139
| LogService Service.Log
142140
| LogShake Shake.Log
@@ -160,8 +158,6 @@ instance Pretty Log where
160158
"Started LSP server in" <+> pretty (showDuration duration)
161159
LogShouldRunSubset shouldRunSubset ->
162160
"shouldRunSubset:" <+> pretty shouldRunSubset
163-
LogSetInitialDynFlagsException e ->
164-
"setInitialDynFlags:" <+> pretty (displayException e)
165161
LogConfigurationChange msg -> "Configuration changed:" <+> pretty msg
166162
LogService msg -> pretty msg
167163
LogShake msg -> pretty msg
@@ -329,13 +325,6 @@ defaultMain recorder Arguments{..} = withHeapStats (cmapWithPrio LogHeapStats re
329325
getIdeState env rootPath withHieDb threadQueue = do
330326
t <- ioT
331327
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-
339328
sessionLoader <- loadSessionWithOptions (cmapWithPrio LogSession recorder) argsSessionLoadingOptions rootPath (tLoaderQueue threadQueue)
340329
config <- LSP.runLspT env LSP.getConfig
341330
let def_options = argsIdeOptions config sessionLoader
@@ -435,7 +424,7 @@ defaultMain recorder Arguments{..} = withHeapStats (cmapWithPrio LogHeapStats re
435424
let root = argsProjectRoot
436425
dbLoc <- getHieDbLoc root
437426
hPutStrLn stderr $ "Using hiedb at: " ++ dbLoc
438-
mlibdir <- setInitialDynFlags (cmapWithPrio LogSession recorder) root def
427+
mlibdir <- getInitialGhcLibDirDefault (cmapWithPrio LogSession recorder) root
439428
rng <- newStdGen
440429
case mlibdir of
441430
Nothing -> exitWith $ ExitFailure 1

0 commit comments

Comments
 (0)