Skip to content

Commit 4060ee0

Browse files
authored
Delete promote-foo syntax in favour of (promote foo) (#5091)
We planned to delete the [promote-foo] syntax in Dune 2 but forgot. Let's do this now. Signed-off-by: Andrey Mokhov <amokhov@janestreet.com>
1 parent 04167da commit 4060ee0

File tree

4 files changed

+110
-21
lines changed

4 files changed

+110
-21
lines changed

CHANGES.md

+3
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,9 @@ Unreleased
257257
- Add experimental support for directory targets (#3316, #5025, Andrey Mokhov),
258258
enabled via `(using directory-targets 0.1)` in `dune-project`.
259259

260+
- Delete old `promote-into`, `promote-until-clean` and `promote-until-clean-into`
261+
syntax (#5091, Andrey Mokhov).
262+
260263
2.9.2 (unreleased)
261264
------------------
262265

doc/dune-files.rst

-11
Original file line numberDiff line numberDiff line change
@@ -1061,17 +1061,6 @@ this behavior using the ``mode`` field. The following modes are available:
10611061
<dune-subdirs>`, specified using the :ref:`predicate-lang`. This feature
10621062
has been available since Dune 1.10.
10631063

1064-
- ``promote-until-clean`` is the same as ``(promote (until-clean))``.
1065-
- ``(promote-into <dir>)`` is the same as ``(promote (into <dir>))``.
1066-
- ``(promote-until-clean-into <dir>)`` is the same as ``(promote
1067-
(until-clean) (into <dir>))``.
1068-
1069-
The ``(promote <options>)`` form has only been available since Dune
1070-
1.10. Before Dune 1.10, you needed to use one of the ``promote-...``
1071-
forms. The ``promote-...`` forms should disappear in Dune 2.0, so
1072-
using the more generic ``(promote <options>)`` form is preferred
1073-
for new projects.
1074-
10751064
There are two use cases for ``promote`` rules. The first one is when the
10761065
generated code is easier to review than the generator, so it's easier
10771066
to commit the generated code and review it. The second is to cut down

src/dune_rules/dune_file.ml

+23-10
Original file line numberDiff line numberDiff line change
@@ -1541,22 +1541,35 @@ module Rule = struct
15411541
include Rule.Mode
15421542

15431543
let mode_decoders =
1544-
let promote_into lifetime =
1545-
let+ () = Dune_lang.Syntax.since Stanza.syntax (1, 8)
1546-
and+ into = Promote.into_decode in
1547-
Rule.Mode.Promote { lifetime; into = Some into; only = None }
1548-
in
15491544
[ ("standard", return Rule.Mode.Standard)
15501545
; ("fallback", return Rule.Mode.Fallback)
15511546
; ( "promote"
15521547
, let+ p = Promote.decode in
15531548
Rule.Mode.Promote p )
15541549
; ( "promote-until-clean"
1555-
, return
1556-
(Rule.Mode.Promote
1557-
{ lifetime = Until_clean; into = None; only = None }) )
1558-
; ("promote-into", promote_into Unlimited)
1559-
; ("promote-until-clean-into", promote_into Until_clean)
1550+
, let+ () =
1551+
Dune_lang.Syntax.deleted_in Stanza.syntax (3, 0)
1552+
~extra_info:"Use the (promote (until-clean)) syntax instead."
1553+
in
1554+
Rule.Mode.Promote { lifetime = Until_clean; into = None; only = None }
1555+
)
1556+
; ( "promote-into"
1557+
, let+ () = Dune_lang.Syntax.since Stanza.syntax (1, 8)
1558+
and+ () =
1559+
Dune_lang.Syntax.deleted_in Stanza.syntax (3, 0)
1560+
~extra_info:"Use the (promote (into <dir>)) syntax instead."
1561+
and+ into = Promote.into_decode in
1562+
Rule.Mode.Promote
1563+
{ lifetime = Unlimited; into = Some into; only = None } )
1564+
; ( "promote-until-clean-into"
1565+
, let+ () = Dune_lang.Syntax.since Stanza.syntax (1, 8)
1566+
and+ () =
1567+
Dune_lang.Syntax.deleted_in Stanza.syntax (3, 0)
1568+
~extra_info:
1569+
"Use the (promote (until-clean) (into <dir>)) syntax instead."
1570+
and+ into = Promote.into_decode in
1571+
Rule.Mode.Promote
1572+
{ lifetime = Until_clean; into = Some into; only = None } )
15601573
]
15611574

15621575
module Extended = struct
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
Test that [promote-foo] syntax is deleted in Dune 3.0 with good error messages.
2+
3+
First, check that the syntax still works with Dune 2.9.
4+
5+
$ echo "(lang dune 2.9)" > dune-project
6+
$ cat >dune <<EOF
7+
> (rule
8+
> (targets promoted)
9+
> (action (with-stdout-to promoted (echo "Hello, world!")))
10+
> (mode (promote-into subdir)))
11+
> (rule
12+
> (targets promoted-until-clean)
13+
> (action (with-stdout-to promoted-until-clean (echo "Hello again!")))
14+
> (mode promote-until-clean))
15+
> EOF
16+
17+
$ mkdir subdir
18+
$ dune build promoted promoted-until-clean
19+
$ cat subdir/promoted
20+
Hello, world!
21+
$ cat promoted-until-clean
22+
Hello again!
23+
$ dune clean
24+
$ cat subdir/promoted
25+
Hello, world!
26+
$ cat promoted-until-clean
27+
cat: promoted-until-clean: No such file or directory
28+
[1]
29+
30+
Now switch to Dune 3.0.
31+
32+
$ echo "(lang dune 3.0)" > dune-project
33+
$ dune build promoted
34+
File "dune", line 4, characters 7-28:
35+
4 | (mode (promote-into subdir)))
36+
^^^^^^^^^^^^^^^^^^^^^
37+
Error: 'promote-into' was deleted in version 3.0 of the dune language. Use
38+
the (promote (into <dir>)) syntax instead.
39+
[1]
40+
41+
$ cat >dune <<EOF
42+
> (rule
43+
> (targets promoted)
44+
> (action (with-stdout-to promoted (echo "Hello again!")))
45+
> (mode (promote-until-clean-into subdir)))
46+
> EOF
47+
$ dune build promoted
48+
File "dune", line 4, characters 7-40:
49+
4 | (mode (promote-until-clean-into subdir)))
50+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
51+
Error: 'promote-until-clean-into' was deleted in version 3.0 of the dune
52+
language. Use the (promote (until-clean) (into <dir>)) syntax instead.
53+
[1]
54+
55+
$ cat >dune <<EOF
56+
> (rule
57+
> (targets promoted)
58+
> (action (with-stdout-to promoted (echo "Hello again!")))
59+
> (mode promote-until-clean))
60+
> EOF
61+
$ dune build promoted
62+
File "dune", line 4, characters 7-26:
63+
4 | (mode promote-until-clean))
64+
^^^^^^^^^^^^^^^^^^^
65+
Error: 'promote-until-clean' was deleted in version 3.0 of the dune language.
66+
Use the (promote (until-clean)) syntax instead.
67+
[1]
68+
69+
Test that the hint works.
70+
71+
$ cat >dune <<EOF
72+
> (rule
73+
> (targets promoted)
74+
> (action (with-stdout-to promoted (echo "Hello again!")))
75+
> (mode (promote (until-clean))))
76+
> EOF
77+
78+
$ dune build promoted
79+
$ cat promoted
80+
Hello again!
81+
$ dune clean
82+
$ cat promoted
83+
cat: promoted: No such file or directory
84+
[1]

0 commit comments

Comments
 (0)