Skip to content

Commit b3ce767

Browse files
Remove -allow-illegal-crossing (ocaml-flambda#3516)
Now that we have [@@unsafe_allow_any_mode_crossing], which is a more precise way of unsafely mode crossing types, we can remove the -allow-illegal-crossing flag, which was always intended to be temporary, and all its usages. --------- Co-authored-by: Richard Eisenberg <[email protected]>
1 parent 321fc34 commit b3ce767

21 files changed

+28
-1079
lines changed

driver/main_args.ml

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -759,10 +759,6 @@ in
759759
\ allows a set of extensions, and every successive universe includes \n\
760760
\ the previous one."
761761

762-
let mk_allow_illegal_crossing f =
763-
"-allow-illegal-crossing", Arg.Unit f,
764-
"Type declarations will not be checked along the portability or contention axes"
765-
766762
let mk_dump_dir f =
767763
"-dump-dir", Arg.String f,
768764
"redirects any file(s) that would be outputted as a result of other flags\n\
@@ -960,7 +956,6 @@ module type Common_options = sig
960956
val _extension : string -> unit
961957
val _no_extension : string -> unit
962958
val _extension_universe : string -> unit
963-
val _allow_illegal_crossing : unit -> unit
964959
val _noassert : unit -> unit
965960
val _nolabels : unit -> unit
966961
val _nostdlib : unit -> unit
@@ -1249,7 +1244,6 @@ struct
12491244
mk_extension F._extension;
12501245
mk_no_extension F._no_extension;
12511246
mk_extension_universe F._extension_universe;
1252-
mk_allow_illegal_crossing F._allow_illegal_crossing;
12531247
mk_for_pack_byt F._for_pack;
12541248
mk_g_byt F._g;
12551249
mk_no_g F._no_g;
@@ -1381,7 +1375,6 @@ struct
13811375
mk_extension F._extension;
13821376
mk_no_extension F._no_extension;
13831377
mk_extension_universe F._extension_universe;
1384-
mk_allow_illegal_crossing F._allow_illegal_crossing;
13851378
mk_noassert F._noassert;
13861379
mk_noinit F._noinit;
13871380
mk_nolabels F._nolabels;
@@ -1476,7 +1469,6 @@ struct
14761469
mk_extension F._extension;
14771470
mk_no_extension F._no_extension;
14781471
mk_extension_universe F._extension_universe;
1479-
mk_allow_illegal_crossing F._allow_illegal_crossing;
14801472
mk_for_pack_opt F._for_pack;
14811473
mk_g_opt F._g;
14821474
mk_no_g F._no_g;
@@ -1669,7 +1661,6 @@ module Make_opttop_options (F : Opttop_options) = struct
16691661
mk_extension F._extension;
16701662
mk_no_extension F._no_extension;
16711663
mk_extension_universe F._extension_universe;
1672-
mk_allow_illegal_crossing F._allow_illegal_crossing;
16731664
mk_no_float_const_prop F._no_float_const_prop;
16741665
mk_noassert F._noassert;
16751666
mk_noinit F._noinit;
@@ -1778,7 +1769,6 @@ struct
17781769
mk_extension F._extension;
17791770
mk_no_extension F._no_extension;
17801771
mk_extension_universe F._extension_universe;
1781-
mk_allow_illegal_crossing F._allow_illegal_crossing;
17821772
mk_noassert F._noassert;
17831773
mk_nolabels F._nolabels;
17841774
mk_nostdlib F._nostdlib;
@@ -1890,7 +1880,6 @@ module Default = struct
18901880
let _no_extension s = Language_extension.(disable_of_string_exn s)
18911881
let _extension_universe s =
18921882
Language_extension.(set_universe_and_enable_all_of_string_exn s)
1893-
let _allow_illegal_crossing = set Clflags.allow_illegal_crossing
18941883
let _noassert = set noassert
18951884
let _nolabels = set classic
18961885
let _nostdlib = set no_std_include

driver/main_args.mli

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ module type Common_options = sig
3434
val _extension : string -> unit
3535
val _no_extension : string -> unit
3636
val _extension_universe : string -> unit
37-
val _allow_illegal_crossing : unit -> unit
3837
val _noassert : unit -> unit
3938
val _nolabels : unit -> unit
4039
val _nostdlib : unit -> unit

otherlibs/stdlib_alpha/capsule.ml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -302,10 +302,12 @@ module Mutex = struct
302302
; mutex : M.t
303303
; mutable poisoned : bool
304304
}
305+
[@@unsafe_allow_any_mode_crossing]
305306

306-
(* CR: illegal mode crossing on the current version of the compiler,
307-
but should be legal. *)
308307
type packed : value mod portable uncontended = P : 'k t -> packed
308+
[@@unsafe_allow_any_mode_crossing
309+
"CR layouts v2.8: illegal mode crossing on the current version of the compiler, but \
310+
should be legal."]
309311

310312
let[@inline] name t = t.name
311313

@@ -357,8 +359,12 @@ module Rwlock = struct
357359
; rwlock : Rw.t
358360
; mutable poisoned : bool
359361
}
362+
[@@unsafe_allow_any_mode_crossing]
360363

361364
type packed : value mod portable uncontended = P : 'k t -> packed
365+
[@@unsafe_allow_any_mode_crossing
366+
"CR layouts v2.8: This can go away once we have proper mode crossing \
367+
inference for GADT constructors "]
362368

363369
exception Poisoned
364370

otherlibs/stdlib_alpha/capsule.mli

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,9 @@ module Mutex : sig
180180
the capsule ['k] using {!create_with_mutex}. *)
181181

182182
type packed : value mod portable uncontended = P : 'k t -> packed
183+
[@@unsafe_allow_any_mode_crossing
184+
"CR layouts v2.8: This can go away once we have proper mode crossing \
185+
inference for GADT constructors "]
183186
(** [packed] is the type of a mutex for some unknown capsule.
184187
Unpacking one provides a ['k Mutex.t] together with a fresh
185188
existential type brand for ['k]. *)
@@ -219,6 +222,9 @@ module Rwlock : sig
219222
the capsule ['k] using {!create_with_rwlock} *)
220223

221224
type packed : value mod portable uncontended = P : 'k t -> packed
225+
[@@unsafe_allow_any_mode_crossing
226+
"CR layouts v2.8: This can go away once we have proper mode crossing \
227+
inference for GADT constructors "]
222228
(** [packed] is the type of a reader-writer lock for some unknown capsule.
223229
Unpacking one provides a ['k Rwlock.t] together with a fresh existential type
224230
brand for ['k]. *)

otherlibs/stdlib_alpha/dune

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,7 @@
2424
-safe-string
2525
-strict-formats
2626
-extension-universe
27-
alpha
28-
;; Capsule API can't be defined legally.
29-
-allow-illegal-crossing))
27+
alpha))
3028
(ocamlopt_flags
3129
(:include %{project_root}/ocamlopt_flags.sexp))
3230
(foreign_stubs

testsuite/tests/capsule-api/rwlock_capsule.ml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
(* TEST
22
include stdlib_alpha;
3-
flags = "-extension-universe alpha -allow-illegal-crossing";
3+
flags = "-extension-universe alpha";
44
runtime5;
55
{ bytecode; }
66
{ native; }
@@ -19,10 +19,12 @@ type ('a, 'k) _data : value mod portable uncontended = ('a, 'k) Capsule.Data.t
1919
type _packed : value mod portable uncontended = Capsule.Rwlock.packed
2020

2121
(* CR: without [with] syntax and mode crossing inference, we need to depend on
22-
[allow-illegal-crossing] to determine that 'a myref crosses portabilility.
23-
This only holds when 'a also crosses portability *)
22+
[@@unsafe_allow_any_mode_crossing] to determine that 'a myref crosses portabilility.
23+
This only holds when 'a also crosses portability *)
2424

2525
type 'a myref : value mod portable = { mutable v : 'a}
26+
[@@unsafe_allow_any_mode_crossing
27+
"CR layouts v2.8: This can go away once we have with-kinds"]
2628

2729

2830
module RwCell = struct

0 commit comments

Comments
 (0)