summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Pickering <matthewtpickering@gmail.com>2021-11-17 14:56:44 +0000
committerMarge Bot <ben+marge-bot@smart-cactus.org>2021-11-20 05:35:02 -0500
commit3d6b78dbd19f9061387c60e553638f9c26839d50 (patch)
tree9c904e946dd56912299a87270184d72820ff7b4c
parentaabff1093f7b80d968c2847d3a3de4280e72391f (diff)
downloadhaskell-3d6b78dbd19f9061387c60e553638f9c26839d50.tar.gz
Remove unused module import syntax from .bkp mode
.bkp mode had this unused feature where you could write module A and it would go looking for A.hs on the file system and use that rather than provide the definition inline. This isn't use anywhere in the testsuite and the code to find the module A looks dubious. Therefore to reduce .bkp complexity I propose to remove it. Fixes #20701
-rw-r--r--compiler/GHC/Driver/Backpack.hs22
-rw-r--r--compiler/GHC/Driver/Backpack/Syntax.hs2
-rw-r--r--compiler/GHC/Parser.y10
3 files changed, 7 insertions, 27 deletions
diff --git a/compiler/GHC/Driver/Backpack.hs b/compiler/GHC/Driver/Backpack.hs
index 852ff4c0f2..1da05dbda8 100644
--- a/compiler/GHC/Driver/Backpack.hs
+++ b/compiler/GHC/Driver/Backpack.hs
@@ -719,8 +719,8 @@ hsunitModuleGraph unit = do
-- 1. Create a HsSrcFile/HsigFile summary for every
-- explicitly mentioned module/signature.
- let get_decl (L _ (DeclD hsc_src lmodname mb_hsmod)) =
- Just `fmap` summariseDecl pn hsc_src lmodname mb_hsmod
+ let get_decl (L _ (DeclD hsc_src lmodname hsmod)) =
+ Just `fmap` summariseDecl pn hsc_src lmodname hsmod
get_decl _ = return Nothing
nodes <- catMaybes `fmap` mapM get_decl decls
@@ -806,23 +806,9 @@ summariseRequirement pn mod_name = do
summariseDecl :: PackageName
-> HscSource
-> Located ModuleName
- -> Maybe (Located HsModule)
+ -> Located HsModule
-> BkpM ExtendedModSummary
-summariseDecl pn hsc_src (L _ modname) (Just hsmod) = hsModuleToModSummary pn hsc_src modname hsmod
-summariseDecl _pn hsc_src lmodname@(L loc modname) Nothing
- = do hsc_env <- getSession
- -- TODO: this looks for modules in the wrong place
- r <- liftIO $ summariseModule hsc_env
- emptyModNodeMap -- GHC API recomp not supported
- (hscSourceToIsBoot hsc_src)
- lmodname
- Nothing -- GHC API buffer support not supported
- [] -- No exclusions
- case r of
- Nothing -> throwOneError $ fmap GhcDriverMessage
- $ mkPlainErrorMsgEnvelope loc (DriverBackpackModuleNotFound modname)
- Just (Left err) -> throwErrors (fmap GhcDriverMessage err)
- Just (Right summary) -> return summary
+summariseDecl pn hsc_src (L _ modname) hsmod = hsModuleToModSummary pn hsc_src modname hsmod
-- | Up until now, GHC has assumed a single compilation target per source file.
-- Backpack files with inline modules break this model, since a single file
diff --git a/compiler/GHC/Driver/Backpack/Syntax.hs b/compiler/GHC/Driver/Backpack/Syntax.hs
index a0529fce2e..e67c62d6d8 100644
--- a/compiler/GHC/Driver/Backpack/Syntax.hs
+++ b/compiler/GHC/Driver/Backpack/Syntax.hs
@@ -65,7 +65,7 @@ type LHsUnit n = Located (HsUnit n)
-- | A declaration in a package, e.g. a module or signature definition,
-- or an include.
data HsUnitDecl n
- = DeclD HscSource (Located ModuleName) (Maybe (Located HsModule))
+ = DeclD HscSource (Located ModuleName) (Located HsModule)
| IncludeD (IncludeDecl n)
type LHsUnitDecl n = Located (HsUnitDecl n)
diff --git a/compiler/GHC/Parser.y b/compiler/GHC/Parser.y
index 075f7bff00..9dcf96551e 100644
--- a/compiler/GHC/Parser.y
+++ b/compiler/GHC/Parser.y
@@ -852,18 +852,12 @@ unitdecl :: { LHsUnitDecl PackageName }
NotBoot -> HsSrcFile
IsBoot -> HsBootFile)
(reLoc $3)
- (Just $ sL1 $1 (HsModule noAnn (thdOf3 $7) (Just $3) $5 (fst $ sndOf3 $7) (snd $ sndOf3 $7) $4 Nothing)) }
+ (sL1 $1 (HsModule noAnn (thdOf3 $7) (Just $3) $5 (fst $ sndOf3 $7) (snd $ sndOf3 $7) $4 Nothing)) }
| 'signature' modid maybemodwarning maybeexports 'where' body
{ sL1 $1 $ DeclD
HsigFile
(reLoc $2)
- (Just $ sL1 $1 (HsModule noAnn (thdOf3 $6) (Just $2) $4 (fst $ sndOf3 $6) (snd $ sndOf3 $6) $3 Nothing)) }
- | 'module' maybe_src modid
- { sL1 $1 $ DeclD (case snd $2 of
- NotBoot -> HsSrcFile
- IsBoot -> HsBootFile) (reLoc $3) Nothing }
- | 'signature' modid
- { sL1 $1 $ DeclD HsigFile (reLoc $2) Nothing }
+ (sL1 $1 (HsModule noAnn (thdOf3 $6) (Just $2) $4 (fst $ sndOf3 $6) (snd $ sndOf3 $6) $3 Nothing)) }
| 'dependency' unitid mayberns
{ sL1 $1 $ IncludeD (IncludeDecl { idUnitId = $2
, idModRenaming = $3