GHC redundantly reports failure of Safe Haskell inference
If I say
{-# OPTIONS_GHC -Wunsafe #-}
module Bug where
import GHC.Exts
{-# NOINLINE f #-}
f :: a -> a
f x = x
{-# RULES "map/f" map f = f #-}
I get
Bug.hs:1:16: warning: [-Wunsafe]
‘Bug’ has been inferred as unsafe!
Reason:
Bug.hs:5:1: error:
GHC.Exts: Can't be safely imported! The module itself isn't safe.
|
1 | {-# OPTIONS_GHC -Wunsafe #-}
| ^^^^^^^^^^
Bug.hs:1:16: warning: [-Wunsafe]
‘Bug’ has been inferred as unsafe!
Reason:
Bug.hs:11:11: warning:
Rule "map/f" ignored
User defined rules are disabled under Safe Haskell
|
1 | {-# OPTIONS_GHC -Wunsafe #-}
| ^^^^^^^^^^
Either of these problems is enough to kill off inference of Safety. Ideally, I would get one report with multiple reasons, but I'd also be OK with only one reason. But the current output is suboptimal.