diff options
author | Alan Zimmerman <alan.zimm@gmail.com> | 2022-06-22 21:09:22 +0100 |
---|---|---|
committer | sheaf <sam.derbyshire@gmail.com> | 2022-07-06 11:32:37 +0200 |
commit | a7f407296514af572cbea1ac6da31662c37d29c6 (patch) | |
tree | c989fb49efb8a47287a1b7828f53a8cfae2e7926 | |
parent | 354ae313b6f142c74f1398a5086ecdf2bf5f739c (diff) | |
download | haskell-wip/romes/ttg-prune.tar.gz |
Fix exact printing of the HsRule namewip/romes/ttg-prune
Prior to this branch, the HsRule name was
XRec pass (SourceText,RuleName)
and there is an ExactPrint instance for (SourceText, RuleName).
The SourceText has moved to a different location, so synthesise the
original to trigger the correct instance when printing.
We need both the SourceText and RuleName when exact printing, as it is
possible to have a NoSourceText variant, in which case we fall back to
the FastString.
-rw-r--r-- | compiler/GHC/Hs/Decls.hs | 2 | ||||
-rw-r--r-- | utils/check-exact/ExactPrint.hs | 4 |
2 files changed, 2 insertions, 4 deletions
diff --git a/compiler/GHC/Hs/Decls.hs b/compiler/GHC/Hs/Decls.hs index 9264d6c7c2..8bb7834f3b 100644 --- a/compiler/GHC/Hs/Decls.hs +++ b/compiler/GHC/Hs/Decls.hs @@ -1122,8 +1122,6 @@ data HsRuleRn = HsRuleRn NameSet NameSet -- Free-vars from the LHS and RHS type instance XXRuleDecl (GhcPass _) = DataConCantHappen -type instance Anno (SourceText, RuleName) = SrcAnn NoEpAnns - data HsRuleAnn = HsRuleAnn { ra_tyanns :: Maybe (AddEpAnn, AddEpAnn) diff --git a/utils/check-exact/ExactPrint.hs b/utils/check-exact/ExactPrint.hs index ef2e98841b..eecb1e28eb 100644 --- a/utils/check-exact/ExactPrint.hs +++ b/utils/check-exact/ExactPrint.hs @@ -1037,9 +1037,9 @@ instance ExactPrint (RuleDecls GhcPs) where instance ExactPrint (RuleDecl GhcPs) where getAnnotationEntry (HsRule {rd_ext = (an,_)}) = fromAnn an - exact (HsRule (an,_) ln act mtybndrs termbndrs lhs rhs) = do + exact (HsRule (an,nsrc) (L ln n) act mtybndrs termbndrs lhs rhs) = do debugM "HsRule entered" - markAnnotated ln + markAnnotated (L ln (nsrc, n)) debugM "HsRule after ln" markActivation an ra_rest act debugM "HsRule after act" |