From 052e2bb629abc97b394b9de2394eb36cbed9385f Mon Sep 17 00:00:00 2001 From: Alan Zimmerman Date: Tue, 25 Apr 2023 23:24:27 +0100 Subject: 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 --- compiler/GHC/Hs.hs | 2 +- compiler/GHC/Parser.y | 19 ++++++++----------- 2 files changed, 9 insertions(+), 12 deletions(-) (limited to 'compiler') 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 [] ))) } -- cgit v1.2.1