Skip to content

Commit

Permalink
rename toplevel_module to old_name for consistency
Browse files Browse the repository at this point in the history
Signed-off-by: Rudi Grinberg <me@rgrinberg.com>
  • Loading branch information
rgrinberg committed Oct 14, 2020
1 parent a1b8f0b commit d453d69
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
6 changes: 3 additions & 3 deletions src/dune_rules/compilation_context.ml
Original file line number Diff line number Diff line change
Expand Up @@ -117,15 +117,15 @@ let context t = Super_context.context t.super_context

type rename =
{ new_name : Module_name.t
; toplevel_module : Module_name.t
; old_name : Module_name.t
}

let renames t =
let open Result.O in
let* renames = t.renames in
Result.List.map renames ~f:(fun (lib, new_name) ->
let* main_module_name = Lib.main_module_name lib in
let+ toplevel_module =
let+ old_name =
match main_module_name with
| Some m -> Ok m
| None ->
Expand All @@ -134,7 +134,7 @@ let renames t =
(User_error.make
[ Pp.text "renaming unwrapped not supported yet" ]))
in
{ new_name; toplevel_module })
{ new_name; old_name })

let create ~super_context ~scope ~expander ~obj_dir ~modules ~flags
~requires_compile ~requires_link ?(preprocessing = Preprocessing.dummy)
Expand Down
2 changes: 1 addition & 1 deletion src/dune_rules/compilation_context.mli
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ val without_bin_annot : t -> t

type rename =
{ new_name : Module_name.t
; toplevel_module : Module_name.t
; old_name : Module_name.t
}

val renames : t -> rename list Or_exn.t
8 changes: 3 additions & 5 deletions src/dune_rules/module_compilation.ml
Original file line number Diff line number Diff line change
Expand Up @@ -310,15 +310,13 @@ let alias_source modules ~renames =
List.sort renames ~compare:(fun (x : Compilation_context.rename) y ->
Module_name.compare x.new_name y.new_name)
|> List.fold_left ~init:([], [])
~f:(fun
(aliases, shadows)
{ Compilation_context.new_name; toplevel_module }
~f:(fun (aliases, shadows) { Compilation_context.new_name; old_name }
->
if Module_name.Map.mem aliased_modules new_name then
(aliases, shadows)
else
let alias = alias new_name toplevel_module in
let shadows = toplevel_module :: shadows in
let alias = alias new_name old_name in
let shadows = old_name :: shadows in
(alias :: aliases, shadows))
in
let shadows =
Expand Down

0 comments on commit d453d69

Please sign in to comment.