summaryrefslogtreecommitdiff
path: root/compiler
diff options
context:
space:
mode:
authorAlan Zimmerman <alan.zimm@gmail.com>2023-04-25 23:24:27 +0100
committerMarge Bot <ben+marge-bot@smart-cactus.org>2023-04-26 14:52:05 -0400
commit052e2bb629abc97b394b9de2394eb36cbed9385f (patch)
tree3ae7f17afa7de56fbdfd0ee2aa8af3fbb3a23811 /compiler
parent77f506b888624b4fd30205fb8512f39435055a27 (diff)
downloadhaskell-052e2bb629abc97b394b9de2394eb36cbed9385f.tar.gz
EPA: Use ExplicitBraces only in HsModule
!9018 brought in exact print annotations in LayoutInfo for open and close braces at the top level. But it retained them in the HsModule annotations too. Remove the originals, so exact printing uses LayoutInfo
Diffstat (limited to 'compiler')
-rw-r--r--compiler/GHC/Hs.hs2
-rw-r--r--compiler/GHC/Parser.y19
2 files changed, 9 insertions, 12 deletions
diff --git a/compiler/GHC/Hs.hs b/compiler/GHC/Hs.hs
index eb66dc0f28..9ec3215dbd 100644
--- a/compiler/GHC/Hs.hs
+++ b/compiler/GHC/Hs.hs
@@ -101,7 +101,7 @@ deriving instance Data (HsModule GhcPs)
data AnnsModule
= AnnsModule {
am_main :: [AddEpAnn],
- am_decls :: AnnList,
+ am_decls :: [TrailingAnn],
am_eof :: Maybe (RealSrcSpan, RealSrcSpan) -- End of file and end of prior token
} deriving (Data, Eq)
diff --git a/compiler/GHC/Parser.y b/compiler/GHC/Parser.y
index bbbc12df56..d95d9d1512 100644
--- a/compiler/GHC/Parser.y
+++ b/compiler/GHC/Parser.y
@@ -925,20 +925,17 @@ maybemodwarning :: { Maybe (LocatedP (WarningTxt GhcPs)) }
(AnnPragma (mo $1) (mc $4) (fst $ unLoc $3))}
| {- empty -} { Nothing }
-body :: { (AnnList
+body :: { ([TrailingAnn]
,([LImportDecl GhcPs], [LHsDecl GhcPs])
,LayoutInfo GhcPs) }
- : '{' top '}' { (AnnList Nothing (Just $ moc $1) (Just $ mcc $3) [] (fst $2)
- , snd $2, explicitBraces $1 $3) }
- | vocurly top close { (AnnList Nothing Nothing Nothing [] (fst $2)
- , snd $2, VirtualBraces (getVOCURLY $1)) }
+ : '{' top '}' { (fst $2, snd $2, explicitBraces $1 $3) }
+ | vocurly top close { (fst $2, snd $2, VirtualBraces (getVOCURLY $1)) }
-body2 :: { (AnnList
+body2 :: { ([TrailingAnn]
,([LImportDecl GhcPs], [LHsDecl GhcPs])
,LayoutInfo GhcPs) }
- : '{' top '}' { (AnnList Nothing (Just $ moc $1) (Just $ mcc $3) [] (fst $2)
- , snd $2, explicitBraces $1 $3) }
- | missing_module_keyword top close { (AnnList Nothing Nothing Nothing [] [], snd $2, VirtualBraces leftmostColumn) }
+ : '{' top '}' { (fst $2, snd $2, explicitBraces $1 $3) }
+ | missing_module_keyword top close { ([], snd $2, VirtualBraces leftmostColumn) }
top :: { ([TrailingAnn]
@@ -957,14 +954,14 @@ header :: { Located (HsModule GhcPs) }
: 'module' modid maybemodwarning maybeexports 'where' header_body
{% fileSrcSpan >>= \ loc ->
acs (\cs -> (L loc (HsModule (XModulePs
- (EpAnn (spanAsAnchor loc) (AnnsModule [mj AnnModule $1,mj AnnWhere $5] (AnnList Nothing Nothing Nothing [] []) Nothing) cs)
+ (EpAnn (spanAsAnchor loc) (AnnsModule [mj AnnModule $1,mj AnnWhere $5] [] Nothing) cs)
NoLayoutInfo $3 Nothing)
(Just $2) $4 $6 []
))) }
| 'signature' modid maybemodwarning maybeexports 'where' header_body
{% fileSrcSpan >>= \ loc ->
acs (\cs -> (L loc (HsModule (XModulePs
- (EpAnn (spanAsAnchor loc) (AnnsModule [mj AnnModule $1,mj AnnWhere $5] (AnnList Nothing Nothing Nothing [] []) Nothing) cs)
+ (EpAnn (spanAsAnchor loc) (AnnsModule [mj AnnModule $1,mj AnnWhere $5] [] Nothing) cs)
NoLayoutInfo $3 Nothing)
(Just $2) $4 $6 []
))) }