summaryrefslogtreecommitdiff
path: root/compiler/GHC/Parser
diff options
context:
space:
mode:
authorSylvain Henry <sylvain@haskus.fr>2021-09-22 18:28:35 +0200
committerMarge Bot <ben+marge-bot@smart-cactus.org>2021-10-22 19:20:44 -0400
commit806e49ae36a058dbe4494055a6b936dd153c6194 (patch)
tree982c304986bf925187aae36997d4602e3419c8e9 /compiler/GHC/Parser
parent6fd7da745a518a93f6685171701a27283cfe2d4e (diff)
downloadhaskell-806e49ae36a058dbe4494055a6b936dd153c6194.tar.gz
Refactor package imports
Use an (Raw)PkgQual datatype instead of `Maybe FastString` to represent package imports. Factorize the code that renames RawPkgQual into PkgQual in function `rnPkgQual`. Renaming consists in checking if the FastString is the magic "this" keyword, the home-unit unit-id or something else. Bump haddock submodule
Diffstat (limited to 'compiler/GHC/Parser')
-rw-r--r--compiler/GHC/Parser/Header.hs13
1 files changed, 7 insertions, 6 deletions
diff --git a/compiler/GHC/Parser/Header.hs b/compiler/GHC/Parser/Header.hs
index 1199d64957..c19c873c91 100644
--- a/compiler/GHC/Parser/Header.hs
+++ b/compiler/GHC/Parser/Header.hs
@@ -37,6 +37,7 @@ import GHC.Types.Error
import GHC.Types.SrcLoc
import GHC.Types.SourceError
import GHC.Types.SourceText
+import GHC.Types.PkgQual
import GHC.Utils.Misc
import GHC.Utils.Panic
@@ -72,8 +73,8 @@ getImports :: ParserOpts -- ^ Parser options
-- in the function result)
-> IO (Either
(Messages PsMessage)
- ([(Maybe FastString, Located ModuleName)],
- [(Maybe FastString, Located ModuleName)],
+ ([(RawPkgQual, Located ModuleName)],
+ [(RawPkgQual, Located ModuleName)],
Bool, -- Is GHC.Prim imported or not
Located ModuleName))
-- ^ The source imports and normal imports (with optional package
@@ -107,7 +108,7 @@ getImports popts implicit_prelude buf filename source_filename = do
implicit_imports = mkPrelImports (unLoc mod) main_loc
implicit_prelude imps
- convImport (L _ i) = (fmap sl_fs (ideclPkgQual i), ideclName i)
+ convImport (L _ i) = (ideclPkgQual i, ideclName i)
in
return (map convImport src_idecls
, map convImport (implicit_imports ++ ordinary_imps)
@@ -136,8 +137,8 @@ mkPrelImports this_mod loc implicit_prelude import_decls
unLoc (ideclName decl) == pRELUDE_NAME
-- allow explicit "base" package qualifier (#19082, #17045)
&& case ideclPkgQual decl of
- Nothing -> True
- Just b -> sl_fs b == unitIdFS baseUnitId
+ NoRawPkgQual -> True
+ RawPkgQual b -> sl_fs b == unitIdFS baseUnitId
loc' = noAnnSrcSpan loc
@@ -146,7 +147,7 @@ mkPrelImports this_mod loc implicit_prelude import_decls
= L loc' $ ImportDecl { ideclExt = noAnn,
ideclSourceSrc = NoSourceText,
ideclName = L loc pRELUDE_NAME,
- ideclPkgQual = Nothing,
+ ideclPkgQual = NoRawPkgQual,
ideclSource = NotBoot,
ideclSafe = False, -- Not a safe import
ideclQualified = NotQualified,