Skip to content

Commit

Permalink
refactor(pkg): move [user_restrictions]
Browse files Browse the repository at this point in the history
Signed-off-by: Rudi Grinberg <[email protected]>

<!-- ps-id: b851a03f-e308-43a3-9369-ff69b1d82cc7 -->

Signed-off-by: Rudi Grinberg <[email protected]>
  • Loading branch information
rgrinberg committed Jan 18, 2025
1 parent 3b29a00 commit a9a4e8b
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions src/dune_pkg/opam_solver.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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 }
Expand Down Expand Up @@ -1208,9 +1208,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
Expand Down

0 comments on commit a9a4e8b

Please sign in to comment.