Commit 404581ea authored by Cheah Jer Fei's avatar Cheah Jer Fei 💻 Committed by Marge Bot

Handle single unused import

parent a951e1ba
......@@ -1498,9 +1498,16 @@ warnUnusedImport flag fld_env (L loc decl, used, unused)
| null unused
= return ()
-- Only one import is unused, with `SrcSpan` covering only the unused item instead of
-- the whole import statement
| Just (_, L _ imports) <- ideclHiding decl
, length unused == 1
, Just (L loc _) <- find (\(L _ ie) -> ((ieName ie) :: Name) `elem` unused) imports
= addWarnAt (Reason flag) loc msg2
-- Some imports are unused
| otherwise
= addWarnAt (Reason flag) loc msg2
= addWarnAt (Reason flag) loc msg2
where
msg1 = vcat [ pp_herald <+> quotes pp_mod <+> is_redundant
......
T13064.hs:5:1: warning: [-Wunused-imports (in -Wextra)]
T13064.hs:5:21: warning: [-Wunused-imports (in -Wextra)]
The import of ‘pure’ from module ‘Prelude’ is redundant
......@@ -4,5 +4,5 @@ rn046.hs:2:1: warning: [-Wunused-imports (in -Wextra)]
except perhaps to import instances from ‘Data.List’
To import instances alone, use: import Data.List()
rn046.hs:3:1: warning: [-Wunused-imports (in -Wextra)]
rn046.hs:3:19: warning: [-Wunused-imports (in -Wextra)]
The import of ‘ord’ from module ‘Data.Char’ is redundant
T7454.hs:5:1: warning: [-Wunused-imports (in -Wextra)]
T7454.hs:5:23: warning: [-Wunused-imports (in -Wextra)]
The import of ‘Arrow’ from module ‘Control.Arrow’ is redundant
T8149.hs:5:1: warning: [-Wunused-imports (in -Wextra)]
T8149.hs:5:36: warning: [-Wunused-imports (in -Wextra)]
The import of ‘WriterT’
from module ‘Control.Monad.Trans.Writer’ is redundant
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment