Skip to content

Commit 8721957

Browse files
Merge PR #16237: Revert (most of) #15802
Reviewed-by: Alizter Ack-by: Zimmi48 Co-authored-by: Alizter <[email protected]>
2 parents 09e32ca + 14392e4 commit 8721957

File tree

7 files changed

+23
-74
lines changed

7 files changed

+23
-74
lines changed

doc/sphinx/addendum/type-classes.rst

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -274,20 +274,12 @@ This declares singleton classes for reflexive and transitive relations,
274274
(see the :ref:`singleton class <singleton-class>` variant for an
275275
explanation). These may be used as parts of other classes:
276276

277-
.. coqtop:: none
278-
279-
Set Warnings "-future-coercion-class-field".
280-
281277
.. coqtop:: all
282278

283279
Class PreOrder (A : Type) (R : relation A) :=
284280
{ PreOrder_Reflexive :> Reflexive A R ;
285281
PreOrder_Transitive :> Transitive A R }.
286282

287-
.. coqtop:: none
288-
289-
Set Warnings "+future-coercion-class-field".
290-
291283
The syntax ``:>`` indicates that each ``PreOrder`` can be seen as a
292284
``Reflexive`` relation. So each time a reflexive relation is needed, a
293285
preorder can be used instead. This is very similar to the coercion
@@ -340,17 +332,6 @@ Summary of the commands
340332

341333
This command has no effect when used on a typeclass.
342334

343-
.. _warn-future-coercion-class-field:
344-
345-
.. warn:: A coercion will be introduced in future versions when using ':>' in 'Class' declarations. Use '#[global] Existing Instance field.' instead if you don't want the coercion.
346-
347-
In future versions, :g:`:>` will also
348-
declare a :ref:`coercion<coercions>`, as it does
349-
for other :cmd:`Record` commands.
350-
To eliminate the warning or to avoid creating the coercion
351-
in the future, use :cmd:`Existing Instance` or :cmd:`Coercion` separately rather
352-
than :g:`:>`.
353-
354335
.. warn:: Ignored instance declaration for “@ident”: “@term” is not a class
355336

356337
Using this ``:>`` syntax with a right-hand-side that is not itself a Class

doc/sphinx/changes.rst

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -331,13 +331,11 @@ Commands and options
331331
(`#15760 <https://github.com/coq/coq/pull/15760>`_,
332332
by Pierre Roux).
333333
- **Added:**
334-
A deprecation warning that :n:`>` in a field of a :cmd:`Class`
335-
and the :g:`Class >` syntax will in the future also
336-
declare :ref:`coercions <coercions>` as they do when used in
334+
A deprecation warning that the :g:`Class >` syntax, that is currently
335+
doing nothing, will in the future
336+
declare :ref:`coercions <coercions>` as it does when used in
337337
:cmd:`Record` commands
338338
(`#15802 <https://github.com/coq/coq/pull/15802>`_,
339-
addresses `#2643 <https://github.com/coq/coq/issues/2643>`_
340-
and `#9014 <https://github.com/coq/coq/issues/9014>`_,
341339
by Pierre Roux, reviewed by Gaëtan Gilbert, Ali Caglayan,
342340
Jason Gross, Jim Fehrle and Théo Zimmermann).
343341
- **Added:**

doc/sphinx/language/core/records.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,6 @@ Defining record types
9191
If specified, the field is declared as a coercion from the record name
9292
to the class of the field type. See :ref:`coercions`.
9393
Note that this currently does something else in :cmd:`Class` commands.
94-
See :ref:`warning in Class <warn-future-coercion-class-field>`.
9594

9695
- :n:`{+ @binder } : @of_type` is equivalent to
9796
:n:`: forall {+ @binder } , @of_type`

theories/Classes/CRelationClasses.v

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -70,18 +70,14 @@ Section Defs.
7070
(** A [PreOrder] is both Reflexive and Transitive. *)
7171

7272
Class PreOrder (R : crelation A) := {
73-
PreOrder_Reflexive : Reflexive R | 2 ;
74-
PreOrder_Transitive : Transitive R | 2 }.
75-
#[global] Existing Instance PreOrder_Reflexive.
76-
#[global] Existing Instance PreOrder_Transitive.
73+
PreOrder_Reflexive :> Reflexive R | 2 ;
74+
PreOrder_Transitive :> Transitive R | 2 }.
7775

7876
(** A [StrictOrder] is both Irreflexive and Transitive. *)
7977

8078
Class StrictOrder (R : crelation A) := {
81-
StrictOrder_Irreflexive : Irreflexive R ;
82-
StrictOrder_Transitive : Transitive R }.
83-
#[global] Existing Instance StrictOrder_Irreflexive.
84-
#[global] Existing Instance StrictOrder_Transitive.
79+
StrictOrder_Irreflexive :> Irreflexive R ;
80+
StrictOrder_Transitive :> Transitive R }.
8581

