diff options
author | Alan Zimmerman <alan.zimm@gmail.com> | 2021-05-12 21:57:48 +0100 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2021-05-19 23:35:59 -0400 |
commit | 10ae305e4ef05e1817ba92fb1d7a7079612c78a3 (patch) | |
tree | d798f2a14b873b35b25b7aa3429a440effeb2705 /utils | |
parent | 327256178e8378c9d5cfd9b1990788d7eca2294f (diff) | |
download | haskell-10ae305e4ef05e1817ba92fb1d7a7079612c78a3.tar.gz |
EPA: Remove duplicate annotations from HsDataDefn
They are repeated in the surrounding DataDecl and FamEqn.
Updates haddock submodule
Closes #19834
Diffstat (limited to 'utils')
-rw-r--r-- | utils/check-exact/ExactPrint.hs | 39 | ||||
-rw-r--r-- | utils/check-exact/Main.hs | 3 | ||||
m--------- | utils/haddock | 0 |
3 files changed, 25 insertions, 17 deletions
diff --git a/utils/check-exact/ExactPrint.hs b/utils/check-exact/ExactPrint.hs index e4319bebf0..c0620ebf16 100644 --- a/utils/check-exact/ExactPrint.hs +++ b/utils/check-exact/ExactPrint.hs @@ -782,12 +782,6 @@ instance ExactPrint (InstDecl GhcPs) where getAnnotationEntry (DataFamInstD an _) = fromAnn an getAnnotationEntry (TyFamInstD _ _) = NoEntryVal --- instance Annotate (GHC.InstDecl GHC.GhcPs) where - --- markAST l (GHC.ClsInstD _ cid) = markAST l cid --- markAST l (GHC.DataFamInstD _ dfid) = markAST l dfid --- markAST l (GHC.TyFamInstD _ tfid) = markAST l tfid --- markAST _ (GHC.XInstDecl x) = error $ "got XInstDecl for:" ++ showPprUnsafe x exact (ClsInstD _ cid) = markAnnotated cid exact (DataFamInstD an decl) = do @@ -800,12 +794,13 @@ instance ExactPrint (InstDecl GhcPs) where exactDataFamInstDecl :: EpAnn [AddEpAnn] -> TopLevelFlag -> (DataFamInstDecl GhcPs) -> EPP () exactDataFamInstDecl an top_lvl - (DataFamInstDecl ( FamEqn { feqn_tycon = tycon + (DataFamInstDecl ( FamEqn { feqn_ext = an2 + , feqn_tycon = tycon , feqn_bndrs = bndrs , feqn_pats = pats , feqn_fixity = fixity , feqn_rhs = defn })) - = exactDataDefn an pp_hdr defn + = exactDataDefn an2 pp_hdr defn -- See Note [an and an2 in exactDataFamInstDecl] where pp_hdr mctxt = do case top_lvl of @@ -813,6 +808,19 @@ exactDataFamInstDecl an top_lvl NotTopLevel -> return () exactHsFamInstLHS an tycon bndrs pats fixity mctxt +{- +Note [an and an2 in exactDataFamInstDecl] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +The exactDataFamInstDecl function is called to render a +DataFamInstDecl within its surrounding context. This context is +rendered via the 'pp_hdr' function, which uses the exact print +annotations from that context, named 'an'. The EPAs used for +rendering the DataDefn are contained in the FamEqn, and are called +'an2'. + +-} + -- --------------------------------------------------------------------- exactTyFamInstDecl :: TopLevelFlag -> (TyFamInstDecl GhcPs) -> EPP () @@ -2681,7 +2689,6 @@ instance ExactPrint (TyClDecl GhcPs) where markEpAnn an AnnCloseC where top_matter = do - annotationsToComments (epAnnAnns an) [AnnOpenP, AnnCloseP] markEpAnn an AnnClass exactVanillaDeclHead an lclas tyvars fixity context unless (null fds) $ do @@ -2829,14 +2836,14 @@ exactDataDefn :: EpAnn [AddEpAnn] -> HsDataDefn GhcPs -> EPP () exactDataDefn an exactHdr - (HsDataDefn { dd_ext = an2 - , dd_ND = new_or_data, dd_ctxt = context + (HsDataDefn { dd_ND = new_or_data, dd_ctxt = context , dd_cType = mb_ct , dd_kindSig = mb_sig , dd_cons = condecls, dd_derivs = derivings }) = do + -- annotationsToComments (epAnnAnns an) [AnnOpenP, AnnCloseP] if new_or_data == DataType - then markEpAnn an2 AnnData - else markEpAnn an2 AnnNewtype + then markEpAnn an AnnData + else markEpAnn an AnnNewtype mapM_ markAnnotated mb_ct exactHdr context case mb_sig of @@ -2845,7 +2852,7 @@ exactDataDefn an exactHdr markEpAnn an AnnDcolon markAnnotated kind when (isGadt condecls) $ markEpAnn an AnnWhere - exact_condecls an2 condecls + exact_condecls an condecls mapM_ markAnnotated derivings return () @@ -2863,16 +2870,16 @@ exactVanillaDeclHead an thing (HsQTvs { hsq_explicit = tyvars }) fixity context -- = hsep [char '(',ppr (unLoc varl), pprInfixOcc (unLoc thing) -- , (ppr.unLoc) (head varsr), char ')' -- , hsep (map (ppr.unLoc) (tail vaprsr))] - markEpAnnAll an id AnnOpenP + annotationsToComments (epAnnAnns an) [AnnOpenP,AnnCloseP] markAnnotated varl markAnnotated thing markAnnotated (head varsr) - markEpAnnAll an id AnnCloseP markAnnotated (tail varsr) return () | fixity == Infix = do -- = hsep [ppr (unLoc varl), pprInfixOcc (unLoc thing) -- , hsep (map (ppr.unLoc) varsr)] + annotationsToComments (epAnnAnns an) [AnnOpenP,AnnCloseP] markAnnotated varl markAnnotated thing markAnnotated varsr diff --git a/utils/check-exact/Main.hs b/utils/check-exact/Main.hs index f9883fee83..d0971dac65 100644 --- a/utils/check-exact/Main.hs +++ b/utils/check-exact/Main.hs @@ -187,7 +187,8 @@ _tt = testOneFile changers "/home/alanz/mysrc/git.haskell.org/worktree/exactprin -- "../../testsuite/tests/printer/Test19784.hs" Nothing -- "../../testsuite/tests/printer/Test19813.hs" Nothing -- "../../testsuite/tests/printer/Test19814.hs" Nothing - "../../testsuite/tests/printer/Test19821.hs" Nothing + -- "../../testsuite/tests/printer/Test19821.hs" Nothing + "../../testsuite/tests/printer/Test19834.hs" Nothing -- cloneT does not need a test, function can be retired diff --git a/utils/haddock b/utils/haddock -Subproject ef2304bbff1e30fcd9306b5b211f045d608753c +Subproject 2fec1b44e0ee7e263286709aa528b4ecb99ac6c |