Skip to content

Commit

Permalink
Remove unused reasons
Browse files Browse the repository at this point in the history
Summary: The `[Contra|In]variant_generic` data constructors are no longer used (replaced by pattern matching on reason) so can be removed

Differential Revision: D69048904

fbshipit-source-id: 34e47dd8dbc45031d7b81864ecd360b7d11142b3
  • Loading branch information
Michael Thomas authored and facebook-github-bot committed Feb 5, 2025
1 parent fd50e29 commit 7a3a7b5
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 100 deletions.
6 changes: 1 addition & 5 deletions hphp/hack/src/oxidized/gen/typing_reason.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// This source code is licensed under the MIT license found in the
// LICENSE file in the "hack" directory of this source tree.
//
// @generated SignedSource<<d166261debd93682ed77ea152fba947d>>
// @generated SignedSource<<fa5b6344fee6fd29456b543a76c37bd9>>
//
// To regenerate this file, run:
// hphp/hack/src/oxidized_regen.sh
Expand Down Expand Up @@ -735,10 +735,6 @@ pub enum T_ {
TypeAccess(Box<T_>, Vec<(Box<T_>, lazy::Lazy<String>)>),
#[rust_to_ocaml(name = "Expr_dep_type")]
ExprDepType(Box<T_>, pos_or_decl::PosOrDecl, ExprDepTypeReason),
#[rust_to_ocaml(name = "Contravariant_generic")]
ContravariantGeneric(Box<T_>, String),
#[rust_to_ocaml(name = "Invariant_generic")]
InvariantGeneric(Box<T_>, String),
#[rust_to_ocaml(name = "Lambda_param")]
LambdaParam(pos::Pos, Box<T_>),
#[rust_to_ocaml(name = "Dynamic_coercion")]
Expand Down
2 changes: 0 additions & 2 deletions hphp/hack/src/oxidized/manual/typing_reason_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,6 @@ impl Reason {
OpaqueTypeFromModule(pos_or_decl, _, _) => Some(pos_or_decl),
LostInfo(_, t, _)
| TypeAccess(t, _)
| InvariantGeneric(t, _)
| ContravariantGeneric(t, _)
| DynamicCoercion(t)
| ExprDepType(t, _, _)
| Typeconst(t, _, _, _)
Expand Down
4 changes: 1 addition & 3 deletions hphp/hack/src/oxidized_by_ref/decl_visitor/node_impl_gen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// This source code is licensed under the MIT license found in the
// LICENSE file in the "hack" directory of this source tree.
//
// @generated SignedSource<<49884b7db749cb8c355c913f14bd1f6c>>
// @generated SignedSource<<327a9543170008c9f6d5e2f5fca34c23>>
//
// To regenerate this file, run:
// hphp/hack/src/oxidized_regen.sh
Expand Down Expand Up @@ -1416,8 +1416,6 @@ impl<'a> Node<'a> for T_<'a> {
T_::Typeconst(ref __binding_0) => __binding_0.accept(v),
T_::TypeAccess(ref __binding_0) => __binding_0.accept(v),
T_::ExprDepType(ref __binding_0) => __binding_0.accept(v),
T_::ContravariantGeneric(ref __binding_0) => __binding_0.accept(v),
T_::InvariantGeneric(ref __binding_0) => __binding_0.accept(v),
T_::LambdaParam(ref __binding_0) => __binding_0.accept(v),
T_::DynamicCoercion(ref __binding_0) => __binding_0.accept(v),
T_::DynamicPartialEnforcement(ref __binding_0) => __binding_0.accept(v),
Expand Down
10 changes: 1 addition & 9 deletions hphp/hack/src/oxidized_by_ref/gen/typing_reason.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// This source code is licensed under the MIT license found in the
// LICENSE file in the "hack" directory of this source tree.
//
// @generated SignedSource<<8ae7adfad9b3b4d8bf43d88ca51e31a4>>
// @generated SignedSource<<1072989237d4a995473e29fd7f1f8831>>
//
// To regenerate this file, run:
// hphp/hack/src/oxidized_regen.sh
Expand Down Expand Up @@ -716,14 +716,6 @@ pub enum T_<'a> {
),
),
#[serde(deserialize_with = "arena_deserializer::arena", borrow)]
#[rust_to_ocaml(name = "Contravariant_generic")]
#[rust_to_ocaml(inline_tuple)]
ContravariantGeneric(&'a (T_<'a>, &'a str)),
#[serde(deserialize_with = "arena_deserializer::arena", borrow)]
#[rust_to_ocaml(name = "Invariant_generic")]
#[rust_to_ocaml(inline_tuple)]
InvariantGeneric(&'a (T_<'a>, &'a str)),
#[serde(deserialize_with = "arena_deserializer::arena", borrow)]
#[rust_to_ocaml(name = "Lambda_param")]
#[rust_to_ocaml(inline_tuple)]
LambdaParam(&'a (&'a pos::Pos<'a>, T_<'a>)),
Expand Down
9 changes: 2 additions & 7 deletions hphp/hack/src/oxidized_by_ref/manual/typing_reason_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,13 +137,10 @@ impl<'a> Reason<'a> {
| SDTCall((p, _))
| LikeCall((p, _))
| OpaqueTypeFromModule((p, _, _)) => Some(p),
LostInfo((_, r, _)) | TypeAccess((r, _)) | InvariantGeneric((r, _)) => r.pos(),
LostInfo((_, r, _)) | TypeAccess((r, _)) => r.pos(),

DynamicCoercion(r) => r.pos(),
ContravariantGeneric((r, _))
| ExprDepType((r, _, _))
| Typeconst((r, _, _, _))
| Instantiate((_, _, r)) => r.pos(),
ExprDepType((r, _, _)) | Typeconst((r, _, _, _)) | Instantiate((_, _, r)) => r.pos(),
_ => None,
}
}
Expand Down Expand Up @@ -176,8 +173,6 @@ impl<'a> std::fmt::Debug for T_<'a> {
Typeconst(p) => f.debug_tuple("Rtypeconst").field(p).finish(),
TypeAccess(p) => f.debug_tuple("RtypeAccess").field(p).finish(),
ExprDepType(p) => f.debug_tuple("RexprDepType").field(p).finish(),
ContravariantGeneric(p) => f.debug_tuple("RcontravariantGeneric").field(p).finish(),
InvariantGeneric(p) => f.debug_tuple("RinvariantGeneric").field(p).finish(),
LambdaParam(p) => f.debug_tuple("RlambdaParam").field(p).finish(),
DynamicPartialEnforcement((p, s, t)) => f
.debug_tuple("RdynamicPartialEnforcement")
Expand Down
72 changes: 2 additions & 70 deletions hphp/hack/src/typing/typing_reason.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1608,8 +1608,6 @@ type _ t_ =
| Expr_dep_type :
'phase t_ * (Pos_or_decl.t[@hash.ignore]) * expr_dep_type_reason
-> 'phase t_
| Contravariant_generic : locl_phase t_ * string -> locl_phase t_
| Invariant_generic : locl_phase t_ * string -> locl_phase t_
| Lambda_param : Pos.t * locl_phase t_ -> locl_phase t_
| Dynamic_coercion : locl_phase t_ -> locl_phase t_
| Dynamic_partial_enforcement :
Expand Down Expand Up @@ -1657,8 +1655,6 @@ let rec to_raw_pos : type ph. ph t_ -> Pos_or_decl.t =
| Def (_, t)
| Lost_info (_, t, _)
| Type_access (t, _)
| Invariant_generic (t, _)
| Contravariant_generic (t, _)
| Dynamic_coercion t ->
to_raw_pos t
| Expr_dep_type (t, _, _) -> to_raw_pos t
Expand Down Expand Up @@ -1709,10 +1705,6 @@ let rec map_pos :
| Expr_dep_type (r, p, n) ->
Expr_dep_type (map_pos pos pos_or_decl r, pos_or_decl p, n)
| Lambda_param (p, r) -> Lambda_param (pos p, map_pos pos pos_or_decl r)
| Contravariant_generic (r1, n) ->
Contravariant_generic (map_pos pos pos_or_decl r1, n)
| Invariant_generic (r1, n) ->
Contravariant_generic (map_pos pos pos_or_decl r1, n)
| Arith_ret_float (p, r, s) ->
Arith_ret_float (pos p, map_pos pos pos_or_decl r, s)
| Arith_ret_num (p, r, s) ->
Expand Down Expand Up @@ -1793,8 +1785,6 @@ let to_constructor_string : type ph. ph t_ -> string = function
| Typeconst _ -> "Rtypeconst"
| Type_access _ -> "Rtype_access"
| Expr_dep_type _ -> "Rexpr_dep_type"
| Contravariant_generic _ -> "Rcontravariant_generic"
| Invariant_generic _ -> "Rinvariant_generic"
| Dynamic_coercion _ -> "Rdynamic_coercion"
| Dynamic_partial_enforcement _ -> "Rdynamic_partial_enforcement"
| Rigid_tvar_escape _ -> "Rrigid_tvar_escape"
Expand Down Expand Up @@ -1905,11 +1895,6 @@ let rec pp_t_ : type ph. _ -> ph t_ -> unit =
Format.pp_print_string fmt s2;
comma ();
pp_t_ fmt r
| Invariant_generic (r, s)
| Contravariant_generic (r, s) ->
pp_t_ fmt r;
comma ();
Format.pp_print_string fmt s
| Lost_info (s, r, b) ->
Format.pp_print_string fmt s;
comma ();
Expand Down Expand Up @@ -2072,16 +2057,6 @@ let rec to_json_help : type a. a t_ -> Hh_json.json list -> Hh_json.json list =
Hh_json.(
JSON_Object [("Lambda_param", JSON_Array [pos_to_json pos; to_json r])])
:: acc
| Contravariant_generic (r, str) ->
Hh_json.(
JSON_Object
[("Contravariant_generic", JSON_Array [to_json r; JSON_String str])])
:: acc
| Invariant_generic (r, str) ->
Hh_json.(
JSON_Object
[("Invariant_generic", JSON_Array [to_json r; JSON_String str])])
:: acc
| Dynamic_coercion r ->
Hh_json.(JSON_Object [("Dynamic_coercion", JSON_Array [to_json r])]) :: acc
| Dynamic_partial_enforcement (pos_or_decl, str, r) ->
Expand Down Expand Up @@ -2436,22 +2411,6 @@ let rec to_string_help :
| Expr_dep_type (r, p, e) ->
to_string_help prefix solutions r
@ [(p, " " ^ expr_dep_type_reason_string e)]
| Contravariant_generic (r_orig, class_name) ->
to_string_help prefix solutions r_orig
@ [
( p,
"This type argument to "
^ (strip_ns class_name |> Markdown_lite.md_codify)
^ " only allows supertypes (it is contravariant)" );
]
| Invariant_generic (r_orig, class_name) ->
to_string_help prefix solutions r_orig
@ [
( p,
"This type argument to "
^ (strip_ns class_name |> Markdown_lite.md_codify)
^ " must match exactly (it is invariant)" );
]
(* If type originated with an unannotated lambda parameter with type variable type,
* suggested annotating the lambda parameter. Otherwise defer to original reason. *)
| Lambda_param
Expand Down Expand Up @@ -2641,10 +2600,6 @@ module Constructors = struct

let unset_field (p, s) = from_witness_locl @@ Unset_field (p, s)

let contravariant_generic (r, s) = Contravariant_generic (r, s)

let invariant_generic (r, s) = Invariant_generic (r, s)

let regex p = from_witness_locl @@ Regex p

let implicit_upper_bound (p, s) =
Expand Down Expand Up @@ -2905,9 +2860,6 @@ module Visitor = struct
| Instantiate (r1, x, r2) ->
Instantiate (this#on_reason r1, x, this#on_reason r2)
| Expr_dep_type (r, y, z) -> Expr_dep_type (this#on_reason r, y, z)
| Contravariant_generic (x, y) ->
Contravariant_generic (this#on_reason x, y)
| Invariant_generic (r, y) -> Invariant_generic (this#on_reason r, y)
| Lambda_param (x, r) -> Lambda_param (x, this#on_reason r)
| Dynamic_coercion r -> Dynamic_coercion (this#on_reason r)
| Dynamic_partial_enforcement (x, y, r) ->
Expand Down Expand Up @@ -3578,10 +3530,6 @@ module Derivation = struct
Expr_dep_type (push_solutions r ~solutions, s, t)
| Lost_info (x, t, y) -> Lost_info (x, push_solutions t ~solutions, y)
| Type_access (t, x) -> Type_access (push_solutions t ~solutions, x)
| Invariant_generic (t, x) ->
Invariant_generic (push_solutions ~solutions t, x)
| Contravariant_generic (t, x) ->
Contravariant_generic (push_solutions ~solutions t, x)
| Dynamic_coercion t -> Dynamic_coercion (push_solutions ~solutions t)
| _ -> t

Expand All @@ -3608,8 +3556,6 @@ module Derivation = struct
| Typeconst _
| Type_access _
| Expr_dep_type _
| Contravariant_generic _
| Invariant_generic _
| Lambda_param _
| Dynamic_coercion _
| Dynamic_partial_enforcement _
Expand Down Expand Up @@ -3642,8 +3588,6 @@ module Derivation = struct
| Typeconst _
| Type_access _
| Expr_dep_type _
| Contravariant_generic _
| Invariant_generic _
| Lambda_param _
| Dynamic_coercion _
| Dynamic_partial_enforcement _
Expand Down Expand Up @@ -3757,16 +3701,14 @@ module Derivation = struct
| ( ( No_reason | From_witness_decl _ | From_witness_locl _
| Instantiate _ | Flow _ | Def _ | Invalid | Missing_field | Idx _
| Arith_ret_float _ | Arith_ret_num _ | Lost_info _ | Format _
| Typeconst _ | Type_access _ | Expr_dep_type _
| Contravariant_generic _ | Invariant_generic _ | Lambda_param _
| Typeconst _ | Type_access _ | Expr_dep_type _ | Lambda_param _
| Dynamic_coercion _ | Dynamic_partial_enforcement _
| Rigid_tvar_escape _ | Opaque_type_from_module _ | SDT_call _
| Like_call _ ),
( No_reason | From_witness_decl _ | From_witness_locl _
| Instantiate _ | Flow _ | Def _ | Invalid | Missing_field | Idx _
| Arith_ret_float _ | Arith_ret_num _ | Lost_info _ | Format _
| Typeconst _ | Type_access _ | Expr_dep_type _
| Contravariant_generic _ | Invariant_generic _ | Lambda_param _
| Typeconst _ | Type_access _ | Expr_dep_type _ | Lambda_param _
| Dynamic_coercion _ | Dynamic_partial_enforcement _
| Rigid_tvar_escape _ | Opaque_type_from_module _ | SDT_call _
| Like_call _ ) ) ->
Expand Down Expand Up @@ -4166,10 +4108,6 @@ module Derivation = struct
| Type_access (r, rs) -> explain_type_access (r, rs) ~st ~cfg ~ctxt
| Expr_dep_type (r, pos, expr_dep_type_reason) ->
explain_expr_dep_type (r, pos, expr_dep_type_reason) ~st ~cfg ~ctxt
| Contravariant_generic (r, nm) ->
explain_contravariant_generic (r, nm) ~st ~cfg ~ctxt
| Invariant_generic (r, nm) ->
explain_invariant_generic (r, nm) ~st ~cfg ~ctxt
| Lambda_param (pos, r) -> explain_lambda_param (pos, r) ~st ~cfg ~ctxt
| Dynamic_coercion r -> explain_dynamic_coercion r ~st ~cfg ~ctxt
| Dynamic_partial_enforcement (pos, nm, r) ->
Expand Down Expand Up @@ -4376,12 +4314,6 @@ module Derivation = struct
and explain_expr_dep_type (r, _pos, _expr_dep_type_reason) ~st ~cfg ~ctxt =
explain_reason r ~st ~cfg ~ctxt

and explain_contravariant_generic (r, _nm) ~st ~cfg ~ctxt =
explain_reason r ~st ~cfg ~ctxt

and explain_invariant_generic (r, _nm) ~st ~cfg ~ctxt =
explain_reason r ~st ~cfg ~ctxt

and explain_lambda_param (pos, _r) ~st ~cfg:_ ~ctxt:_ =
( [Explanation.Witness (Pos_or_decl.of_raw_pos pos, "lambda parameter")],
st )
Expand Down
4 changes: 0 additions & 4 deletions hphp/hack/src/typing/typing_reason.mli
Original file line number Diff line number Diff line change
Expand Up @@ -302,10 +302,6 @@ val missing_optional_field : Pos_or_decl.t * string -> 'phase t_

val unset_field : Pos.t * string -> t

val contravariant_generic : t * string -> t

val invariant_generic : t * string -> t

val regex : Pos.t -> t

val implicit_upper_bound : Pos_or_decl.t * string -> 'phase t_
Expand Down

0 comments on commit 7a3a7b5

Please sign in to comment.