Skip to content

Commit

Permalink
rules: remove unnecessary changes in dune_pkg Entry.t
Browse files Browse the repository at this point in the history
Signed-off-by: Javier Chávarri <[email protected]>
  • Loading branch information
jchavarri committed Mar 26, 2024
1 parent 02b7186 commit 86bd245
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 15 deletions.
12 changes: 6 additions & 6 deletions src/dune_rules/dune_package.ml
Original file line number Diff line number Diff line change
Expand Up @@ -362,12 +362,12 @@ end
module Entry = struct
type t =
| Library of Lib.t
| Deprecated_library_name of Path.t * Deprecated_library_name.t
| Deprecated_library_name of Deprecated_library_name.t
| Hidden_library of Lib.t

let name = function
| Library lib | Hidden_library lib -> Lib_info.name (Lib.info lib)
| Deprecated_library_name (_, d) -> d.old_public_name
| Deprecated_library_name d -> d.old_public_name
;;

let version = function
Expand All @@ -377,7 +377,7 @@ module Entry = struct

let loc = function
| Library lib | Hidden_library lib -> Lib_info.loc (Lib.info lib)
| Deprecated_library_name (_, d) -> d.loc
| Deprecated_library_name d -> d.loc
;;

let sentinel = function
Expand All @@ -394,15 +394,15 @@ module Entry = struct
Library lib )
; ( "deprecated_library_name"
, let+ x = Deprecated_library_name.decode in
Deprecated_library_name (dir, x) )
Deprecated_library_name x )
]
;;

let to_dyn x =
let open Dyn in
match x with
| Library lib -> variant "Library" [ Lib.to_dyn lib ]
| Deprecated_library_name (_, lib) ->
| Deprecated_library_name lib ->
variant "Deprecated_library_name" [ Deprecated_library_name.to_dyn lib ]
| Hidden_library lib -> variant "Hidden_library" [ Lib.to_dyn lib ]
;;
Expand Down Expand Up @@ -527,7 +527,7 @@ let encode ~dune_version { entries; name; version; dir; sections; sites; files }
match e with
| Entry.Library lib ->
list (Dune_lang.atom "library" :: Lib.encode lib ~package_root:dir ~stublibs)
| Deprecated_library_name (_, d) ->
| Deprecated_library_name d ->
list (Dune_lang.atom "deprecated_library_name" :: Deprecated_library_name.encode d)
| Hidden_library lib ->
Code_error.raise
Expand Down
2 changes: 1 addition & 1 deletion src/dune_rules/dune_package.mli
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ end
module Entry : sig
type t =
| Library of Lib.t
| Deprecated_library_name of Path.t * Deprecated_library_name.t
| Deprecated_library_name of Deprecated_library_name.t
| Hidden_library of Lib.t
(** Only for external libraries that:
Expand Down
9 changes: 4 additions & 5 deletions src/dune_rules/findlib.ml
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,10 @@ end
let builtin_for_dune : Dune_package.t =
let entry =
Dune_package.Entry.Deprecated_library_name
( Path.external_ Path.External.initial_cwd
, { loc = Loc.of_pos __POS__
; old_public_name = Lib_name.of_string "dune.configurator"
; new_public_name = Lib_name.of_string "dune-configurator"
} )
{ loc = Loc.of_pos __POS__
; old_public_name = Lib_name.of_string "dune.configurator"
; new_public_name = Lib_name.of_string "dune-configurator"
}
in
{ name = Opam_package.Name.of_string "dune"
; entries = Lib_name.Map.singleton (Dune_package.Entry.name entry) entry
Expand Down
4 changes: 2 additions & 2 deletions src/dune_rules/install_rules.ml
Original file line number Diff line number Diff line change
Expand Up @@ -629,7 +629,7 @@ end = struct
(Some
( old_public_name
, Dune_package.Entry.Deprecated_library_name
(Path.build pkg_root, { loc; old_public_name; new_public_name }) ))
{ loc; old_public_name; new_public_name } ))
| Library (sentinel, lib) ->
let info = Lib.Local.info lib in
let dir = Lib_info.src_dir info in
Expand Down Expand Up @@ -764,7 +764,7 @@ end = struct
acc
old_public_name
(Dune_package.Entry.Deprecated_library_name
(dir, { loc; old_public_name; new_public_name })))
{ loc; old_public_name; new_public_name }))
in
let sections = sections ctx.name [] pkg in
{ Dune_package.version = Package.version pkg
Expand Down
2 changes: 1 addition & 1 deletion src/dune_rules/lib.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1978,7 +1978,7 @@ module DB = struct
Findlib.find findlib name
>>| function
| Ok (Library pkg) -> Resolve_result (Found (Dune_package.Lib.info pkg))
| Ok (Deprecated_library_name (_, d)) ->
| Ok (Deprecated_library_name d) ->
Resolve_result (Redirect_in_the_same_db (d.loc, d.new_public_name))
| Ok (Hidden_library pkg) ->
Resolve_result (Hidden (Hidden.unsatisfied_exist_if pkg))
Expand Down

0 comments on commit 86bd245

Please sign in to comment.