diff --git a/infer/src/istd/PrettyPrintable.ml b/infer/src/istd/PrettyPrintable.ml index a9550794b..34836040e 100644 --- a/infer/src/istd/PrettyPrintable.ml +++ b/infer/src/istd/PrettyPrintable.ml @@ -233,7 +233,7 @@ module type PPUniqRankSet = sig val union_prefer_left : t -> t -> t - val pp : F.formatter -> t -> unit + val pp : ?print_rank:bool -> F.formatter -> t -> unit end module MakePPUniqRankSet (Val : PrintableRankedType) : PPUniqRankSet with type elt = Val.t = struct @@ -273,7 +273,10 @@ module MakePPUniqRankSet (Val : PrintableRankedType) : PPUniqRankSet with type e m - let pp = Map.pp + let pp ?(print_rank = false) fmt map = + if print_rank then Map.pp fmt map + else pp_collection ~pp_item:Val.pp fmt (Map.bindings map |> List.map ~f:snd) + let singleton value = add Map.empty value diff --git a/infer/src/istd/PrettyPrintable.mli b/infer/src/istd/PrettyPrintable.mli index 1779115a9..cba82e0c4 100644 --- a/infer/src/istd/PrettyPrintable.mli +++ b/infer/src/istd/PrettyPrintable.mli @@ -186,7 +186,7 @@ module type PPUniqRankSet = sig (** in case an element with the same rank is present both in [lhs] and [rhs], keep the one from [lhs] in [union_prefer_left lhs rhs] *) - val pp : F.formatter -> t -> unit + val pp : ?print_rank:bool -> F.formatter -> t -> unit end module MakePPUniqRankSet (Val : PrintableRankedType) : PPUniqRankSet with type elt = Val.t