summaryrefslogtreecommitdiff
path: root/compiler/rename
diff options
context:
space:
mode:
authorIan Lynagh <igloo@earth.li>2011-06-02 00:23:27 +0100
committerIan Lynagh <igloo@earth.li>2011-06-09 13:01:09 +0100
commit5f8f1f244f49543cda309303f065c5bdcf961ea4 (patch)
treeb6640c1a7838a53904077e6448ddb0fcb6476242 /compiler/rename
parent1d746841aafe38044dd9f0de1a8d686ea554a3c7 (diff)
downloadhaskell-srcloc.tar.gz
Refactor SrcLoc and SrcSpansrcloc
The "Unhelpful" cases are now in a separate type. This allows us to improve various things, e.g.: * Most of the panic's in SrcLoc are now gone * The Lexer now works with RealSrcSpans rather than SrcSpans, i.e. it knows that it has real locations and thus can assume that the line number etc really exists * Some of the more suspicious cases are no longer necessary, e.g. we no longer need this case in advanceSrcLoc: advanceSrcLoc loc _ = loc -- Better than nothing More improvements can probably be made, e.g. tick locations can probably use RealSrcSpans too.
Diffstat (limited to 'compiler/rename')
-rw-r--r--compiler/rename/RnEnv.lhs6
-rw-r--r--compiler/rename/RnHsDoc.hs2
-rw-r--r--compiler/rename/RnHsSyn.lhs2
-rw-r--r--compiler/rename/RnNames.lhs4
4 files changed, 10 insertions, 4 deletions
diff --git a/compiler/rename/RnEnv.lhs b/compiler/rename/RnEnv.lhs
index c4ad95a333..b3333731c1 100644
--- a/compiler/rename/RnEnv.lhs
+++ b/compiler/rename/RnEnv.lhs
@@ -1053,7 +1053,11 @@ unknownNameSuggestErr where_look tried_rdr_name
where
pp_item :: (RdrName, HowInScope) -> SDoc
pp_item (rdr, Left loc) = quotes (ppr rdr) <+> -- Locally defined
- parens (ptext (sLit "line") <+> int (srcSpanStartLine loc))
+ parens (ptext (sLit "line") <+> int (srcSpanStartLine loc'))
+ where loc' = case loc of
+ UnhelpfulSpan _ ->
+ panic "unknownNameSuggestErr UnhelpfulSpan"
+ RealSrcSpan l -> l
pp_item (rdr, Right is) = quotes (ppr rdr) <+> -- Imported
parens (ptext (sLit "imported from") <+> ppr (is_mod is))
diff --git a/compiler/rename/RnHsDoc.hs b/compiler/rename/RnHsDoc.hs
index beb45bbfbc..9e53f49320 100644
--- a/compiler/rename/RnHsDoc.hs
+++ b/compiler/rename/RnHsDoc.hs
@@ -3,7 +3,7 @@ module RnHsDoc ( rnHsDoc, rnLHsDoc, rnMbLHsDoc ) where
import TcRnTypes
import HsSyn
-import SrcLoc ( Located(..) )
+import SrcLoc
rnMbLHsDoc :: Maybe LHsDocString -> RnM (Maybe LHsDocString)
diff --git a/compiler/rename/RnHsSyn.lhs b/compiler/rename/RnHsSyn.lhs
index 478ba32655..bfbcdc515f 100644
--- a/compiler/rename/RnHsSyn.lhs
+++ b/compiler/rename/RnHsSyn.lhs
@@ -22,7 +22,7 @@ import TysWiredIn ( tupleTyCon, listTyCon, parrTyCon, charTyCon )
import Name ( Name, getName, isTyVarName )
import NameSet
import BasicTypes ( Boxity )
-import SrcLoc ( Located(..), unLoc )
+import SrcLoc
\end{code}
%************************************************************************
diff --git a/compiler/rename/RnNames.lhs b/compiler/rename/RnNames.lhs
index 46058c4677..3867e17693 100644
--- a/compiler/rename/RnNames.lhs
+++ b/compiler/rename/RnNames.lhs
@@ -1256,7 +1256,9 @@ warnUnusedImportDecls gbl_env
; ifDOptM Opt_D_dump_minimal_imports $
printMinimalImports usage }
where
- explicit_import (L loc _) = isGoodSrcSpan loc
+ explicit_import (L loc _) = case loc of
+ UnhelpfulSpan _ -> False
+ RealSrcSpan _ -> True
-- Filter out the implicit Prelude import
-- which we do not want to bleat about
\end{code}