From 691c450f1e9cc3fd83b662be3c0134fde03e97db Mon Sep 17 00:00:00 2001 From: Alan Zimmerman Date: Sat, 23 Oct 2021 10:49:55 +0100 Subject: EPA: Use LocatedA for ModuleName This allows us to use an Anchor with a DeltaPos in it when exact printing. --- compiler/GHC/Parser/Header.hs | 8 ++++---- compiler/GHC/Parser/PostProcess/Haddock.hs | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'compiler/GHC/Parser') diff --git a/compiler/GHC/Parser/Header.hs b/compiler/GHC/Parser/Header.hs index c19c873c91..cb8a5c334e 100644 --- a/compiler/GHC/Parser/Header.hs +++ b/compiler/GHC/Parser/Header.hs @@ -97,7 +97,7 @@ getImports popts implicit_prelude buf filename source_filename = do imps = hsmodImports hsmod main_loc = srcLocSpan (mkSrcLoc (mkFastString source_filename) 1 1) - mod = mb_mod `orElse` L main_loc mAIN_NAME + mod = mb_mod `orElse` L (noAnnSrcSpan main_loc) mAIN_NAME (src_idecls, ord_idecls) = partition ((== IsBoot) . ideclSource . unLoc) imps -- GHC.Prim doesn't exist physically, so don't go looking for it. @@ -108,12 +108,12 @@ getImports popts implicit_prelude buf filename source_filename = do implicit_imports = mkPrelImports (unLoc mod) main_loc implicit_prelude imps - convImport (L _ i) = (ideclPkgQual i, ideclName i) + convImport (L _ i) = (ideclPkgQual i, reLoc $ ideclName i) in return (map convImport src_idecls , map convImport (implicit_imports ++ ordinary_imps) , not (null ghc_prim_import) - , mod) + , reLoc mod) mkPrelImports :: ModuleName -> SrcSpan -- Attribute the "import Prelude" to this location @@ -146,7 +146,7 @@ mkPrelImports this_mod loc implicit_prelude import_decls preludeImportDecl = L loc' $ ImportDecl { ideclExt = noAnn, ideclSourceSrc = NoSourceText, - ideclName = L loc pRELUDE_NAME, + ideclName = L loc' pRELUDE_NAME, ideclPkgQual = NoRawPkgQual, ideclSource = NotBoot, ideclSafe = False, -- Not a safe import diff --git a/compiler/GHC/Parser/PostProcess/Haddock.hs b/compiler/GHC/Parser/PostProcess/Haddock.hs index 5cb81edcdb..f0adba4e6f 100644 --- a/compiler/GHC/Parser/PostProcess/Haddock.hs +++ b/compiler/GHC/Parser/PostProcess/Haddock.hs @@ -249,10 +249,10 @@ instance HasHaddock (Located HsModule) where -- Only do this when the module header exists. headerDocs <- for @Maybe (hsmodName mod) $ \(L l_name _) -> - extendHdkA l_name $ liftHdkA $ do + extendHdkA (locA l_name) $ liftHdkA $ do -- todo: register keyword location of 'module', see Note [Register keyword location] docs <- - inLocRange (locRangeTo (getBufPos (srcSpanStart l_name))) $ + inLocRange (locRangeTo (getBufPos (srcSpanStart (locA l_name)))) $ takeHdkComments mkDocNext selectDocString docs -- cgit v1.2.1