Skip to content

Commit

Permalink
chore: move Core.withImportModules to Imports.lean
Browse files Browse the repository at this point in the history
This way only `main` is defined in UnusedTransitiveImports.lean,
and hence it should never be necessary to import `UnusedTransitiveImports`.
  • Loading branch information
jcommelin committed Nov 11, 2024
1 parent ac7b989 commit ebcdcf2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 6 additions & 0 deletions ImportGraph/Imports.lean
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,12 @@ def unusedTransitiveImports (amongst : List Name) (verbose : Bool := false) : Co
let unused := (transitiveImports.find? n).getD {} \ (transitivelyRequired.find? n |>.getD {})
amongst.filter (fun m => unused.contains m))

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

/--
Return the redundant imports (i.e. those transitively implied by another import)
of a specified module (or the current module if `none` is specified).
Expand Down
6 changes: 0 additions & 6 deletions ImportGraph/UnusedTransitiveImports.lean
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,6 @@ 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 ...`
Expand Down

0 comments on commit ebcdcf2

Please sign in to comment.