From 2c0afbb0ae4adece37b558de2c2b3955b9a442d7 Mon Sep 17 00:00:00 2001 From: Pepe Iborra Date: Tue, 9 Mar 2021 08:52:47 +0000 Subject: [PATCH] Log a warning for every diagnostic received when doDiagnostics=False Even if the rule body does not produce diagnostics, it is still possible to get a BadDependency diagnostic. To avoid a debugging nightmare if this ever happens, let's make sure to log any unexpected diagnostics --- ghcide/src/Development/IDE/Core/Shake.hs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/ghcide/src/Development/IDE/Core/Shake.hs b/ghcide/src/Development/IDE/Core/Shake.hs index effc31bf8e..b0d7d53277 100644 --- a/ghcide/src/Development/IDE/Core/Shake.hs +++ b/ghcide/src/Development/IDE/Core/Shake.hs @@ -938,7 +938,7 @@ defineEarlyCutoff' -> Action (Maybe BS.ByteString, IdeResult v) -> Action (RunResult (A (RuleResult k))) defineEarlyCutoff' doDiagnostics key file old mode action = do - extras@ShakeExtras{state, inProgress} <- getShakeExtras + extras@ShakeExtras{state, inProgress, logger} <- getShakeExtras options <- getIdeOptions (if optSkipProgress options key then id else withProgressVar inProgress file) $ do val <- case old of @@ -974,8 +974,9 @@ defineEarlyCutoff' doDiagnostics key file old mode action = do (toShakeValue ShakeResult bs, Failed b) Just v -> pure (maybe ShakeNoCutoff ShakeResult bs, Succeeded (vfsVersion =<< modTime) v) liftIO $ setValues state key file res (Vector.fromList diags) - when doDiagnostics $ - updateFileDiagnostics file (Key key) extras $ map (\(_,y,z) -> (y,z)) diags + if doDiagnostics + then updateFileDiagnostics file (Key key) extras $ map (\(_,y,z) -> (y,z)) diags + else forM_ diags $ \d -> liftIO $ logWarning logger $ showDiagnosticsColored [d] let eq = case (bs, fmap decodeShakeValue old) of (ShakeResult a, Just (ShakeResult b)) -> a == b (ShakeStale a, Just (ShakeStale b)) -> a == b