- unused_imports :: [GlobalRdrElt]
- unused_imports = filter unused_imp defined_but_not_used
- unused_imp (GRE {gre_prov = Imported imp_specs})
- = not (all (module_unused . importSpecModule) imp_specs)
- && or [exp | ImpSpec { is_item = ImpSome { is_explicit = exp } } <- imp_specs]
- -- Don't complain about unused imports if we've already said the
- -- entire import is unused
- unused_imp other = False
+ unused_imports :: [GlobalRdrElt]
+ unused_imports = mapCatMaybes unused_imp defined_but_not_used
+ unused_imp :: GlobalRdrElt -> Maybe GlobalRdrElt -- Result has trimmed Imported provenances
+ unused_imp gre@(GRE {gre_prov = LocalDef}) = Nothing
+ unused_imp gre@(GRE {gre_prov = Imported imp_specs})
+ | null trimmed_specs = Nothing
+ | otherwise = Just (gre {gre_prov = Imported trimmed_specs})
+ where
+ trimmed_specs = filter report_if_unused imp_specs