From a952a776b835c931ea8a17b5e2915c6a1f0c11d6 Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Fri, 25 Aug 2023 23:14:49 +0100 Subject: [PATCH] fix: ignoring promotion rules Bug #4401 was `(promote until-clean)` rules being incorrectly ignored by `--ignore-promoted-rules`. PR #5956 fixed it but only made the fix available to newer projects. This means that projects must update their dune versions before users can actually build this project without being affected by this bug. Since this bug fix doesn't have much the potential to break anything, we make the fix available to all versions. Signed-off-by: Rudi Grinberg --- src/dune_rules/dune_file.ml | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/src/dune_rules/dune_file.ml b/src/dune_rules/dune_file.ml index 0ccce3d676ac..3bcf5eadbc10 100644 --- a/src/dune_rules/dune_file.ml +++ b/src/dune_rules/dune_file.ml @@ -2464,19 +2464,16 @@ type t = } let is_promoted_rule = - let is_promoted_mode version = function + let is_promoted_mode = function | Rule.Mode.Promote { only = None; lifetime; _ } -> - if version >= (3, 5) - then ( - match lifetime with - | Unlimited -> true - | Until_clean -> false) - else true + (match lifetime with + | Unlimited -> true + | Until_clean -> false) | _ -> false in - fun version rule -> + fun rule -> match rule with - | Rule { mode; _ } | Menhir_stanza.T { mode; _ } -> is_promoted_mode version mode + | Rule { mode; _ } | Menhir_stanza.T { mode; _ } -> is_promoted_mode mode | _ -> false ;; @@ -2485,9 +2482,7 @@ let parse sexps ~dir ~file ~project = let+ stanzas = Stanzas.parse ~file ~dir project sexps in let stanzas = if !Clflags.ignore_promoted_rules - then ( - let version = Dune_project.dune_version project in - List.filter stanzas ~f:(fun s -> not (is_promoted_rule version s))) + then List.filter stanzas ~f:(fun s -> not (is_promoted_rule s)) else stanzas in { dir; project; stanzas }