From b5ce0971dc49fbfb2632745fd7995824e32c3845 Mon Sep 17 00:00:00 2001 From: Hunter Goldstein Date: Fri, 10 Sep 2021 11:06:00 -0700 Subject: [PATCH] Rip out support for `Rx/IS_ENABLED` Summary: We do a ton of special handling for this in the typechecker / compiler. I think this handling is *partially* dead, so let's just kill it entirely. I've left the constant itself there, but we can also remove that if desired. Reviewed By: Wilfred Differential Revision: D30720410 fbshipit-source-id: 6385307e68160bf683831691140bf275408b77ec --- hphp/hack/src/hhbc/hhbc_by_ref/hhas_coeffects.rs | 20 -------------------- hphp/hack/src/naming/naming_special_names.ml | 4 ---- hphp/hack/src/naming/naming_special_names.rs | 4 ---- hphp/hack/src/typing/typing.ml | 14 -------------- hphp/hack/src/typing/typing_local_ops.ml | 3 --- hphp/hack/src/typing/typing_local_ops.mli | 3 --- 6 files changed, 48 deletions(-) diff --git a/hphp/hack/src/hhbc/hhbc_by_ref/hhas_coeffects.rs b/hphp/hack/src/hhbc/hhbc_by_ref/hhas_coeffects.rs index 7bfb35dcbdb..9996de91c03 100644 --- a/hphp/hack/src/hhbc/hhbc_by_ref/hhas_coeffects.rs +++ b/hphp/hack/src/hhbc/hhbc_by_ref/hhas_coeffects.rs @@ -412,26 +412,6 @@ impl<'arena> HhasCoeffects<'arena> { } } -pub fn halves_of_is_enabled_body( - body: &a::FuncBody, -) -> Option<(&a::Block, &a::Block)> { - use a::*; - if let [Stmt(_, Stmt_::If(if_))] = body.fb_ast.as_slice() { - if let (Expr(_, _, Expr_::Id(sid)), enabled, disabled) = &**if_ { - let Id(_, name) = &**sid; - return if name != sn::rx::IS_ENABLED { - None - } else { - match disabled.as_slice() { - [] | [Stmt(_, Stmt_::Noop)] => None, - _ => Some((enabled, disabled)), - } - }; - } - } - None -} - #[allow(clippy::needless_lifetimes)] #[no_mangle] pub unsafe extern "C" fn no_call_compile_only_USED_TYPES_hhas_ctx_constant<'arena>( diff --git a/hphp/hack/src/naming/naming_special_names.ml b/hphp/hack/src/naming/naming_special_names.ml index 0a482c00742..a8057e55c6e 100644 --- a/hphp/hack/src/naming/naming_special_names.ml +++ b/hphp/hack/src/naming/naming_special_names.ml @@ -723,10 +723,6 @@ module HH = struct let contains_key = "\\HH\\Lib\\C\\contains_key" end -module Rx = struct - let is_enabled = "\\HH\\Rx\\IS_ENABLED" -end - module Shapes = struct let cShapes = "\\HH\\Shapes" diff --git a/hphp/hack/src/naming/naming_special_names.rs b/hphp/hack/src/naming/naming_special_names.rs index 71df3591b35..687417286a2 100644 --- a/hphp/hack/src/naming/naming_special_names.rs +++ b/hphp/hack/src/naming/naming_special_names.rs @@ -739,10 +739,6 @@ pub mod hh { pub const CONTAINS_KEY: &str = "\\HH\\Lib\\C\\contains_key"; } -pub mod rx { - pub const IS_ENABLED: &str = "\\HH\\Rx\\IS_ENABLED"; -} - pub mod readonly { pub const AS_MUT: &str = "\\HH\\Readonly\\as_mut"; } diff --git a/hphp/hack/src/typing/typing.ml b/hphp/hack/src/typing/typing.ml index 4e40ad811bc..415c105fcdd 100644 --- a/hphp/hack/src/typing/typing.ml +++ b/hphp/hack/src/typing/typing.ml @@ -8149,20 +8149,6 @@ and condition ?lhs_of_null_coalesce env tparamet ((ty, p, e) as te : Tast.expr) Ast_defs.Eqeqeq in condition env (not tparamet) (ty, p, Aast.Binop (op, e1, e2)) - | Aast.Id (p, s) when String.equal s SN.Rx.is_enabled -> - (* when Rx\IS_ENABLED is false - switch env to non-reactive *) - let env = - if not tparamet then - if TypecheckerOptions.any_coeffects (Env.get_tcopt env) then - let env = Typing_local_ops.enforce_rx_is_enabled p env in - let defaults = MakeType.default_capability Pos_or_decl.none in - fst @@ Typing_coeffects.register_capabilities env defaults defaults - else - env - else - env - in - (env, Local_id.Set.empty) (* Conjunction of conditions. Matches the two following forms: if (cond1 && cond2) if (!(cond1 || cond2)) diff --git a/hphp/hack/src/typing/typing_local_ops.ml b/hphp/hack/src/typing/typing_local_ops.ml index 5ca4024dfd0..5478a0a9735 100644 --- a/hphp/hack/src/typing/typing_local_ops.ml +++ b/hphp/hack/src/typing/typing_local_ops.ml @@ -85,9 +85,6 @@ let enforce_memoize_object = let enforce_io = enforce_local_capability Capabilities.(mk io) "`echo` or `print` builtin" -let enforce_rx_is_enabled = - enforce_local_capability Capabilities.(mk rx) ("`" ^ SN.Rx.is_enabled ^ "`") - let enforce_enum_class_variant = enforce_local_capability Capabilities.(mk writeProperty) diff --git a/hphp/hack/src/typing/typing_local_ops.mli b/hphp/hack/src/typing/typing_local_ops.mli index 53d15768320..5228ad76ea9 100644 --- a/hphp/hack/src/typing/typing_local_ops.mli +++ b/hphp/hack/src/typing/typing_local_ops.mli @@ -19,9 +19,6 @@ val enforce_memoize_object : val enforce_mutable_static_variable : ?msg:string -> Pos.t -> Typing_env_types.env -> Typing_env_types.env -val enforce_rx_is_enabled : - Pos.t -> Typing_env_types.env -> Typing_env_types.env - val enforce_enum_class_variant : Pos.t -> Typing_env_types.env -> Typing_env_types.env -- 2.11.4.GIT