-nameClashErr (rdr_name, (name1,name2)) sty
- = hang (hsep [ptext SLIT("Conflicting definitions for:"), ppr sty rdr_name])
- 4 (vcat [pprNameProvenance sty name1,
- pprNameProvenance sty name2])
-
-fixityClashErr (rdr_name, (fp1,fp2)) sty
- = hang (hsep [ptext SLIT("Conflicting fixities for:"), ppr sty rdr_name])
- 4 (vcat [pprFixityProvenance sty fp1,
- pprFixityProvenance sty fp2])
-
-shadowedNameWarn shadow sty
- = hcat [ptext SLIT("This binding for"),
- ppr sty shadow,
+warnUnusedBinds, warnUnusedMatches, warnUnusedImports :: NameSet -> RnM s d ()
+
+warnUnusedBinds names
+ | opt_WarnUnusedBinds = warnUnusedNames names
+ | otherwise = returnRn ()
+
+warnUnusedMatches names
+ | opt_WarnUnusedMatches = warnUnusedNames names
+ | otherwise = returnRn ()
+
+warnUnusedImports names
+ | opt_WarnUnusedImports = warnUnusedNames names
+ | otherwise = returnRn ()
+
+warnUnusedNames :: NameSet -> RnM s d ()
+warnUnusedNames names
+ = mapRn warn (nameSetToList names) `thenRn_`
+ returnRn ()
+ where
+ warn name = pushSrcLocRn (getSrcLoc name) $
+ addWarnRn (unusedNameWarn name)
+
+unusedNameWarn name = quotes (ppr name) <+> ptext SLIT("is bound but not used")
+
+addNameClashErrRn (rdr_name, ((_,how_in_scope1), (_, how_in_scope2)))
+ | isClassDataConRdrName rdr_name
+ -- Nasty hack to prevent error messages complain about conflicts for ":C",
+ -- where "C" is a class. There'll be a message about C, and :C isn't
+ -- the programmer's business. There may be a better way to filter this
+ -- out, but I couldn't get up the energy to find it.
+ = returnRn ()
+
+ | otherwise
+ = addErrRn (hang (hsep [ptext SLIT("Conflicting definitions for"), quotes (ppr rdr_name)])
+ 4 (vcat [ppr how_in_scope1,
+ ppr how_in_scope2]))
+
+fixityClashErr (rdr_name, ((_,how_in_scope1), (_, how_in_scope2)))
+ = hang (hsep [ptext SLIT("Conflicting fixities for"), quotes (ppr rdr_name)])
+ 4 (vcat [ppr how_in_scope1,
+ ppr how_in_scope2])
+
+shadowedNameWarn shadow
+ = hsep [ptext SLIT("This binding for"),
+ quotes (ppr shadow),