Skip to content
This repository was archived by the owner on Aug 3, 2024. It is now read-only.

Commit 83f0fa0

Browse files
committed
Don't warn about missing links in miminal sigs
When renaming the Haddock interface, never emit warnings when renaming a minimal signature. Also added some documention around `renameInterface`. Minimal signatures intentionally include references to potentially un-exported methods (see the discussion in #330), so it is expected that they will not always have a link destination. On the principle that warnings should always be resolvable, this shouldn't produce a warning. See #1070.
1 parent 8d83110 commit 83f0fa0

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

haddock-api/src/Haddock/Interface/Create.hs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -188,10 +188,10 @@ createInterface tm flags modMap instIfaceMap = do
188188
, ifaceOptions = opts
189189
, ifaceDocMap = prunedDocMap
190190
, ifaceArgMap = prunedArgMap
191-
, ifaceRnDocMap = M.empty
192-
, ifaceRnArgMap = M.empty
191+
, ifaceRnDocMap = M.empty -- Filled in `renameInterface`
192+
, ifaceRnArgMap = M.empty -- Filled in `renameInterface`
193193
, ifaceExportItems = prunedExportItems
194-
, ifaceRnExportItems = []
194+
, ifaceRnExportItems = [] -- Filled in `renameInterface`
195195
, ifaceExports = exportedNames
196196
, ifaceVisibleExports = visibleNames
197197
, ifaceDeclMap = declMap

haddock-api/src/Haddock/Interface/Rename.hs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,14 @@ import Control.Monad hiding (mapM)
3131
import qualified Data.Map as Map hiding ( Map )
3232
import Prelude hiding (mapM)
3333

34+
-- | Traverse docstrings and ASTs in the Haddock interface, renaming 'Name' to
35+
-- 'DocName'.
36+
--
37+
-- What this really boils down to is: for each 'Name', figure out which of the
38+
-- modules that export the name is the preferred place to link to.
39+
--
40+
-- The renamed output gets written into fields in the Haddock interface record
41+
-- that were previously left empty.
3442
renameInterface :: DynFlags -> LinkEnv -> Bool -> Interface -> ErrMsgM Interface
3543
renameInterface dflags renamingEnv warnings iface =
3644

@@ -128,6 +136,11 @@ lookupRn name = RnM $ \lkp ->
128136
(False,maps_to) -> (maps_to, (name :))
129137
(True, maps_to) -> (maps_to, id)
130138

139+
-- | Look up a 'Name' in the renaming environment, but don't warn if you don't
140+
-- find the name. Prefer to use 'lookupRn' whenever possible.
141+
lookupRnNoWarn :: Name -> RnM DocName
142+
lookupRnNoWarn name = RnM $ \lkp -> (snd (lkp name), id)
143+
131144
-- | Run the renamer action using lookup in a 'LinkEnv' as the lookup function.
132145
-- Returns the renamed value along with a list of `Name`'s that could not be
133146
-- renamed because they weren't in the environment.
@@ -532,7 +545,7 @@ renameSig sig = case sig of
532545
lnames' <- mapM renameL lnames
533546
return $ FixSig noExtField (FixitySig noExtField lnames' fixity)
534547
MinimalSig _ src (L l s) -> do
535-
s' <- traverse renameL s
548+
s' <- traverse (traverse lookupRnNoWarn) s
536549
return $ MinimalSig noExtField src (L l s')
537550
-- we have filtered out all other kinds of signatures in Interface.Create
538551
_ -> error "expected TypeSig"

0 commit comments

Comments
 (0)