Skip to content

Commit 98f5d69

Browse files
cknittclaude
andauthored
Remove dead code, stale comments and unused test inputs (#8991)
Why: Recent removals left definitions without callers, which no warning reports because they are exported or in a module without an interface: Cmi_format.output_cmi, the always-None cmt_interface_digest, the read of a cmt after an embedded cmi (unreachable since the magic bumps of #8805 and #8928), Oprint.out_type_extension, Ext_namespace.try_split_module_name and Ast_untagged_variants.block_type_can_be_undefined. Comments that promised older .cmt layouts, a JSX transform rejection that #8944 made a deprecation, and a TODO for a removed warning are corrected, and the empty rescript_compiler_main.mli and three unused test inputs removed. Review: Why does the cmt magic number change? Removing cmt_interface_digest changes the marshalled cmt_infos record, so .cmt files of the previous layout must be rejected rather than misread: T047 becomes T048. Claude-Session: https://claude.ai/code/session_01Xk6AeCYpCK4SZRtHYKHGoe Signed-off-by: Christoph Knittel <ck@cca.io> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 74f2031 commit 98f5d69

21 files changed

Lines changed: 15 additions & 117 deletions
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- Remove dead code, stale comments and unused test inputs left by recent changes, including the unused `cmt_interface_digest` field of `.cmt` files.

‎compiler/bsc/rescript_compiler_main.mli‎

Lines changed: 0 additions & 23 deletions
This file was deleted.

‎compiler/ext/bsc_warnings.ml‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,3 @@
4747
let defaults_w = "+a-4-9-20-41-102"
4848

4949
let defaults_warn_error = "-a+5+101+109"
50-
(*TODO: add +10*)

‎compiler/ext/config.ml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ and ast0_impl_magic_number = "Caml1999M022"
1313

1414
and ast0_intf_magic_number = "Caml1999N022"
1515

16-
and cmt_magic_number = "Caml1999T047"
16+
and cmt_magic_number = "Caml1999T048"
1717

1818
let get_load_path () = (Compiler_request_state.current ()).load_path
1919
let set_load_path path = (Compiler_request_state.current ()).load_path <- path

‎compiler/ext/ext_namespace.ml‎

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,6 @@ let rec rindex_rec s i =
3333
let change_ext_ns_suffix name ext =
3434
let i = rindex_rec name (String.length name - 1) in
3535
if i < 0 then name ^ ext else String.sub name 0 i ^ ext
36-
(* FIXME: micro-optimizaiton*)
37-
38-
let try_split_module_name name =
39-
let len = String.length name in
40-
let i = rindex_rec name (len - 1) in
41-
if i < 0 then None
42-
else Some (String.sub name (i + 1) (len - i - 1), String.sub name 0 i)
4336

4437
let js_name_of_modulename s (case : Ext_js_file_kind.case) suffix : string =
4538
let s =

‎compiler/ext/ext_namespace.mli‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@
2222
* along with this program; if not, write to the Free Software
2323
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)
2424

25-
val try_split_module_name : string -> (string * string) option
26-
2725
(* Note we have to output uncapitalized file Name,
2826
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)`
2927
relevant issues: #1609, #913

‎compiler/jsoo/jsoo_playground_main.ml‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -508,7 +508,6 @@ module Compile = struct
508508
cmt_source_digest = None;
509509
cmt_initial_env = env;
510510
cmt_imports = [];
511-
cmt_interface_digest = None;
512511
cmt_use_summaries = false;
513512
cmt_extra_info = {Cmt_utils.deprecated_used = []};
514513
}

‎compiler/ml/ast_helper.ml‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -360,8 +360,9 @@ module Jsx_component = struct
360360
(* The first [@react.component], or failing that the first
361361
[@react.componentWithProps]: the JSX transform has always given them
362362
this precedence. A later one, or one whose payload is not understood, is
363-
left in the attributes for the JSX transform to reject, so that
364-
formatting does not drop it. *)
363+
left in the attributes, so that formatting does not drop it: the JSX
364+
transform takes a payload on a lone [@react.componentWithProps] with a
365+
deprecation warning and rejects the others. *)
365366
let take attrs =
366367
let take_first is_kind =
367368
let rec go seen = function

‎compiler/ml/ast_untagged_variants.ml‎

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -88,12 +88,6 @@ let literal_tag_to_user_visible_string = function
8888

8989
let untagged = "unboxed"
9090

91-
let block_type_can_be_undefined = function
92-
| IntType | StringType | FloatType | BigintType | BooleanType | InstanceType _
93-
| FunctionType | ObjectType ->
94-
false
95-
| UnknownType -> true
96-
9791
let has_untagged (attrs : Parsetree.attributes) =
9892
Ext_list.exists attrs (function {txt}, _ -> txt = untagged)
9993

‎compiler/ml/cmi_format.ml‎

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -61,20 +61,8 @@ let read_cmi filename =
6161
(fun () -> read_cmi_channel filename ic)
6262
~finally:(fun () -> close_in_noerr ic)
6363

64-
let output_cmi filename oc cmi =
65-
(* beware: the provided signature must have been substituted for saving *)
66-
output_string oc Config.cmi_magic_number;
67-
output_value oc (cmi.cmi_name, cmi.cmi_sign);
68-
flush oc;
69-
let crc = Digest.file (Compiler_request_state.resolve_path filename) in
70-
let crcs = (cmi.cmi_name, Some crc) :: cmi.cmi_crcs in
71-
output_value oc crcs;
72-
output_value oc cmi.cmi_flags;
73-
crc
74-
75-
(* This function is also called by [save_cmt] as cmi_format is subset of
76-
cmt_format, so dont close the channel yet
77-
*)
64+
(* Writes the .cmi file, keeping an existing one with the same contents
65+
when [check_exists] is given *)
7866
let create_cmi ?check_exists filename (cmi : cmi_infos) =
7967
(* beware: the provided signature must have been substituted for saving *)
8068
let content =

0 commit comments

Comments
 (0)