From 8185b1c284e949e92c61b1c0369a4b0cc38090b2 Mon Sep 17 00:00:00 2001 From: Finley McIlwaine <finleymcilwaine@gmail.com> Date: Fri, 16 Jun 2023 11:53:52 -0400 Subject: [PATCH] Fix associated data family doc structure items Associated data families were being given their own export DocStructureItems, which resulted in them being documented separately from their classes in haddocks. This commit fixes it. --- compiler/GHC/Hs/Doc.hs | 2 +- compiler/GHC/HsToCore/Docs.hs | 8 +++++++- utils/haddock | 2 +- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/compiler/GHC/Hs/Doc.hs b/compiler/GHC/Hs/Doc.hs index 70d0ee3638c2..93c0a734fe37 100644 --- a/compiler/GHC/Hs/Doc.hs +++ b/compiler/GHC/Hs/Doc.hs @@ -123,7 +123,7 @@ type LHsDoc pass = Located (HsDoc pass) data DocStructureItem = DsiSectionHeading !Int !(HsDoc GhcRn) | DsiDocChunk !(HsDoc GhcRn) - | DsiNamedChunkRef !(String) + | DsiNamedChunkRef !String | DsiExports !Avails | DsiModExport !(NonEmpty ModuleName) -- ^ We might re-export avails from multiple diff --git a/compiler/GHC/HsToCore/Docs.hs b/compiler/GHC/HsToCore/Docs.hs index 123e5dfadecc..8c3730ac4bc8 100644 --- a/compiler/GHC/HsToCore/Docs.hs +++ b/compiler/GHC/HsToCore/Docs.hs @@ -192,7 +192,13 @@ mkDocStructureFromDecls env all_exports decls = Just loc -> L loc (DsiExports [avail]) -- FIXME: This is just a workaround that we use when handling e.g. -- associated data families like in the html-test Instances.hs. - Nothing -> noLoc (DsiExports [avail]) + Nothing -> noLoc (DsiExports []) + + -- This causes the associated data family to be incorrectly documented + -- separately from its class: + -- Nothing -> noLoc (DsiExports [avail]) + + -- This panics on the associated data family: -- Nothing -> panicDoc "mkDocStructureFromDecls: No loc found for" -- (ppr avail) diff --git a/utils/haddock b/utils/haddock index 2c6ce8063c97..bfb52adefa02 160000 --- a/utils/haddock +++ b/utils/haddock @@ -1 +1 @@ -Subproject commit 2c6ce8063c975602761cf0ae121200fe9c166148 +Subproject commit bfb52adefa028f541672623321eb1b3d21dd2547 -- GitLab