getIfacesRn `thenRn` \ ifaces ->
let
direct_import_mods :: [Module]
- direct_import_mods = [m | (_, _, Just (m, _, _, _, ImportByUser, _))
- <- eltsFM (iImpModInfo ifaces)]
- -- Pick just the non-back-edge imports
- -- (Back edges are ImportByUserSource)
+ direct_import_mods = [m | (_, _, Just (m, _, _, _, imp, _))
+ <- eltsFM (iImpModInfo ifaces), user_import imp]
+
+ -- *don't* just pick the forward edges. It's entirely possible
+ -- that a module is only reachable via back edges.
+ user_import ImportByUser = True
+ user_import ImportByUserSource = True
+ user_import _ = False
this_module = mkThisModule mod_name
check (HsVar v) = not (isLocallyDefined v)
check (HsApp f a) = check f && check a
check (HsLit _) = False
+ check (HsOverLit _) = False
check (OpApp l o _ r) = check l && check o && check r
check (NegApp e _) = check e
check (HsPar e) = check e
get_details (VanillaCon tys) = plusFVs (map get_bang tys)
get_details (InfixCon t1 t2) = get_bang t1 `plusFV` get_bang t2
get_details (RecCon fields) = plusFVs [get_bang t | (_, t) <- fields]
- get_details (NewCon t _) = extractHsTyNames t
get_field (fs,t) | any (`elemNameSet` source_fvs) fs = get_bang t
| otherwise = emptyFVs
-- unused_imp_mods are the directly-imported modules
-- that are not mentioned in minimal_imports
- unused_imp_mods = [m | m <- direct_import_mods,
- not (maybeToBool (lookupFM minimal_imports m))]
+ unused_imp_mods = [m | m <- direct_import_mods,
+ not (maybeToBool (lookupFM minimal_imports m)),
+ moduleName m /= pRELUDE_Name]
module_unused :: Name -> Bool
-- Name is imported from a module that's completely unused,