8682
(** By definition, a strict order is also asymmetric *)
8783
Global Instance StrictOrder_Asymmetric `(StrictOrder R) : Asymmetric R.
@@ -90,20 +86,15 @@ Section Defs.
9086
(** A partial equivalence crelation is Symmetric and Transitive. *)
9187

9288
Class PER (R : crelation A) := {
93-
PER_Symmetric : Symmetric R | 3 ;
94-
PER_Transitive : Transitive R | 3 }.
95-
#[global] Existing Instance PER_Symmetric.
96-
#[global] Existing Instance PER_Transitive.
89+
PER_Symmetric :> Symmetric R | 3 ;
90+
PER_Transitive :> Transitive R | 3 }.
9791

9892
(** Equivalence crelations. *)
9993

10094
Class Equivalence (R : crelation A) := {
101-
Equivalence_Reflexive : Reflexive R ;
102-
Equivalence_Symmetric : Symmetric R ;
103-
Equivalence_Transitive : Transitive R }.
104-
#[global] Existing Instance Equivalence_Reflexive.
105-
#[global] Existing Instance Equivalence_Symmetric.
106-
#[global] Existing Instance Equivalence_Transitive.
95+
Equivalence_Reflexive :> Reflexive R ;
96+
Equivalence_Symmetric :> Symmetric R ;
97+
Equivalence_Transitive :> Transitive R }.
10798

10899
(** An Equivalence is a PER plus reflexivity. *)
109100

theories/Classes/RelationClasses.v

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -60,18 +60,14 @@ Section Defs.
6060
(** A [PreOrder] is both Reflexive and Transitive. *)
6161

6262
Class PreOrder (R : relation A) : Prop := {
63-
PreOrder_Reflexive : Reflexive R | 2 ;
64-
PreOrder_Transitive : Transitive R | 2 }.
65-
#[global] Existing Instance PreOrder_Reflexive.
66-
#[global] Existing Instance PreOrder_Transitive.
63+
PreOrder_Reflexive :> Reflexive R | 2 ;
64+
PreOrder_Transitive :> Transitive R | 2 }.
6765

6866
(** A [StrictOrder] is both Irreflexive and Transitive. *)
6967

7068
Class StrictOrder (R : relation A) : Prop := {
71-
StrictOrder_Irreflexive : Irreflexive R ;
72-
StrictOrder_Transitive : Transitive R }.
73-
#[global] Existing Instance StrictOrder_Irreflexive.
74-
#[global] Existing Instance StrictOrder_Transitive.
69+
StrictOrder_Irreflexive :> Irreflexive R ;
70+
StrictOrder_Transitive :> Transitive R }.
7571

7672
(** By definition, a strict order is also asymmetric *)
7773
Global Instance StrictOrder_Asymmetric `(StrictOrder R) : Asymmetric R.
@@ -80,20 +76,15 @@ Section Defs.
8076
(** A partial equivalence relation is Symmetric and Transitive. *)
8177

8278
Class PER (R : relation A) : Prop := {
83-
PER_Symmetric : Symmetric R | 3 ;
84-
PER_Transitive : Transitive R | 3 }.
85-
#[global] Existing Instance PER_Symmetric.
86-
#[global] Existing Instance PER_Transitive.
79+
PER_Symmetric :> Symmetric R | 3 ;
80+
PER_Transitive :> Transitive R | 3 }.
8781

8882
(** Equivalence relations. *)
8983

9084
Class Equivalence (R : relation A) : Prop := {
91-
Equivalence_Reflexive : Reflexive R ;
92-
Equivalence_Symmetric : Symmetric R ;
93-
Equivalence_Transitive : Transitive R }.
94-
#[global] Existing Instance Equivalence_Reflexive.
95-
#[global] Existing Instance Equivalence_Symmetric.
96-
#[global] Existing Instance Equivalence_Transitive.
85+
Equivalence_Reflexive :> Reflexive R ;
86+
Equivalence_Symmetric :> Symmetric R ;
87+
Equivalence_Transitive :> Transitive R }.
9788

9889
(** An Equivalence is a PER plus reflexivity. *)
9990

theories/Classes/SetoidClass.v

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@ Require Export Coq.Classes.Morphisms.
2929

3030
Class Setoid A := {
3131
equiv : relation A ;
32-
setoid_equiv : Equivalence equiv }.
33-
#[global] Existing Instance setoid_equiv.
32+
setoid_equiv :> Equivalence equiv }.
3433

3534
(* Too dangerous instance *)
3635
(* Program Instance [ eqa : Equivalence A eqA ] => *)
@@ -136,8 +135,7 @@ Program Instance setoid_partial_app_morphism `(sa : Setoid A) (x : A) : Proper (
136135
(** Partial setoids don't require reflexivity so we can build a partial setoid on the function space. *)
137136

138137
Class PartialSetoid (A : Type) :=
139-
{ pequiv : relation A ; pequiv_prf : PER pequiv }.
140-
#[global] Existing Instance pequiv_prf.
138+
{ pequiv : relation A ; pequiv_prf :> PER pequiv }.
141139

142140
(** Overloaded notation for partial setoid equivalence. *)
143141

vernac/record.ml

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -788,13 +788,6 @@ let warn_future_coercion_class_constructor =
788788
~default:CWarnings.AsError
789789
Pp.(fun () -> str "'Class >' currently does nothing. Use 'Class' instead.")
790790

791-
(* deprecated in 8.16, to be removed at the end of the deprecation phase
792-
(c.f., https://github.com/coq/coq/pull/15802 ) *)
793-
let warn_future_coercion_class_field =
794-
CWarnings.create ~name:"future-coercion-class-field" ~category:"records" Pp.(fun () ->
795-
str "A coercion will be introduced in future versions when using ':>' in 'Class' declarations. "
796-
++ str "Use '#[global] Existing Instance field.' instead if you don't want the coercion.")
797-
798791
(** [declare_class] will prepare and declare a [Class]. This is done in
799792
2 steps:
800793
@@ -822,8 +815,6 @@ let warn_future_coercion_class_field =
822815
let declare_class ~univs params inds def data =
823816
let id, idbuild, rdata, is_coercion, coers, inhabitant_id = get_class_params data in
824817
if is_coercion then warn_future_coercion_class_constructor ();
825-
if List.exists (fun pf -> pf <> None) coers then
826-
warn_future_coercion_class_field ();
827818
let fields = rdata.DataR.fields in
828819
let map ind =
829820
let map decl b y = {

0 commit comments

Comments
 (0)