From e66a4f6218c75092b6aaccdf5d46ecf5c724ec94 Mon Sep 17 00:00:00 2001 From: "open-session-submodule[bot]" <341020755+open-session-submodule[bot]@users.noreply.github.com> Date: Wed, 11 Nov 2026 17:37:21 +0100 Subject: [PATCH 1/2] Print a deprecated item's name only when it is deprecated Every use of a value or a type checks the item for a `deprecated` attribute. 38acef3a62 (raise invalid-escape errors where OCaml's readers raise) folded that check into one helper that takes the item's name, so both callers printed the path to a fresh string before looking at the attributes. Almost no item is deprecated, and the string was dropped. The path is now printed only once a `deprecated` attribute was found. The warning and the invalid-escape error are unchanged. Session: https://jakes-mac-mini.tail23a77e.ts.net:8443/session/os-01a1c9fa-0c5d-7912-a93b-3e7f38e53547 Signed-off-by: open-session-submodule[bot] <341020755+open-session-submodule[bot]@users.noreply.github.com> --- compiler-rust/src/types/typecore.rs | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/compiler-rust/src/types/typecore.rs b/compiler-rust/src/types/typecore.rs index a183e2ccdd..c8a4d71eae 100644 --- a/compiler-rust/src/types/typecore.rs +++ b/compiler-rust/src/types/typecore.rs @@ -7667,6 +7667,20 @@ fn deprecated_warning_from_attrs( .map(|(reason, can_be_automigrated)| deprecated_warning(name, reason, can_be_automigrated))) } +/// `deprecated_warning_from_attrs` for an item named by its path. The name is +/// printed only for a deprecated item: this runs on every use of a value or +/// type, and almost none of them is deprecated. +fn deprecated_warning_for_path( + path: &Path, + attrs: &[crate::types::decl::Attribute], +) -> Result, crate::types::DeclLoc> { + Ok( + deprecated_attr_payload(attrs)?.map(|(reason, can_be_automigrated)| { + deprecated_warning(path.name().as_str(), reason, can_be_automigrated) + }), + ) +} + /// `Builtin_attributes.deprecated_of_attrs` (builtin_attributes.ml:59-62): /// `string_of_opt_payload` of the first `deprecated` attribute, the record /// form reading as `""`; `Err` where it raises. @@ -7835,14 +7849,14 @@ fn deprecated_warning_for_value( path: &Path, desc: &ValueDescription, ) -> Result, crate::types::DeclLoc> { - deprecated_warning_from_attrs(path.name().as_str(), &desc.val_attributes) + deprecated_warning_for_path(path, &desc.val_attributes) } fn deprecated_warning_for_type( path: &Path, decl: &crate::types::decl::TypeDeclaration, ) -> Result, crate::types::DeclLoc> { - deprecated_warning_from_attrs(path.name().as_str(), &decl.type_attributes) + deprecated_warning_for_path(path, &decl.type_attributes) } /// Type check an expression against an expected type. From e9c064b4337e90e3291c3436f605007164b976cf Mon Sep 17 00:00:00 2001 From: "open-session-submodule[bot]" <341020755+open-session-submodule[bot]@users.noreply.github.com> Date: Wed, 11 Nov 2026 17:47:18 +0100 Subject: [PATCH 2/2] Document the on-demand deprecation name Session: https://jakes-mac-mini.tail23a77e.ts.net:8443/session/os-01a1c9fa-0c5d-7912-a93b-3e7f38e53547 Signed-off-by: open-session-submodule[bot] <341020755+open-session-submodule[bot]@users.noreply.github.com> --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index eec143420d..d43b9627c2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -86,6 +86,8 @@ - Load a compiled module's interface into its first dependent without decoding it again, and keep the syntax tree nodes the built-in frontend pass leaves unchanged instead of copying them. https://github.com/jfrolich/rescript-rust/pull/89 https://github.com/jfrolich/rescript-rust/pull/85 +- Print the path of a value or type for a deprecation warning only when the item is deprecated, instead of on every use. https://github.com/jfrolich/rescript-rust/pull/98 + - Compute the item digests and item references of a compiled module's interface once, when it is published, instead of decoding the stored interface again for each. https://github.com/jfrolich/rescript-rust/pull/87 - Type-check faster: lower argument levels directly, settle the checks before binding a type variable in one walk, and skip the inclusion check of a unit against its own inferred signature. https://github.com/jfrolich/rescript-rust/pull/84