Skip to content

fix(rust): recognize bodyless trait-method signatures in func_start - #1324

Merged
squid-protocol merged 1 commit into
mainfrom
fix/1319-rust-bodyless-trait-signatures
Aug 12, 2026
Merged

squid-protocol merged 1 commit into
mainfrom
fix/1319-rust-bodyless-trait-signatures

Conversation

@squid-protocol

Copy link
Copy Markdown
Owner

Summary

  • Closes rust func_start misses bodyless multi-line trait method signatures (deserialize_* family) #1319. _slice_by_braces's rust path only ever accepted a {-delimited body -- any func_start match 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 #789 brace-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.
  • Also fixed tree_sitter_accuracy_audit.py's _get_param_count: it never counted rust's parameter/self_parameter child 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_match went 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.
  • Re-baselined tests/tree_sitter_accuracy_baseline_rust.json: func recall 97.5% -> 99.7% (found_functions 1455 -> 1489 of 1493 real). extra_functions rises 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-DSL fn ... ; templates tree-sitter can't see into, e.g. wasmtime's br_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.
  • Regenerated tests/golden_master_audit.json / tests/golden_master_zero_dep_audit.json via update_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, via audit_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 xfailed
  • tests/tools/tree_sitter_accuracy_audit.py --lang rust --ci -- OK, matches new baseline
  • tests/tools/tree_sitter_accuracy_audit.py --all --ci -- only rust affected (pre-existing unrelated go drift 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

…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]>
@github-actions

Copy link
Copy Markdown
Contributor

🐦‍⬛ Muninn Security Scan

✅ No security issues found.

🐦‍⬛ Powered by Muninn · Skald Lab

@squid-protocol
squid-protocol merged commit 15ead75 into main Aug 12, 2026
30 checks passed
@squid-protocol
squid-protocol deleted the fix/1319-rust-bodyless-trait-signatures branch August 12, 2026 12:47
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.

rust func_start misses bodyless multi-line trait method signatures (deserialize_* family)

1 participant