imp_mod_name = unLoc loc_imp_mod_name
doc = ppr imp_mod_name <+> ptext (sLit "is directly imported")
- let isExplicit lie = case unLoc lie of
- IEThingAll _ -> False
- _ -> True
+ -- Check for a missing import list
+ -- (Opt_WarnMissingImportList also checks for T(..) items
+ -- but that is done in checkDodgyImport below)
case imp_details of
- Just (False, lies)
- | all isExplicit lies ->
- return ()
- _ ->
- unless implicit_prelude $
- ifDOptM Opt_WarnMissingImportList (addWarn (missingImportListWarn imp_mod_name))
+ Just (False, _) -> return ()
+ _ | implicit_prelude -> return ()
+ | otherwise -> ifDOptM Opt_WarnMissingImportList $
+ addWarn (missingImportListWarn imp_mod_name)
iface <- loadSrcInterface doc imp_mod_name want_boot mb_pkg
| IEThingAll n <- ieRdr, (_, AvailTC _ [_]):_ <- stuff
= ifDOptM Opt_WarnDodgyImports (addWarn (dodgyImportWarn n))
-- NB. use the RdrName for reporting the warning
+ | IEThingAll {} <- ieRdr
+ = ifDOptM Opt_WarnMissingImportList $
+ addWarn (missingImportListItem ieRdr)
checkDodgyImport _
= return ()
= case lookupGRE_Name global_env name of
(gre:_) -> gre
[] -> pprPanic "exportClashErr" (ppr name)
- get_loc name = nameSrcLoc $ gre_name $ get_gre name
+ get_loc name = greSrcSpan (get_gre name)
(name1', ie1', name2', ie2') = if get_loc name1 < get_loc name2
then (name1, ie1, name2, ie2)
else (name2, ie2, name1, ie1)
+-- the SrcSpan that pprNameProvenance prints out depends on whether
+-- the Name is defined locally or not: for a local definition the
+-- definition site is used, otherwise the location of the import
+-- declaration. We want to sort the export locations in
+-- exportClashErr by this SrcSpan, we need to extract it:
+greSrcSpan :: GlobalRdrElt -> SrcSpan
+greSrcSpan gre
+ | Imported (is:_) <- gre_prov gre = is_dloc (is_decl is)
+ | otherwise = name_span
+ where
+ name_span = nameSrcSpan (gre_name gre)
+
addDupDeclErr :: [Name] -> TcRn ()
addDupDeclErr []
= panic "addDupDeclErr: empty list"
missingImportListWarn mod
= ptext (sLit "The module") <+> quotes (ppr mod) <+> ptext (sLit "does not have an explicit import list")
+missingImportListItem :: IE RdrName -> SDoc
+missingImportListItem ie
+ = ptext (sLit "The import item") <+> quotes (ppr ie) <+> ptext (sLit "does not have an explicit import list")
+
moduleWarn :: ModuleName -> WarningTxt -> SDoc
moduleWarn mod (WarningTxt txt)
= sep [ ptext (sLit "Module") <+> quotes (ppr mod) <> ptext (sLit ":"),