Skip to content

Print a deprecated item's name only when it is deprecated - #98

Merged
jfrolich merged 2 commits into
ocaml-to-rust-rewritefrom
deprecation-name-on-demand
Nov 11, 2026
Merged

jfrolich merged 2 commits into
ocaml-to-rust-rewritefrom
deprecation-name-on-demand

Conversation

@jfrolich

Copy link
Copy Markdown
Owner

What

The deprecation check on a value or type use prints the item's path only when the item carries a deprecated attribute.

Why

Every use of a value and every use of a type constructor asks whether the item is deprecated. 38acef3 (raise the invalid-escape errors where OCaml's readers raise) moved that check into a helper that takes the item's name as a string, and both callers passed path.name(). So each use allocated and formatted the full dotted path before the attributes were looked at, and dropped it again for nearly every item, since almost none is deprecated.

In a single-worker profile of a 3,735-module application this was 27 ms of a 6.1 s clean build (0.45% of CPU), up from 1.7 ms before that commit.

How

deprecated_warning_for_path looks for the attribute first and prints the path inside the map that builds the warning. The constructor callers keep deprecated_warning_from_attrs, whose name is already a string.

Measurements

Clean build of a 3,735-module application, release builds with one codegen unit, one compile worker, alternating runs, retired instructions from /usr/bin/time -l:

Trunk (b4c2789) This change Paired difference
Instructions (n=6) 83.02 G 82.82 G −0.20 ± 0.10 G (−0.24%)

The 3,980 generated files are byte-identical. The measured binary also carried two disabled measurement switches for other experiments; they are not part of this change.

Verification

Behaviour is meant to be unchanged, so the check is before against after:

  • A probe with deprecated values and types behind nested modules (M.N.x, M.N.t, with and without a reason) prints the same seven warnings from both compilers.
  • The 17 fixtures under tests/build_tests/super_errors/fixtures and tests/error_output_parity/compiler/fixtures that mention deprecated give identical output and exit codes from both compilers; 15 of them print a deprecation warning.

No test was added: the existing fixtures cover the warning text, and the change does not alter it.


Created by this Assistant session

Every use of a value or a type checks the item for a `deprecated`
attribute. 38acef3 (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>
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>
@jfrolich
jfrolich force-pushed the deprecation-name-on-demand branch from 5e8ec11 to e9c064b Compare November 11, 2026 17:23
@jfrolich
jfrolich merged commit 9fb4b18 into ocaml-to-rust-rewrite Nov 11, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant