-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #39 from leanprover-community/fast_unusedTransitiv…
…eImports feat: fast unused transitive imports
- Loading branch information
Showing
6 changed files
with
99 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import ImportGraph.Imports | ||
|
||
open Lean | ||
|
||
def Core.withImportModules (modules : Array Name) {α} (f : CoreM α) : IO α := do | ||
searchPathRef.set compile_time_search_path% | ||
unsafe Lean.withImportModules (modules.map (fun m => {module := m})) {} (trustLevel := 1024) | ||
fun env => Prod.fst <$> Core.CoreM.toIO | ||
(ctx := { fileName := "<CoreM>", fileMap := default }) (s := { env := env }) do f | ||
|
||
/-- | ||
`lake exe unused_transitive_imports m1 m2 ...` | ||
For each specified module `m`, prints those `n` from the argument list which are imported, but transitively unused by `m`. | ||
-/ | ||
def main (args : List String) : IO UInt32 := do | ||
let (flags, args) := args.partition (fun s => s.startsWith "-") | ||
let mut modules := args.map (fun s => s.toName) | ||
Core.withImportModules modules.toArray do | ||
let r ← unusedTransitiveImports modules (verbose := flags.contains "-v" || flags.contains "--verbose") | ||
for (n, u) in r do | ||
IO.println s!"{n}: {u}" | ||
return 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters