Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
GHC
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
4,268
Issues
4,268
List
Boards
Labels
Service Desk
Milestones
Iterations
Merge Requests
411
Merge Requests
411
Requirements
Requirements
List
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Code Review
Insights
Issue
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Glasgow Haskell Compiler
GHC
Commits
e6b0189e
Commit
e6b0189e
authored
Nov 06, 2006
by
simonpj@microsoft.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Warn only of explicit imports that are unused (test is mod177)
This is really a long-standing bug. See test mod177.
parent
6f074a37
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
8 deletions
+10
-8
compiler/rename/RnNames.lhs
compiler/rename/RnNames.lhs
+10
-8
No files found.
compiler/rename/RnNames.lhs
View file @
e6b0189e
...
@@ -1134,8 +1134,6 @@ warnDuplicateImports :: [GlobalRdrElt] -> RnM ()
...
@@ -1134,8 +1134,6 @@ warnDuplicateImports :: [GlobalRdrElt] -> RnM ()
warnDuplicateImports gres
warnDuplicateImports gres
= ifOptM Opt_WarnUnusedImports $
= ifOptM Opt_WarnUnusedImports $
sequenceM_ [ warn name pr
sequenceM_ [ warn name pr
-- The 'head' picks the first offending group
-- for this particular name
| GRE { gre_name = name, gre_prov = Imported imps } <- gres
| GRE { gre_name = name, gre_prov = Imported imps } <- gres
, pr <- redundants imps ]
, pr <- redundants imps ]
where
where
...
@@ -1154,7 +1152,12 @@ warnDuplicateImports gres
...
@@ -1154,7 +1152,12 @@ warnDuplicateImports gres
redundants imps
redundants imps
= [ (red_imp, cov_imp)
= [ (red_imp, cov_imp)
| red_imp <- imps
| red_imp <- imps
, isExplicitItem (is_item red_imp)
-- Complain only about redundant imports
-- mentioned explicitly by the user
, cov_imp <- take 1 (filter (covers red_imp) imps) ]
, cov_imp <- take 1 (filter (covers red_imp) imps) ]
-- The 'take 1' picks the first offending group
-- for this particular name
-- "red_imp" is a putative redundant import
-- "red_imp" is a putative redundant import
-- "cov_imp" potentially covers it
-- "cov_imp" potentially covers it
...
@@ -1175,6 +1178,10 @@ warnDuplicateImports gres
...
@@ -1175,6 +1178,10 @@ warnDuplicateImports gres
= False -- They bring into scope different qualified names
= False -- They bring into scope different qualified names
| not (is_qual red_decl) && is_qual cov_decl
| not (is_qual red_decl) && is_qual cov_decl
= False -- Covering one doesn't bring unqualified name into scope
= False -- Covering one doesn't bring unqualified name into scope
| otherwise
= not (isExplicitItem cov_item) -- Redundant one is selective and covering one isn't
|| red_later -- or both are explicit; tie-break using red_later
{-
| red_selective
| red_selective
= not cov_selective -- Redundant one is selective and covering one isn't
= not cov_selective -- Redundant one is selective and covering one isn't
|| red_later -- Both are explicit; tie-break using red_later
|| red_later -- Both are explicit; tie-break using red_later
...
@@ -1182,16 +1189,11 @@ warnDuplicateImports gres
...
@@ -1182,16 +1189,11 @@ warnDuplicateImports gres
= not cov_selective -- Neither import is selective
= not cov_selective -- Neither import is selective
&& (is_mod red_decl == is_mod cov_decl) -- They import the same module
&& (is_mod red_decl == is_mod cov_decl) -- They import the same module
&& red_later -- Tie-break
&& red_later -- Tie-break
-}
where
where
red_loc = importSpecLoc red_imp
red_loc = importSpecLoc red_imp
cov_loc = importSpecLoc cov_imp
cov_loc = importSpecLoc cov_imp
red_later = red_loc > cov_loc
red_later = red_loc > cov_loc
cov_selective = selectiveImpItem cov_item
red_selective = selectiveImpItem red_item
selectiveImpItem :: ImpItemSpec -> Bool
selectiveImpItem ImpAll = False
selectiveImpItem (ImpSome {}) = True
-- ToDo: deal with original imports with 'qualified' and 'as M' clauses
-- ToDo: deal with original imports with 'qualified' and 'as M' clauses
printMinimalImports :: FiniteMap ModuleName AvailEnv -- Minimal imports
printMinimalImports :: FiniteMap ModuleName AvailEnv -- Minimal imports
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment