Skip to content

Commit bb7defe

Browse files
authored
Remove @no_mutable_implied_modalities (#3962)
1 parent a3342a7 commit bb7defe

File tree

16 files changed

+60
-91
lines changed

16 files changed

+60
-91
lines changed

parsing/builtin_attributes.ml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,6 @@ let builtin_attrs =
113113
; "only_generative_effects"
114114
; "error_message"
115115
; "layout_poly"
116-
; "no_mutable_implied_modalities"
117116
; "or_null_reexport"
118117
; "no_recursive_modalities"
119118
; "jane.non_erasable.instances"
@@ -650,9 +649,6 @@ let parse_standard_implementation_attributes attr =
650649
zero_alloc_attribute ~in_signature:false attr;
651650
unsafe_allow_any_mode_crossing_attribute attr
652651

653-
let has_no_mutable_implied_modalities attrs =
654-
has_attribute "no_mutable_implied_modalities" attrs
655-
656652
let has_local_opt attrs =
657653
has_attribute "local_opt" attrs
658654

parsing/builtin_attributes.mli

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,6 @@ val parse_standard_implementation_attributes : Parsetree.attribute -> unit
212212
val curry_attr_name : string
213213
val curry_attr : Location.t -> Parsetree.attribute
214214

215-
val has_no_mutable_implied_modalities: Parsetree.attributes -> bool
216215
val has_local_opt: Parsetree.attributes -> bool
217216
val has_layout_poly: Parsetree.attributes -> bool
218217
val has_curry: Parsetree.attributes -> bool

testsuite/tests/parsetree/source_jane_street.ml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -601,8 +601,8 @@ type t = { x : string @@ global
601601
type t1 = { mutable x : float
602602
; mutable f : float -> float }
603603

604-
type t2 = { mutable x : float [@no_mutable_implied_modalities]
605-
; mutable f : float -> float [@no_mutable_implied_modalities] }
604+
type t2 = { mutable x : float @@ local once
605+
; mutable f : float -> float @@ local once }
606606

607607
[%%expect{|
608608
type t =
@@ -614,7 +614,10 @@ type t = {
614614
z : string @@ global many;
615615
}
616616
type t1 = { mutable x : float; mutable f : float -> float; }
617-
type t2 = { mutable x : float; mutable f : float -> float; }
617+
type t2 = {
618+
mutable x : float @@ local once;
619+
mutable f : float -> float @@ local once;
620+
}
618621
|}]
619622

620623
let f1 (x @ local) (f @ once) : t1 = exclave_ { x; f }

testsuite/tests/typing-modes/mutable.ml

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,9 @@ type r = {mutable s : string @@ unyielding local}
6464
type r = { mutable s : string @@ local unyielding; }
6565
|}]
6666

67-
(* [@no_mutable_implied_modalities] disables those implied modalities on the
68-
comonadic axes, and allows us to test [mutable] alone *)
69-
70-
(* Note the attribute is not printed back, which might be confusing.
71-
Considering this is a short-term workaround, let's not worry too much. *)
72-
type 'a r = {mutable s : 'a [@no_mutable_implied_modalities]}
67+
type 'a r = {mutable s : 'a @@ local}
7368
[%%expect{|
74-
type 'a r = { mutable s : 'a; }
69+
type 'a r = { mutable s : 'a @@ local; }
7570
|}]
7671

7772
(* We can now construct a local record using a local field. *)
@@ -104,11 +99,11 @@ let foo (local_ r) =
10499
val foo : local_ string r -> unit = <fun>
105100
|}]
106101

107-
(* We can still add modalities explicitly. Of course, the print-back is
108-
confusing. *)
109-
type r' = {mutable s' : string @@ global [@no_mutable_implied_modalities]}
102+
(* We can still add modalities explicitly. But they might be omitted if they are
103+
the same as the mutable-implied ones. *)
104+
type r' = {mutable s' : string @@ global}
110105
[%%expect{|
111-
type r' = { mutable global_ s' : string; }
106+
type r' = { mutable s' : string; }
112107
|}]
113108

114109
let foo (local_ s') = exclave_ {s'}
@@ -152,7 +147,7 @@ Error: This value is "aliased" but expected to be "unique".
152147
|}]
153148

154149
module M : sig
155-
type t = { mutable s : string [@no_mutable_implied_modalities] }
150+
type t = { mutable s : string @@ local }
156151
end = struct
157152
type t = { mutable s : string }
158153
end
@@ -165,39 +160,39 @@ Error: Signature mismatch:
165160
Modules do not match:
166161
sig type t = { mutable s : string; } end
167162
is not included in
168-
sig type t = { mutable s : string; } end
163+
sig type t = { mutable s : string @@ local; } end
169164
Type declarations do not match:
170165
type t = { mutable s : string; }
171166
is not included in
172-
type t = { mutable s : string; }
167+
type t = { mutable s : string @@ local; }
173168
Fields do not match:
174169
"mutable s : string;"
175170
is not the same as:
176-
"mutable s : string;"
171+
"mutable s : string @@ local;"
177172
The first is global and the second is not.
178173
|}]
179174

180175
module M : sig
181176
type t = { mutable s : string }
182177
end = struct
183-
type t = { mutable s : string [@no_mutable_implied_modalities] }
178+
type t = { mutable s : string @@ local}
184179
end
185180
[%%expect{|
186181
Lines 3-5, characters 6-3:
187182
3 | ......struct
188-
4 | type t = { mutable s : string [@no_mutable_implied_modalities] }
183+
4 | type t = { mutable s : string @@ local}
189184
5 | end
190185
Error: Signature mismatch:
191186
Modules do not match:
192-
sig type t = { mutable s : string; } end
187+
sig type t = { mutable s : string @@ local; } end
193188
is not included in
194189
sig type t = { mutable s : string; } end
195190
Type declarations do not match:
196-
type t = { mutable s : string; }
191+
type t = { mutable s : string @@ local; }
197192
is not included in
198193
type t = { mutable s : string; }
199194
Fields do not match:
200-
"mutable s : string;"
195+
"mutable s : string @@ local;"
201196
is not the same as:
202197
"mutable s : string;"
203198
The second is global and the first is not.

testsuite/tests/warnings/w53.compilers.reference

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
File "w53.ml", line 9, characters 24-53:
2-
9 | type r0 = {s : string [@no_mutable_implied_modalities]} (* rejected *)
3-
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
4-
Warning 53 [misplaced-attribute]: the "no_mutable_implied_modalities" attribute cannot appear in this context
5-
61
File "w53.ml", line 15, characters 16-21:
72
15 | val x : int [@alert foo "foo"] (* rejected *)
83
^^^^^

testsuite/tests/warnings/w53.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
check-ocamlc.byte-output;
77
*)
88

9-
type r0 = {s : string [@no_mutable_implied_modalities]} (* rejected *)
10-
type r1 = {mutable s : string [@no_mutable_implied_modalities]} (* accepted *)
9+
10+
1111

1212
module type TestAlertSig = sig
1313
type t1 = Foo1 [@alert foo "foo"] (* accepted *)

typing/jkind.ml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1236,7 +1236,7 @@ let outcometree_of_type = ref (fun _ -> assert false)
12361236

12371237
let set_outcometree_of_type p = outcometree_of_type := p
12381238

1239-
let outcometree_of_modalities_new = ref (fun _ _ _ -> assert false)
1239+
let outcometree_of_modalities_new = ref (fun _ _ -> assert false)
12401240

12411241
let set_outcometree_of_modalities_new p = outcometree_of_modalities_new := p
12421242

@@ -1731,7 +1731,7 @@ module Const = struct
17311731
in
17321732
( !outcometree_of_type type_expr,
17331733
!outcometree_of_modalities_new
1734-
Types.Immutable []
1734+
Types.Immutable
17351735
(modality_to_ignore_axes axes_ignored_by_modalities) ))
17361736
(With_bounds.to_list actual.with_bounds)
17371737
in
@@ -1891,7 +1891,7 @@ module Const = struct
18911891
| Left_jkind (transl_type, _) ->
18921892
let type_ = transl_type type_ in
18931893
let modality =
1894-
Typemode.transl_modalities ~maturity:Stable Immutable [] modalities
1894+
Typemode.transl_modalities ~maturity:Stable Immutable modalities
18951895
in
18961896
{ layout = base.layout;
18971897
mod_bounds = base.mod_bounds;

typing/jkind.mli

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -645,7 +645,6 @@ val set_outcometree_of_type : (Types.type_expr -> Outcometree.out_type) -> unit
645645

646646
val set_outcometree_of_modalities_new :
647647
(Types.mutability ->
648-
Parsetree.attributes ->
649648
Mode.Modality.Value.Const.t ->
650649
Outcometree.out_mode_new list) ->
651650
unit

typing/printtyp.ml

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1421,14 +1421,14 @@ let tree_of_modality_old (t: Parsetree.modality loc) =
14211421
| Modality "global" -> Some (Ogf_legacy Ogf_global)
14221422
| _ -> None
14231423

1424-
let tree_of_modalities mut attrs t =
1425-
let t = Typemode.untransl_modalities mut attrs t in
1424+
let tree_of_modalities mut t =
1425+
let t = Typemode.untransl_modalities mut t in
14261426
match all_or_none tree_of_modality_old t with
14271427
| Some l -> l
14281428
| None -> List.map tree_of_modality_new t
14291429

1430-
let tree_of_modalities_new mut attrs t =
1431-
let l = Typemode.untransl_modalities mut attrs t in
1430+
let tree_of_modalities_new mut t =
1431+
let l = Typemode.untransl_modalities mut t in
14321432
List.map (fun ({txt = Parsetree.Modality s; _}) -> s) l
14331433

14341434
(** [tree_of_mode m l] finds the outcome node in [l] that corresponds to [m].
@@ -1647,7 +1647,7 @@ and tree_of_labeled_typlist mode tyl =
16471647

16481648
and tree_of_typ_gf {ca_type=ty; ca_modalities=gf; _} =
16491649
(tree_of_typexp Type Alloc.Const.legacy ty,
1650-
tree_of_modalities Immutable [] gf)
1650+
tree_of_modalities Immutable gf)
16511651

16521652
(** We are on the RHS of an arrow type, where [ty] is the return type, and [m]
16531653
is the return mode. This function decides the printed modes on [ty].
@@ -1846,9 +1846,7 @@ let tree_of_label l =
18461846
mut
18471847
| Immutable -> Om_immutable
18481848
in
1849-
let ld_modalities =
1850-
tree_of_modalities l.ld_mutable l.ld_attributes l.ld_modalities
1851-
in
1849+
let ld_modalities = tree_of_modalities l.ld_mutable l.ld_modalities in
18521850
(Ident.name l.ld_id, mut, tree_of_typexp Type l.ld_type, ld_modalities)
18531851
18541852
let tree_of_constructor_arguments = function
@@ -2269,8 +2267,7 @@ let tree_of_value_description id decl =
22692267
let vd =
22702268
{ oval_name = id;
22712269
oval_type = Otyp_poly(qtvs, ty);
2272-
oval_modalities =
2273-
tree_of_modalities_new Immutable decl.val_attributes moda;
2270+
oval_modalities = tree_of_modalities_new Immutable moda;
22742271
oval_prims = [];
22752272
oval_attributes = attrs
22762273
}

typing/typecore.ml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2647,7 +2647,7 @@ and type_pat_aux
26472647
solve_Ppat_array ~refine:false loc penv mutability expected_ty
26482648
in
26492649
let modalities =
2650-
Typemode.transl_modalities ~maturity:Stable mutability [] []
2650+
Typemode.transl_modalities ~maturity:Stable mutability []
26512651
in
26522652
check_project_mutability ~loc ~env:!!penv mutability alloc_mode.mode;
26532653
let alloc_mode = Modality.Value.Const.apply modalities alloc_mode.mode in
@@ -9529,9 +9529,7 @@ and type_generic_array
95299529
if Types.is_mutable mutability then Predef.type_array
95309530
else Predef.type_iarray
95319531
in
9532-
let modalities =
9533-
Typemode.transl_modalities ~maturity:Stable mutability [] []
9534-
in
9532+
let modalities = Typemode.transl_modalities ~maturity:Stable mutability [] in
95359533
let argument_mode = mode_modality modalities array_mode in
95369534
let jkind, elt_sort = Jkind.of_new_legacy_sort_var ~why:Array_element in
95379535
let ty = newgenvar jkind in

0 commit comments

Comments
 (0)