+ return (src_idecls, implicit_imports ++ ordinary_imps, mod)
+
+mkPrelImports :: ModuleName -> Bool -> [LImportDecl RdrName]
+ -> [LImportDecl RdrName]
+-- Consruct the implicit declaration "import Prelude" (or not)
+--
+-- NB: opt_NoImplicitPrelude is slightly different to import Prelude ();
+-- because the former doesn't even look at Prelude.hi for instance
+-- declarations, whereas the latter does.
+mkPrelImports this_mod implicit_prelude import_decls
+ | this_mod == pRELUDE_NAME
+ || explicit_prelude_import
+ || not implicit_prelude
+ = []
+ | otherwise = [preludeImportDecl]
+ where
+ explicit_prelude_import
+ = notNull [ () | L _ (ImportDecl mod Nothing _ _ _ _) <- import_decls,
+ unLoc mod == pRELUDE_NAME ]
+
+ preludeImportDecl :: LImportDecl RdrName
+ preludeImportDecl
+ = L loc $
+ ImportDecl (L loc pRELUDE_NAME)
+ Nothing {- no specific package -}
+ False {- Not a boot interface -}
+ False {- Not qualified -}
+ Nothing {- No "as" -}
+ Nothing {- No import list -}
+
+ loc = mkGeneralSrcSpan (fsLit "Implicit import declaration")
+
+parseError :: SrcSpan -> Message -> IO a