diff --git a/changes/dead-code-after-drift-8980.internal.md b/changes/dead-code-after-drift-8980.internal.md new file mode 100644 index 00000000000..0279fd3d60c --- /dev/null +++ b/changes/dead-code-after-drift-8980.internal.md @@ -0,0 +1 @@ +- Remove dead code, stale comments and unused test inputs left by recent changes, including the unused `cmt_interface_digest` field of `.cmt` files. diff --git a/compiler/bsc/rescript_compiler_main.mli b/compiler/bsc/rescript_compiler_main.mli deleted file mode 100644 index 3999ce7f69e..00000000000 --- a/compiler/bsc/rescript_compiler_main.mli +++ /dev/null @@ -1,23 +0,0 @@ -(* Copyright (C) 2015-2016 Bloomberg Finance L.P. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * In addition to the permissions granted to you by the LGPL, you may combine - * or link a "work that uses the Library" with a publicly distributed version - * of this file to produce a combined library or application, then distribute - * that combined work under the terms of your choosing, with no requirement - * to comply with the obligations normally placed on you by section 4 of the - * LGPL version 3 (or the corresponding section of a later version of the LGPL - * should you choose to use a later version). - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) diff --git a/compiler/ext/bsc_warnings.ml b/compiler/ext/bsc_warnings.ml index 955f9da9be2..d2c2b3dc7f4 100644 --- a/compiler/ext/bsc_warnings.ml +++ b/compiler/ext/bsc_warnings.ml @@ -47,4 +47,3 @@ let defaults_w = "+a-4-9-20-41-102" let defaults_warn_error = "-a+5+101+109" -(*TODO: add +10*) diff --git a/compiler/ext/config.ml b/compiler/ext/config.ml index 1f2c26527d0..a3d5904c212 100644 --- a/compiler/ext/config.ml +++ b/compiler/ext/config.ml @@ -13,7 +13,7 @@ and ast0_impl_magic_number = "Caml1999M022" and ast0_intf_magic_number = "Caml1999N022" -and cmt_magic_number = "Caml1999T047" +and cmt_magic_number = "Caml1999T048" let get_load_path () = (Compiler_request_state.current ()).load_path let set_load_path path = (Compiler_request_state.current ()).load_path <- path diff --git a/compiler/ext/ext_namespace.ml b/compiler/ext/ext_namespace.ml index 619684cefd9..52253d3a094 100644 --- a/compiler/ext/ext_namespace.ml +++ b/compiler/ext/ext_namespace.ml @@ -33,13 +33,6 @@ let rec rindex_rec s i = let change_ext_ns_suffix name ext = let i = rindex_rec name (String.length name - 1) in if i < 0 then name ^ ext else String.sub name 0 i ^ ext -(* FIXME: micro-optimizaiton*) - -let try_split_module_name name = - let len = String.length name in - let i = rindex_rec name (len - 1) in - if i < 0 then None - else Some (String.sub name (i + 1) (len - i - 1), String.sub name 0 i) let js_name_of_modulename s (case : Ext_js_file_kind.case) suffix : string = let s = diff --git a/compiler/ext/ext_namespace.mli b/compiler/ext/ext_namespace.mli index daba3f4a99e..bee1c678035 100644 --- a/compiler/ext/ext_namespace.mli +++ b/compiler/ext/ext_namespace.mli @@ -22,8 +22,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) -val try_split_module_name : string -> (string * string) option - (* Note we have to output uncapitalized file Name, or at least be consistent, since by reading cmi file on Case insensitive OS, we don't really know it is `list.cmi` or `List.cmi`, so that `require (./list.js)` or `require(./List.js)` relevant issues: #1609, #913 diff --git a/compiler/jsoo/jsoo_playground_main.ml b/compiler/jsoo/jsoo_playground_main.ml index 0b84139e32a..109b9ae619f 100644 --- a/compiler/jsoo/jsoo_playground_main.ml +++ b/compiler/jsoo/jsoo_playground_main.ml @@ -508,7 +508,6 @@ module Compile = struct cmt_source_digest = None; cmt_initial_env = env; cmt_imports = []; - cmt_interface_digest = None; cmt_use_summaries = false; cmt_extra_info = {Cmt_utils.deprecated_used = []}; } diff --git a/compiler/ml/ast_helper.ml b/compiler/ml/ast_helper.ml index cf0bf224c1a..e89291e735d 100644 --- a/compiler/ml/ast_helper.ml +++ b/compiler/ml/ast_helper.ml @@ -360,8 +360,9 @@ module Jsx_component = struct (* The first [@react.component], or failing that the first [@react.componentWithProps]: the JSX transform has always given them this precedence. A later one, or one whose payload is not understood, is - left in the attributes for the JSX transform to reject, so that - formatting does not drop it. *) + left in the attributes, so that formatting does not drop it: the JSX + transform takes a payload on a lone [@react.componentWithProps] with a + deprecation warning and rejects the others. *) let take attrs = let take_first is_kind = let rec go seen = function diff --git a/compiler/ml/ast_untagged_variants.ml b/compiler/ml/ast_untagged_variants.ml index 37807fd4455..f4e99def1d8 100644 --- a/compiler/ml/ast_untagged_variants.ml +++ b/compiler/ml/ast_untagged_variants.ml @@ -88,12 +88,6 @@ let literal_tag_to_user_visible_string = function let untagged = "unboxed" -let block_type_can_be_undefined = function - | IntType | StringType | FloatType | BigintType | BooleanType | InstanceType _ - | FunctionType | ObjectType -> - false - | UnknownType -> true - let has_untagged (attrs : Parsetree.attributes) = Ext_list.exists attrs (function {txt}, _ -> txt = untagged) diff --git a/compiler/ml/cmi_format.ml b/compiler/ml/cmi_format.ml index 92a71bd5989..46a4a0594f6 100644 --- a/compiler/ml/cmi_format.ml +++ b/compiler/ml/cmi_format.ml @@ -61,20 +61,8 @@ let read_cmi filename = (fun () -> read_cmi_channel filename ic) ~finally:(fun () -> close_in_noerr ic) -let output_cmi filename oc cmi = - (* beware: the provided signature must have been substituted for saving *) - output_string oc Config.cmi_magic_number; - output_value oc (cmi.cmi_name, cmi.cmi_sign); - flush oc; - let crc = Digest.file (Compiler_request_state.resolve_path filename) in - let crcs = (cmi.cmi_name, Some crc) :: cmi.cmi_crcs in - output_value oc crcs; - output_value oc cmi.cmi_flags; - crc - -(* This function is also called by [save_cmt] as cmi_format is subset of - cmt_format, so dont close the channel yet -*) +(* Writes the .cmi file, keeping an existing one with the same contents + when [check_exists] is given *) let create_cmi ?check_exists filename (cmi : cmi_infos) = (* beware: the provided signature must have been substituted for saving *) let content = diff --git a/compiler/ml/cmi_format.mli b/compiler/ml/cmi_format.mli index 15273591efc..8f21bc6df6c 100644 --- a/compiler/ml/cmi_format.mli +++ b/compiler/ml/cmi_format.mli @@ -22,9 +22,6 @@ type cmi_infos = { cmi_flags: pers_flags list; } -(* write the magic + the cmi information *) -val output_cmi : string -> out_channel -> cmi_infos -> Digest.t - val create_cmi : ?check_exists:unit -> string -> cmi_infos -> Digest.t (* read the cmi information (the magic is supposed to have already been read) *) diff --git a/compiler/ml/cmt_format.mli b/compiler/ml/cmt_format.mli index 75953e14641..fccae7f2225 100644 --- a/compiler/ml/cmt_format.mli +++ b/compiler/ml/cmt_format.mli @@ -15,16 +15,11 @@ (** cmt and cmti files format. *) -(** The layout of a cmt or cmti file is as follows: - := \{\} \{cmt infos\} - where is the cmi file format: - := . - The compiler no longer writes the optional part: the signature is - read from the .cmi file. Files written by older compilers have it in a - cmti, and in the cmt of a module without an interface. +(** A cmt or cmti file is ; the signature is read + from the .cmi file. - [read] accepts cmi, cmt and cmti files, with or without the part, - and returns an option for the cmi info and the cmt info. *) + [read] accepts cmi, cmt and cmti files and returns the cmi info of a cmi + file and the cmt info of a cmt or cmti file. *) open Typedtree @@ -56,7 +51,6 @@ type cmt_infos = { cmt_source_digest: Digest.t option; cmt_initial_env: Env.t; cmt_imports: (string * Digest.t option) list; - cmt_interface_digest: Digest.t option; cmt_use_summaries: bool; cmt_extra_info: Cmt_utils.cmt_extra_info; } diff --git a/compiler/ml/cmt_format_common.ml b/compiler/ml/cmt_format_common.ml index 9ad18767174..9a7b25a222a 100644 --- a/compiler/ml/cmt_format_common.ml +++ b/compiler/ml/cmt_format_common.ml @@ -48,7 +48,6 @@ type cmt_infos = { cmt_source_digest: Digest.t option; cmt_initial_env: Env.t; cmt_imports: (string * Digest.t option) list; - cmt_interface_digest: Digest.t option; cmt_use_summaries: bool; cmt_extra_info: Cmt_utils.cmt_extra_info; } @@ -103,13 +102,8 @@ exception Error of error let input_cmt ic = (input_value ic : cmt_infos) -(** [read filename] opens filename, and extract both the cmi_infos, if - it exists, and the cmt_infos, if it exists. Thus, it can be used - with .cmi, .cmt and .cmti files. - - The compiler no longer writes a cmi_infos in front of the cmt_infos in - .cmt and .cmti files, but files from older compilers may contain one. -*) +(** [read filename] reads a .cmi file as its cmi_infos, or a .cmt or .cmti + file as its cmt_infos. *) let read filename = (* Printf.fprintf stderr "Cmt_format.read %s\n%!" filename; *) let ic = open_in_bin (Compiler_request_state.resolve_path filename) in @@ -118,17 +112,7 @@ let read filename = let cmi, cmt = if magic_number = Config.cmt_magic_number then (None, Some (input_cmt ic)) else if magic_number = Config.cmi_magic_number then - let cmi = Cmi_format.input_cmi ic in - let cmt = - try - let magic_number = read_magic_number ic in - if magic_number = Config.cmt_magic_number then - let cmt = input_cmt ic in - Some cmt - else None - with _ -> None - in - (Some cmi, cmt) + (Some (Cmi_format.input_cmi ic), None) else raise (Cmi_format.Error (Cmi_format.Not_an_interface filename)) in close_in ic; diff --git a/compiler/ml/oprint.ml b/compiler/ml/oprint.ml index 3665f810c2a..398af99b295 100644 --- a/compiler/ml/oprint.ml +++ b/compiler/ml/oprint.ml @@ -28,5 +28,3 @@ let out_sig_item : (Format.formatter -> out_sig_item -> unit) ref = ref not_set_up let out_signature : (Format.formatter -> out_sig_item list -> unit) ref = ref not_set_up -let out_type_extension : (Format.formatter -> out_type_extension -> unit) ref = - ref not_set_up diff --git a/compiler/ml/oprint.mli b/compiler/ml/oprint.mli index 32b5fe65ed9..8f3b949ce02 100644 --- a/compiler/ml/oprint.mli +++ b/compiler/ml/oprint.mli @@ -20,4 +20,3 @@ val out_type : (formatter -> out_type -> unit) ref val out_module_type : (formatter -> out_module_type -> unit) ref val out_sig_item : (formatter -> out_sig_item -> unit) ref val out_signature : (formatter -> out_sig_item list -> unit) ref -val out_type_extension : (formatter -> out_type_extension -> unit) ref diff --git a/compiler/ml/platform/native/cmt_format_persistence.ml b/compiler/ml/platform/native/cmt_format_persistence.ml index 49c13c5caa5..0b1f1c8ba60 100644 --- a/compiler/ml/platform/native/cmt_format_persistence.ml +++ b/compiler/ml/platform/native/cmt_format_persistence.ml @@ -46,7 +46,6 @@ let save_cmt filename modname binary_annots sourcefile initial_env = (if need_to_clear_env then keep_only_summary initial_env else initial_env); cmt_imports = List.sort compare (Env.imports ()); - cmt_interface_digest = None; cmt_use_summaries = need_to_clear_env; cmt_extra_info = {deprecated_used = deprecated_uses ()}; } diff --git a/compiler/syntax/src/res_outcome_printer.ml b/compiler/syntax/src/res_outcome_printer.ml index 1c8c4095844..7ad5747e513 100644 --- a/compiler/syntax/src/res_outcome_printer.ml +++ b/compiler/syntax/src/res_outcome_printer.ml @@ -928,10 +928,6 @@ let print_out_module_type fmt out_module_type = Format.pp_print_string fmt (Doc.to_string ~width:80 (print_out_module_type_doc out_module_type)) -let print_out_type_extension fmt type_extension = - Format.pp_print_string fmt - (Doc.to_string ~width:80 (print_out_type_extension_doc type_extension)) - (* Not supported in ReScript *) (* Oprint.out_class_type *) let setup = @@ -939,5 +935,4 @@ let setup = (Oprint.out_type := print_out_type; Oprint.out_module_type := print_out_module_type; Oprint.out_sig_item := print_out_sig_item; - Oprint.out_signature := print_out_signature; - Oprint.out_type_extension := print_out_type_extension) + Oprint.out_signature := print_out_signature) diff --git a/rewatch-ocaml/tests/failure/Broken.invalid b/rewatch-ocaml/tests/failure/Broken.invalid deleted file mode 100644 index 0e3ce71961b..00000000000 --- a/rewatch-ocaml/tests/failure/Broken.invalid +++ /dev/null @@ -1 +0,0 @@ -let value: string = 42 diff --git a/tests/build_tests/option_transitive_dependency/rescript.json b/tests/build_tests/option_transitive_dependency/rescript.json deleted file mode 100644 index 2cd03417343..00000000000 --- a/tests/build_tests/option_transitive_dependency/rescript.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "name": "option_transitive_dependency", - "sources": [] -} diff --git a/tests/build_tests/regexp_statement_formatting/rescript.json b/tests/build_tests/regexp_statement_formatting/rescript.json deleted file mode 100644 index 0517d76218d..00000000000 --- a/tests/build_tests/regexp_statement_formatting/rescript.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "name": "regexp-statement-formatting", - "sources": [] -} diff --git a/tests/ounit_tests/ounit_string_tests.ml b/tests/ounit_tests/ounit_string_tests.ml index 68a3fd0c3d1..8abc0ffbf00 100644 --- a/tests/ounit_tests/ounit_string_tests.ml +++ b/tests/ounit_tests/ounit_string_tests.ml @@ -134,15 +134,6 @@ let suites = =~ "AA.js"; Ext_namespace.js_name_of_modulename "AA-b" Upper ".bs.js" =~ "AA.bs.js" ); - ( __LOC__ >:: fun _ -> - let ( =~ ) = - OUnit.assert_equal ~printer:(fun x -> - match x with - | None -> "" - | Some (a, b) -> a ^ "," ^ b) - in - Ext_namespace.try_split_module_name "Js-X" =~ Some ("X", "Js"); - Ext_namespace.try_split_module_name "Js_X" =~ None ); ( __LOC__ >:: fun _ -> let k = Ext_modulename.js_id_name_of_hint_name in k "xx" =~ "Xx";