Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changes/dead-code-after-drift-8980.internal.md
Original file line number Diff line number Diff line change
@@ -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.
23 changes: 0 additions & 23 deletions compiler/bsc/rescript_compiler_main.mli

This file was deleted.

1 change: 0 additions & 1 deletion compiler/ext/bsc_warnings.ml
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,3 @@
let defaults_w = "+a-4-9-20-41-102"

let defaults_warn_error = "-a+5+101+109"
(*TODO: add +10*)
2 changes: 1 addition & 1 deletion compiler/ext/config.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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
7 changes: 0 additions & 7 deletions compiler/ext/ext_namespace.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down
2 changes: 0 additions & 2 deletions compiler/ext/ext_namespace.mli
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion compiler/jsoo/jsoo_playground_main.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []};
}
Expand Down
5 changes: 3 additions & 2 deletions compiler/ml/ast_helper.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 0 additions & 6 deletions compiler/ml/ast_untagged_variants.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
16 changes: 2 additions & 14 deletions compiler/ml/cmi_format.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down
3 changes: 0 additions & 3 deletions compiler/ml/cmi_format.mli
Original file line number Diff line number Diff line change
Expand Up @@ -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) *)
Expand Down
14 changes: 4 additions & 10 deletions compiler/ml/cmt_format.mli
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,11 @@

(** cmt and cmti files format. *)

(** The layout of a cmt or cmti file is as follows:
<cmt> := \{<cmi>\} <cmt magic> \{cmt infos\}
where <cmi> is the cmi file format:
<cmi> := <cmi magic> <cmi info>.
The compiler no longer writes the optional <cmi> 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 <cmt magic> <cmt infos>; the signature is read
from the .cmi file.

[read] accepts cmi, cmt and cmti files, with or without the <cmi> 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

Expand Down Expand Up @@ -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;
}
Expand Down
22 changes: 3 additions & 19 deletions compiler/ml/cmt_format_common.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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
Expand All @@ -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;
Expand Down
2 changes: 0 additions & 2 deletions compiler/ml/oprint.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 0 additions & 1 deletion compiler/ml/oprint.mli
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 0 additions & 1 deletion compiler/ml/platform/native/cmt_format_persistence.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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 ()};
}
Expand Down
7 changes: 1 addition & 6 deletions compiler/syntax/src/res_outcome_printer.ml
Original file line number Diff line number Diff line change
Expand Up @@ -928,16 +928,11 @@ 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 =
lazy
(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)
1 change: 0 additions & 1 deletion rewatch-ocaml/tests/failure/Broken.invalid

This file was deleted.

4 changes: 0 additions & 4 deletions tests/build_tests/option_transitive_dependency/rescript.json

This file was deleted.

4 changes: 0 additions & 4 deletions tests/build_tests/regexp_statement_formatting/rescript.json

This file was deleted.

9 changes: 0 additions & 9 deletions tests/ounit_tests/ounit_string_tests.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
Loading