From 2551666d27c54ad0768599ab2f77ab4fbba63252 Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Fri, 17 Jan 2025 23:56:07 +0000 Subject: [PATCH] refactor(pkg): move [user_restrictions] Signed-off-by: Rudi Grinberg Signed-off-by: Rudi Grinberg --- src/dune_pkg/opam_solver.ml | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/src/dune_pkg/opam_solver.ml b/src/dune_pkg/opam_solver.ml index 938facedabb..1a5f8984cf7 100644 --- a/src/dune_pkg/opam_solver.ml +++ b/src/dune_pkg/opam_solver.ml @@ -346,6 +346,14 @@ module Solver = struct include T + let user_restrictions = function + | Virtual _ -> None + | Real role -> + (match Context.user_restrictions role.context role.name with + | None -> None + | Some f -> Some { kind = `Ensure; expr = OpamFormula.Atom f }) + ;; + let pp = pp_role module Map = Map.Make (T) @@ -524,14 +532,6 @@ module Solver = struct Ordering.to_int (Poly.compare b a) ;; - let user_restrictions = function - | Virtual _ -> None - | Real role -> - (match Context.user_restrictions role.context role.name with - | None -> None - | Some f -> Some { kind = `Ensure; expr = OpamFormula.Atom f }) - ;; - let string_of_op = let pos = { OpamParserTypes.FullPos.filename = ""; start = 0, 0; stop = 0, 0 } in fun pelem -> OpamPrinter.FullPos.relop { pelem; pos } @@ -1210,9 +1210,8 @@ module Solver = struct (* Check for user-supplied restrictions *) let examine_extra_restrictions report = Role.Map.iteri report ~f:(fun role component -> - Model.user_restrictions role - |> Option.iter ~f:(fun restriction -> - Component.apply_user_restriction component restriction)) + Model.Role.user_restrictions role + |> Option.iter ~f:(Component.apply_user_restriction component)) ;; module Classes = Map.Make (struct