summaryrefslogtreecommitdiff
path: root/compiler/rename
diff options
context:
space:
mode:
authorSimon Peyton Jones <simonpj@microsoft.com>2011-07-27 10:39:07 +0100
committerSimon Peyton Jones <simonpj@microsoft.com>2011-07-27 10:39:07 +0100
commit3fdd294af643a86162e544f442b0e36c57e1db36 (patch)
tree898da924ee321de4e5158d0b6fcedf38e8278e6f /compiler/rename
parente84b35aaf9d806ec553bdee3a86feedf96a46904 (diff)
downloadhaskell-3fdd294af643a86162e544f442b0e36c57e1db36.tar.gz
Give a more helpful src location (Trac #5281)
We weren't giving a useful location for the *implicit* import of Prelude. Lennart rightly complained. This fixes it.
Diffstat (limited to 'compiler/rename')
-rw-r--r--compiler/rename/RnNames.lhs16
1 files changed, 9 insertions, 7 deletions
diff --git a/compiler/rename/RnNames.lhs b/compiler/rename/RnNames.lhs
index afec7f59b5..dfd4d3555c 100644
--- a/compiler/rename/RnNames.lhs
+++ b/compiler/rename/RnNames.lhs
@@ -132,16 +132,16 @@ with yes we have gone with no for now.
\begin{code}
-rnImports :: [LImportDecl RdrName]
+rnImports :: SrcSpan -> [LImportDecl RdrName]
-> RnM ([LImportDecl Name], GlobalRdrEnv, ImportAvails, AnyHpcUsage)
-rnImports imports
+rnImports prel_imp_loc imports
-- PROCESS IMPORT DECLS
-- Do the non {- SOURCE -} ones first, so that we get a helpful
-- warning for {- SOURCE -} ones that are unnecessary
= do this_mod <- getModule
implicit_prelude <- xoptM Opt_ImplicitPrelude
- let prel_imports = mkPrelImports (moduleName this_mod)
+ let prel_imports = mkPrelImports (moduleName this_mod) prel_imp_loc
implicit_prelude imports
(source, ordinary) = partition is_source_import imports
is_source_import (L _ (ImportDecl _ _ is_boot _ _ _ _)) = is_boot
@@ -1395,18 +1395,20 @@ warnUnusedImportDecls gbl_env
; let usage :: [ImportDeclUsage]
usage = findImportUsage imports rdr_env (Set.elems uses)
- ; traceRn (ptext (sLit "Import usage") <+> ppr usage)
+ ; traceRn (vcat [ ptext (sLit "Uses:") <+> ppr (Set.elems uses)
+ , ptext (sLit "Import usage") <+> ppr usage])
; ifDOptM Opt_WarnUnusedImports $
mapM_ warnUnusedImport usage
; ifDOptM Opt_D_dump_minimal_imports $
printMinimalImports usage }
where
- explicit_import (L loc _) = case loc of
- UnhelpfulSpan _ -> False
- RealSrcSpan _ -> True
+ explicit_import (L _ decl) = unLoc (ideclName decl) /= pRELUDE_NAME
-- Filter out the implicit Prelude import
-- which we do not want to bleat about
+ -- This also filters out an *explicit* Prelude import
+ -- but solving that problem involves more plumbing, and
+ -- it just doesn't seem worth it
\end{code}
\begin{code}