From d453d69e0dcb17c6a0ee4b926023c58843d15499 Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Wed, 14 Oct 2020 11:14:37 -0700 Subject: [PATCH] rename toplevel_module to old_name for consistency Signed-off-by: Rudi Grinberg --- src/dune_rules/compilation_context.ml | 6 +++--- src/dune_rules/compilation_context.mli | 2 +- src/dune_rules/module_compilation.ml | 8 +++----- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/dune_rules/compilation_context.ml b/src/dune_rules/compilation_context.ml index fc63be8d8b43..eb159d9dc493 100644 --- a/src/dune_rules/compilation_context.ml +++ b/src/dune_rules/compilation_context.ml @@ -117,7 +117,7 @@ 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 = @@ -125,7 +125,7 @@ let renames t = 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 -> @@ -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) diff --git a/src/dune_rules/compilation_context.mli b/src/dune_rules/compilation_context.mli index 3d6b5d896ca3..a1205c682bf3 100644 --- a/src/dune_rules/compilation_context.mli +++ b/src/dune_rules/compilation_context.mli @@ -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 diff --git a/src/dune_rules/module_compilation.ml b/src/dune_rules/module_compilation.ml index 91b3628b6491..0fc3fac3051a 100644 --- a/src/dune_rules/module_compilation.ml +++ b/src/dune_rules/module_compilation.ml @@ -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 =