From c23e0044fc86022adcfdc7af3ae150ec4a61069f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ezgi=20=C3=87i=C3=A7ek?= Date: Wed, 10 Jun 2020 07:52:11 -0700 Subject: [PATCH] [infer] Remove ppx_compare workaround for nonrec types (2) Summary: The past issue with ppx_compare on nonrec types has (at some point) been fixed. Greped for `let compare = compare` and removed the workaround for `nonrec`. Reviewed By: jberdine Differential Revision: D21973087 fbshipit-source-id: 5e2043e20 --- infer/src/IR/Exp.ml | 12 +++--------- infer/src/IR/Fieldname.ml | 4 +--- infer/src/IR/Ident.ml | 16 ++++------------ infer/src/IR/JavaClassName.ml | 8 ++------ infer/src/IR/Mangled.ml | 8 ++------ infer/src/IR/Procdesc.ml | 4 +--- infer/src/IR/Procname.ml | 18 ++++-------------- infer/src/IR/Pvar.ml | 4 +--- infer/src/IR/Typ.ml | 8 ++------ infer/src/IR/Var.ml | 4 +--- infer/src/absint/AccessPath.ml | 4 +--- infer/src/absint/CallSite.ml | 4 +--- infer/src/absint/Errlog.ml | 4 +--- infer/src/absint/Passthrough.ml | 4 +--- infer/src/absint/ProcCfg.ml | 8 ++------ infer/src/absint/Sink.ml | 4 +--- infer/src/absint/Source.ml | 12 +++--------- infer/src/base/Location.ml | 4 +--- infer/src/base/SourceFile.ml | 4 +--- infer/src/biabduction/Paths.ml | 4 +--- infer/src/biabduction/RetainCyclesType.ml | 4 +--- infer/src/pulse/PulseAbstractValue.ml | 4 +--- infer/src/test_determinator/JProcname.ml | 5 +---- infer/src/unit/TraceTests.ml | 8 ++------ infer/src/unit/schedulerTests.ml | 4 +--- 25 files changed, 40 insertions(+), 123 deletions(-) diff --git a/infer/src/IR/Exp.ml b/infer/src/IR/Exp.ml index 3e2e05612..a0ed6bf07 100644 --- a/infer/src/IR/Exp.ml +++ b/infer/src/IR/Exp.ml @@ -53,21 +53,15 @@ let equal = [%compare.equal: t] let hash = Hashtbl.hash module Set = Caml.Set.Make (struct - type nonrec t = t - - let compare = compare + type nonrec t = t [@@deriving compare] end) module Map = Caml.Map.Make (struct - type nonrec t = t - - let compare = compare + type nonrec t = t [@@deriving compare] end) module Hash = Hashtbl.Make (struct - type nonrec t = t - - let equal = equal + type nonrec t = t [@@deriving equal] let hash = hash end) diff --git a/infer/src/IR/Fieldname.ml b/infer/src/IR/Fieldname.ml index d1d3c6595..2069f8d02 100644 --- a/infer/src/IR/Fieldname.ml +++ b/infer/src/IR/Fieldname.ml @@ -19,9 +19,7 @@ let get_field_name {field_name} = field_name let is_java {class_name} = Typ.Name.Java.is_class class_name module T = struct - type nonrec t = t - - let compare = compare + type nonrec t = t [@@deriving compare] end module Set = Caml.Set.Make (T) diff --git a/infer/src/IR/Ident.ml b/infer/src/IR/Ident.ml index 3182c8c49..8e631bf4f 100644 --- a/infer/src/IR/Ident.ml +++ b/infer/src/IR/Ident.ml @@ -74,21 +74,15 @@ let equal i1 i2 = (** {2 Set for identifiers} *) module Set = Caml.Set.Make (struct - type nonrec t = t - - let compare = compare + type nonrec t = t [@@deriving compare] end) module Map = Caml.Map.Make (struct - type nonrec t = t - - let compare = compare + type nonrec t = t [@@deriving compare] end) module Hash = Hashtbl.Make (struct - type nonrec t = t - - let equal = equal + type nonrec t = t [@@deriving equal] let hash (id : t) = Hashtbl.hash id end) @@ -240,9 +234,7 @@ let to_string id = F.asprintf "%a" pp id let pp_name f name = F.pp_print_string f (name_to_string name) module HashQueue = Hash_queue.Make (struct - type nonrec t = t - - let compare = compare + type nonrec t = t [@@deriving compare] let hash = Hashtbl.hash diff --git a/infer/src/IR/JavaClassName.ml b/infer/src/IR/JavaClassName.ml index be7672891..43b94e459 100644 --- a/infer/src/IR/JavaClassName.ml +++ b/infer/src/IR/JavaClassName.ml @@ -13,15 +13,11 @@ module L = Logging type t = {classname: string; package: string option} [@@deriving compare, equal] module Map = Caml.Map.Make (struct - type nonrec t = t - - let compare = compare + type nonrec t = t [@@deriving compare] end) module Set = Caml.Set.Make (struct - type nonrec t = t - - let compare = compare + type nonrec t = t [@@deriving compare] end) let make ~package ~classname = diff --git a/infer/src/IR/Mangled.ml b/infer/src/IR/Mangled.ml index b16138188..e8b8f92c9 100644 --- a/infer/src/IR/Mangled.ml +++ b/infer/src/IR/Mangled.ml @@ -49,13 +49,9 @@ let rename ~f {plain; mangled} = module Set = Caml.Set.Make (struct - type nonrec t = t - - let compare = compare + type nonrec t = t [@@deriving compare] end) module Map = Caml.Map.Make (struct - type nonrec t = t - - let compare = compare + type nonrec t = t [@@deriving compare] end) diff --git a/infer/src/IR/Procdesc.ml b/infer/src/IR/Procdesc.ml index e0a148e1b..fe0f8a122 100644 --- a/infer/src/IR/Procdesc.ml +++ b/infer/src/IR/Procdesc.ml @@ -176,9 +176,7 @@ module Node = struct end) module IdMap = PrettyPrintable.MakePPMap (struct - type t = id - - let compare = compare_id + type t = id [@@deriving compare] let pp = pp_id end) diff --git a/infer/src/IR/Procname.ml b/infer/src/IR/Procname.ml index 5b1b8067d..074b9dea9 100644 --- a/infer/src/IR/Procname.ml +++ b/infer/src/IR/Procname.ml @@ -735,11 +735,7 @@ let make_java ~class_name ~return_type ~method_name ~parameters ~kind () = let make_objc_dealloc name = ObjC_Cpp (ObjC_Cpp.make_dealloc name) module Hashable = struct - type nonrec t = t - - let equal = equal - - let compare = compare + type nonrec t = t [@@deriving compare, equal] let hash = hash @@ -751,17 +747,13 @@ module LRUHash = LRUHashtbl.Make (Hashable) module HashQueue = Hash_queue.Make (Hashable) module Map = PrettyPrintable.MakePPMap (struct - type nonrec t = t - - let compare = compare + type nonrec t = t [@@deriving compare] let pp = pp end) module Set = PrettyPrintable.MakePPSet (struct - type nonrec t = t - - let compare = compare + type nonrec t = t [@@deriving compare] let pp = pp end) @@ -801,9 +793,7 @@ let to_filename pname = module SQLite = struct module T = struct - type nonrec t = t - - let compare = compare + type nonrec t = t [@@deriving compare] let hash = hash diff --git a/infer/src/IR/Pvar.ml b/infer/src/IR/Pvar.ml index b46ddbe30..2e776fb3e 100644 --- a/infer/src/IR/Pvar.ml +++ b/infer/src/IR/Pvar.ml @@ -320,9 +320,7 @@ let is_objc_static_local_of_proc_name pname pvar = let is_block_pvar pvar = Typ.has_block_prefix (Mangled.to_string (get_name pvar)) module Set = PrettyPrintable.MakePPSet (struct - type nonrec t = t - - let compare = compare + type nonrec t = t [@@deriving compare] let pp = pp Pp.text end) diff --git a/infer/src/IR/Typ.ml b/infer/src/IR/Typ.ml index ea20d6645..facfddb3e 100644 --- a/infer/src/IR/Typ.ml +++ b/infer/src/IR/Typ.ml @@ -509,17 +509,13 @@ module Name = struct end module Set = PrettyPrintable.MakePPSet (struct - type nonrec t = t - - let compare = compare + type nonrec t = t [@@deriving compare] let pp = pp end) module Map = PrettyPrintable.MakePPMap (struct - type nonrec t = t - - let compare = compare + type nonrec t = t [@@deriving compare] let pp = pp end) diff --git a/infer/src/IR/Var.ml b/infer/src/IR/Var.ml index 1ecf29d65..11e6b7fcc 100644 --- a/infer/src/IR/Var.ml +++ b/infer/src/IR/Var.ml @@ -88,9 +88,7 @@ let get_footprint_index t = module Map = PrettyPrintable.MakePPMap (struct - type nonrec t = t - - let compare = compare + type nonrec t = t [@@deriving compare] let pp = pp end) diff --git a/infer/src/absint/AccessPath.ml b/infer/src/absint/AccessPath.ml index db877d756..c4b996dec 100644 --- a/infer/src/absint/AccessPath.ml +++ b/infer/src/absint/AccessPath.ml @@ -188,9 +188,7 @@ end include Raw module BaseMap = PrettyPrintable.MakePPMap (struct - type t = base - - let compare = compare_base + type t = base [@@deriving compare] let pp = pp_base end) diff --git a/infer/src/absint/CallSite.ml b/infer/src/absint/CallSite.ml index 1b8020738..26e5090ee 100644 --- a/infer/src/absint/CallSite.ml +++ b/infer/src/absint/CallSite.ml @@ -23,9 +23,7 @@ let dummy = make Procname.empty_block Location.dummy let pp fmt t = F.fprintf fmt "%a at %a" Procname.pp t.pname Location.pp t.loc module Set = PrettyPrintable.MakePPSet (struct - type nonrec t = t - - let compare = compare + type nonrec t = t [@@deriving compare] let pp = pp end) diff --git a/infer/src/absint/Errlog.ml b/infer/src/absint/Errlog.ml index 488c2077a..4d6829145 100644 --- a/infer/src/absint/Errlog.ml +++ b/infer/src/absint/Errlog.ml @@ -94,9 +94,7 @@ let compare_err_data err_data1 err_data2 = Location.compare err_data1.loc err_da module ErrDataSet = (* set err_data with no repeated loc *) Caml.Set.Make (struct - type t = err_data - - let compare = compare_err_data + type t = err_data [@@deriving compare] end) (** Hash table to implement error logs *) diff --git a/infer/src/absint/Passthrough.ml b/infer/src/absint/Passthrough.ml index 2f9dc6d50..32811b2f5 100644 --- a/infer/src/absint/Passthrough.ml +++ b/infer/src/absint/Passthrough.ml @@ -18,9 +18,7 @@ let site t = t.site let pp fmt s = CallSite.pp fmt s.site module Set = PrettyPrintable.MakePPSet (struct - type nonrec t = t - - let compare = compare + type nonrec t = t [@@deriving compare] let pp = pp end) diff --git a/infer/src/absint/ProcCfg.ml b/infer/src/absint/ProcCfg.ml index 8002c4a7f..04521663f 100644 --- a/infer/src/absint/ProcCfg.ml +++ b/infer/src/absint/ProcCfg.ml @@ -60,9 +60,7 @@ module DefaultNode : Node with type t = Procdesc.Node.t and type id = Procdesc.N let pp_id = Procdesc.Node.pp_id module OrderedId = struct - type t = id - - let compare = compare_id + type t = id [@@deriving compare] let pp = pp_id end @@ -98,9 +96,7 @@ end = struct let pp_id fmt (id, index) = F.fprintf fmt "(%a: %d)" Procdesc.Node.pp_id id index module OrderedId = struct - type t = id - - let compare = compare_id + type t = id [@@deriving compare] let pp = pp_id end diff --git a/infer/src/absint/Sink.ml b/infer/src/absint/Sink.ml index 8b32380e2..738ec4f67 100644 --- a/infer/src/absint/Sink.ml +++ b/infer/src/absint/Sink.ml @@ -49,9 +49,7 @@ module Make (Kind : Kind) = struct let pp fmt s = F.fprintf fmt "%a(%a)" Kind.pp s.kind CallSite.pp s.site module Set = PrettyPrintable.MakePPSet (struct - type nonrec t = t - - let compare = compare + type nonrec t = t [@@deriving compare] let pp = pp end) diff --git a/infer/src/absint/Source.ml b/infer/src/absint/Source.ml index 967e3e96a..1e3906aed 100644 --- a/infer/src/absint/Source.ml +++ b/infer/src/absint/Source.ml @@ -65,9 +65,7 @@ module Make (Kind : Kind) = struct let with_callsite t callee_site = {t with site= callee_site} module Set = PrettyPrintable.MakePPSet (struct - type nonrec t = t - - let compare = compare + type nonrec t = t [@@deriving compare] let pp = pp end) @@ -93,9 +91,7 @@ module Dummy = struct module Kind = struct - type nonrec t = t - - let compare = compare + type nonrec t = t [@@deriving compare] let matches ~caller ~callee = Int.equal 0 (compare caller callee) @@ -103,9 +99,7 @@ module Dummy = struct end module Set = PrettyPrintable.MakePPSet (struct - type nonrec t = t - - let compare = compare + type nonrec t = t [@@deriving compare] let pp = pp end) diff --git a/infer/src/base/Location.ml b/infer/src/base/Location.ml index 8cb1397f5..ae4b1b0c1 100644 --- a/infer/src/base/Location.ml +++ b/infer/src/base/Location.ml @@ -48,9 +48,7 @@ let pp_range f (loc_start, loc_end) = module Map = PrettyPrintable.MakePPMap (struct - type nonrec t = t - - let compare = compare + type nonrec t = t [@@deriving compare] let pp = pp end) diff --git a/infer/src/base/SourceFile.ml b/infer/src/base/SourceFile.ml index e89df12fd..4daff4193 100644 --- a/infer/src/base/SourceFile.ml +++ b/infer/src/base/SourceFile.ml @@ -24,9 +24,7 @@ type t = let equal = [%compare.equal: t] module OrderedSourceFile = struct - type nonrec t = t - - let compare = compare + type nonrec t = t [@@deriving compare] end module Map = Caml.Map.Make (OrderedSourceFile) diff --git a/infer/src/biabduction/Paths.ml b/infer/src/biabduction/Paths.ml index c48c14c80..7a86a2160 100644 --- a/infer/src/biabduction/Paths.ml +++ b/infer/src/biabduction/Paths.ml @@ -391,9 +391,7 @@ end = struct module PathMap = Caml.Map.Make (struct - type nonrec t = t - - let compare = compare + type nonrec t = t [@@deriving compare] end) let pp fmt path = diff --git a/infer/src/biabduction/RetainCyclesType.ml b/infer/src/biabduction/RetainCyclesType.ml index ba366c6ee..4e43e4894 100644 --- a/infer/src/biabduction/RetainCyclesType.ml +++ b/infer/src/biabduction/RetainCyclesType.ml @@ -50,9 +50,7 @@ let compare (rc1 : t) (rc2 : t) = module Set = Caml.Set.Make (struct - type nonrec t = t - - let compare = compare + type nonrec t = t [@@deriving compare] end) let is_inst_rearrange node = diff --git a/infer/src/pulse/PulseAbstractValue.ml b/infer/src/pulse/PulseAbstractValue.ml index dfce7f461..e8f705e94 100644 --- a/infer/src/pulse/PulseAbstractValue.ml +++ b/infer/src/pulse/PulseAbstractValue.ml @@ -26,9 +26,7 @@ let pp f l = F.fprintf f "v%d" l let of_id v = v module PPKey = struct - type nonrec t = t - - let compare = compare + type nonrec t = t [@@deriving compare] let pp = pp end diff --git a/infer/src/test_determinator/JProcname.ml b/infer/src/test_determinator/JProcname.ml index d2f03539a..7803694c9 100644 --- a/infer/src/test_determinator/JProcname.ml +++ b/infer/src/test_determinator/JProcname.ml @@ -245,10 +245,7 @@ module JNI = struct | FullyQualifiedClass of (string * string) | Array of t | Method of (t list * t) - - let compare = compare - - let equal = equal + [@@deriving compare, equal] let parse_str = parse_str diff --git a/infer/src/unit/TraceTests.ml b/infer/src/unit/TraceTests.ml index ef6c167c5..80d2647cd 100644 --- a/infer/src/unit/TraceTests.ml +++ b/infer/src/unit/TraceTests.ml @@ -27,9 +27,7 @@ module MockTraceElem = struct module Kind = struct - type nonrec t = t - - let compare = compare + type nonrec t = t [@@deriving compare] let matches = matches @@ -37,9 +35,7 @@ module MockTraceElem = struct end module Set = PrettyPrintable.MakePPSet (struct - type nonrec t = t - - let compare = compare + type nonrec t = t [@@deriving compare] let pp = pp end) diff --git a/infer/src/unit/schedulerTests.ml b/infer/src/unit/schedulerTests.ml index b7f4ec990..cc9f1f8ef 100644 --- a/infer/src/unit/schedulerTests.ml +++ b/infer/src/unit/schedulerTests.ml @@ -31,9 +31,7 @@ module MockNode = struct let pp_id fmt i = F.pp_print_int fmt i module OrderedId = struct - type t = id - - let compare = compare_id + type t = id [@@deriving compare] let pp = pp_id end