forked from coq/coq
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge PR coq#18248: Generalize the deprecation machinery to other for…
…ms of comments Reviewed-by: proux01 Co-authored-by: proux01 <[email protected]>
- Loading branch information
Showing
49 changed files
with
402 additions
and
179 deletions.
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
dev/ci/user-overlays/18248-herbelin-master-extend-deprecation.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
overlay elpi https://github.com/proux01/coq-elpi coq_18248 18248 |
5 changes: 5 additions & 0 deletions
5
doc/changelog/08-vernac-commands-and-options/18248-user_warn.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
- **Added:** | ||
:attr:`warn` attribute generalizing the deprecation | ||
machinery to other forms of comments | ||
(`#18248 <https://github.com/coq/coq/pull/18248>`_, | ||
by Hugo Herbelin and Pierre Roux). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
(************************************************************************) | ||
(* * The Coq Proof Assistant / The Coq Development Team *) | ||
(* v * Copyright INRIA, CNRS and contributors *) | ||
(* <O___,, * (see version control and CREDITS file for authors & dates) *) | ||
(* \VV/ **************************************************************) | ||
(* // * This file is distributed under the terms of the *) | ||
(* * GNU Lesser General Public License Version 2.1 *) | ||
(* * (see LICENSE file for the text of the license) *) | ||
(************************************************************************) | ||
|
||
(** This is about warnings triggered from user .v code ("warn" attibute). | ||
See cWarnings.mli for the generic warning interface. *) | ||
|
||
type warn = { note : string; cats : string } | ||
(** note and comma separated list of categories *) | ||
|
||
type t = { depr : Deprecation.t option; warn : warn list } | ||
|
||
let empty = { depr = None; warn = [] } | ||
|
||
let make_warn ~note ?cats () = | ||
let l = String.split_on_char ',' (Option.default "" cats) in | ||
let l = | ||
List.map String.(fun s -> map (function ' ' -> '-' | c -> c) (trim s)) l in | ||
let l = List.sort String.compare l in | ||
{ note; cats = String.concat "," l } | ||
|
||
let user_warn_cat = CWarnings.CoreCategories.user_warn | ||
|
||
let warn_cats = ref CString.Map.empty | ||
|
||
let get_generic_cat cat = | ||
match CString.Map.find_opt cat !warn_cats with | ||
| Some c -> c | ||
| None -> | ||
let c = CWarnings.create_category ~from:[user_warn_cat] ~name:cat () in | ||
warn_cats := CString.Map.add cat c !warn_cats; | ||
c | ||
|
||
let create_warning ?default ~warning_name_if_no_cats () = | ||
let main_cat, main_w = CWarnings.create_hybrid ?default ~name:warning_name_if_no_cats ~from:[user_warn_cat] () in | ||
let main_w = CWarnings.create_in main_w Pp.strbrk in | ||
let warnings = ref CString.Map.empty in | ||
fun ?loc {note;cats} -> | ||
let w = | ||
if cats = "" then main_w else | ||
match CString.Map.find_opt cats !warnings with | ||
| Some w -> w | ||
| None -> | ||
let l = String.split_on_char ',' cats in | ||
let generic_cats = List.map get_generic_cat l in | ||
let w = CWarnings.create_warning ?default ~from:(main_cat :: generic_cats) | ||
~name:(String.concat "-" (warning_name_if_no_cats :: l)) () in | ||
let w = CWarnings.create_in w Pp.strbrk in | ||
warnings := CString.Map.add cats w !warnings; | ||
w | ||
in | ||
w ?loc note |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
(************************************************************************) | ||
(* * The Coq Proof Assistant / The Coq Development Team *) | ||
(* v * Copyright INRIA, CNRS and contributors *) | ||
(* <O___,, * (see version control and CREDITS file for authors & dates) *) | ||
(* \VV/ **************************************************************) | ||
(* // * This file is distributed under the terms of the *) | ||
(* * GNU Lesser General Public License Version 2.1 *) | ||
(* * (see LICENSE file for the text of the license) *) | ||
(************************************************************************) | ||
|
||
(** This is about warnings triggered from user .v code ("warn" attibute). | ||
See cWarnings.mli for the generic warning interface. *) | ||
|
||
type warn = private { note : string; cats : string } | ||
(** note and comma separated list of categories *) | ||
|
||
type t = { depr : Deprecation.t option; warn : warn list } | ||
|
||
val empty : t | ||
|
||
val make_warn : note:string -> ?cats:string -> unit -> warn | ||
|
||
val create_warning : ?default:CWarnings.status -> warning_name_if_no_cats:string -> | ||
unit -> ?loc:Loc.t -> warn -> unit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.