Repository navigation
fix(rust): recognize bodyless trait-method signatures in func_start - #1324
Merged
Merged
Conversation
…1319) _slice_by_braces silently dropped every rust func_start match whose bounded window never found a `{` -- correct for a normal function, but wrong for a trait method requirement (`fn deserialize_any<V>(...) -> ...\nwhere\n V: Visitor<'de>;`), which is legitimately terminated by `;` instead of a body. Adds a rust-specific brace-vs-`;` terminator scan (mirrors csharp's #789 arrow-vs-brace split), tracking `[`/`]` depth so array-typed return values like `-> [u8; 32]` don't get mistaken for a bodyless terminator. Also fixes tree_sitter_accuracy_audit.py's `_get_param_count`, which never counted rust's `parameter`/`self_parameter` child node types -- rust's args_exact_match was silently measuring 0 params for every function regardless of its real signature (args_exact_match 133 -> 1446 of 1489). Re-baselines rust's tree-sitter accuracy fixture: func recall 97.5% -> 99.7% (found_functions 1455 -> 1489 of 1493 real). extra_functions rises 67 -> 108, documented as the same macro-body ground-truth blind spot #1311 identified (`macro_rules!`/custom-DSL `fn ...;` templates that tree-sitter can't see into) -- now more visible because bodyless signatures inside those macro bodies are no longer silently dropped everywhere, not just in real code. Co-Authored-By: Claude Sonnet 5 <[email protected]>
Contributor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
_slice_by_braces's rust path only ever accepted a{-delimited body -- anyfunc_startmatch whose bounded window never found a{was silently dropped, which is correct for a real function but wrong for a trait method requirement (fn deserialize_any<V>(self, visitor: V) -> Result<...>\nwhere\n V: Visitor<'de>;), legitimately terminated by;instead. Added a rust-specific branch (mirrors csharp's#789brace-vs-arrow split) that treats either{or;as a valid terminator after the parameter list, tracking[/]depth so an array-typed return (-> [u8; 32] { ... }) doesn't get its embedded;mistaken for the bodyless terminator.tree_sitter_accuracy_audit.py's_get_param_count: it never counted rust'sparameter/self_parameterchild node types, so every rust function's measured param count was silently 0 regardless of its real signature (only coincidentally "matching" on genuinely zero-arg functions, ~9% baseline).args_exact_matchwent 133 -> 1446 of 1489 comparable as a result -- a real accuracy-measurement fix, unrelated to the detector.py change but surfaced by the same investigation.tests/tree_sitter_accuracy_baseline_rust.json: func recall 97.5% -> 99.7% (found_functions1455 -> 1489 of 1493 real).extra_functionsrises 67 -> 108; confirmed (all 41 net-new entries) this is the exact same macro-body ground-truth blind spot rust/swift func_start extra_functions rose after #1302's prism.py fix -- newly exposed, not caused #1311 already documented in the module docstring (macro_rules!/custom-DSLfn ... ;templates tree-sitter can't see into, e.g. wasmtime'sbr_if_imm! { fn br_if_xeq32_i8(...) = BrIfXeq32I8 / == / get_i32; ... }) -- previously invisible everywhere (both real code and macro bodies), now visible everywhere, so the macro-body instances newly register as "extra" too. Extended the docstring with this follow-on note.tests/golden_master_audit.json/tests/golden_master_zero_dep_audit.jsonviaupdate_golden_master.py(both venvs) -- 156 diffs confined to rust files plus small ripple effects on cross-repo normalized metrics (PageRank-derived coordinates, directory-group averages). Regenerated the ruff baseline (pure line-shift only, viaaudit_check.py --regenerate).Test plan
pytest tests/extraction/languages/test_rust.py tests/extraction/languages/test_rust_strict.py tests/core_engine -q-- 629 passed, 1 xfailedtests/tools/tree_sitter_accuracy_audit.py --lang rust --ci-- OK, matches new baselinetests/tools/tree_sitter_accuracy_audit.py --all --ci-- only rust affected (pre-existing unrelatedgodrift confirmed via stash test)tests/tools/audit_check.py-- all clear (ruff/mypy/dead-key/ast-accuracy)tests/tools/crucible_check.py-- full_precision PASS, zero_dependency PASS🤖 Generated with Claude Code