diff options
author | Oleg Grenrus <oleg.grenrus@iki.fi> | 2019-05-07 12:02:15 +0300 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2019-06-25 23:25:08 -0400 |
commit | 8ec5ceb009299fbb3c5ff1fef39180f5a8fbb774 (patch) | |
tree | da203246e1da8d4be1a7449ff91833b611bf338b | |
parent | a863c44f35720b760054e949de1b2f431f32774e (diff) | |
download | haskell-8ec5ceb009299fbb3c5ff1fef39180f5a8fbb774.tar.gz |
Add -Wmissing-safe-haskell-mode warning
-rw-r--r-- | compiler/main/HscMain.hs | 10 | ||||
-rw-r--r-- | docs/users_guide/safe_haskell.rst | 18 |
2 files changed, 27 insertions, 1 deletions
diff --git a/compiler/main/HscMain.hs b/compiler/main/HscMain.hs index 91a1f1d1e6..aa29554e9d 100644 --- a/compiler/main/HscMain.hs +++ b/compiler/main/HscMain.hs @@ -498,6 +498,14 @@ tcRnModule' sum save_rn_syntax mod = do hsc_env <- getHscEnv dflags <- getDynFlags + -- -Wmissing-safe-haskell-mode + when (not (safeHaskellModeEnabled dflags) + && wopt Opt_WarnMissingSafeHaskellMode dflags) $ + logWarnings $ unitBag $ + makeIntoWarning (Reason Opt_WarnMissingSafeHaskellMode) $ + mkPlainWarnMsg dflags (getLoc (hpm_module mod)) $ + warnMissingSafeHaskellMode + tcg_res <- {-# SCC "Typecheck-Rename" #-} ioMsgMaybe $ tcRnModule hsc_env sum @@ -544,6 +552,8 @@ tcRnModule' sum save_rn_syntax mod = do errSafe t = quotes (pprMod t) <+> text "has been inferred as safe!" errTwthySafe t = quotes (pprMod t) <+> text "is marked as Trustworthy but has been inferred as safe!" + warnMissingSafeHaskellMode = ppr (moduleName (ms_mod sum)) + <+> text "is missing Safe Haskell mode" -- | Convert a typechecked module to Core hscDesugar :: HscEnv -> ModSummary -> TcGblEnv -> IO ModGuts diff --git a/docs/users_guide/safe_haskell.rst b/docs/users_guide/safe_haskell.rst index af016194bf..3911b9f41d 100644 --- a/docs/users_guide/safe_haskell.rst +++ b/docs/users_guide/safe_haskell.rst @@ -740,7 +740,7 @@ And one general flag: requiring the package that ``M`` resides in be considered trusted, for ``M`` to be considered trusted. -And four warning flags: +And five warning flags: .. ghc-flag:: -Wunsafe :shortdesc: warn if the module being compiled is regarded to be unsafe. @@ -809,6 +809,22 @@ And four warning flags: ``B``, it will cause compilation error of ``A``. When :ghc-flag:`-Winferred-safe-imports` is enabled, the compiler will emit a warning about this. + This option is off by default. + +.. ghc-flag:: -Wmissing-safe-haskell-mode + :shortdesc: warn when the Safe Haskell mode is not explicitly specified. + :type: dynamic + :reverse: -Wno-missing-safe-haskell-mode + :category: + + :since: 8.10.1 + + .. index:: + single: safe haskell mode, missing + + The compiler will warn when none of :extension:`Safe`, + :extension:`Trustworthy` or :extension:`Unsafe` is specified. + This option is off by default. .. _safe-compilation: |