Skip to content

calls_out (Rust): macros and turbofish calls are calls; match/let patterns are not - #3726

Merged
squid-protocol merged 2 commits into
mainfrom
claude/rust-calls-out-3643
Sep 26, 2026
Merged

squid-protocol merged 2 commits into
mainfrom
claude/rust-calls-out-3643

Conversation

@squid-protocol

Copy link
Copy Markdown
Owner

Summary

Fixes #3643 (part of #3641). Rust used the shared \b(name)\s*\( pattern, which has three problems:

  • It misses macros (format!(, vec[).
  • It misses turbofish calls (collect::<Vec<_>>()).
  • It counts tuple-struct patterns as calls (Data::Struct(x) =>, Ok(t) =>, if let Some(x) =). C3's 2026-09-25 amendment says a pattern is not a call.

Rust now has its own CALLS_OUT_RUST. Group 1 is still the callee, so qualifier capture and the C5 nested-header check are unchanged.

  • Macro: name!(, name[ or name!{ is a call to name. macro_rules! foo { is not, because its ! isn't followed by the delimiter.

  • Turbofish: name::<…>(, allowing two levels of nested generics, one line, with no parens, braces or quotes inside.

  • Pattern: a capitalised Name(…) (a variant or tuple struct) whose balanced one-line argument list is followed by any of:

    • =>;
    • a pattern |, which may also start the next line, since multi-line arms put it there;
    • a binding =, but never ==, the = of =>, or ||/|=;
    • a match guard's if. An expression never has if after a call, because Rust has no postfix if.

    Any closing )/] of an enclosing pattern may come in between, as in Err(X::Gone(e)) =>. A lowercase guard call, like if valid(x) =>, stays a call.

  • Fn, FnMut and FnOnce join Rust's keyword set. F: Fn(&T) and impl FnOnce(u8) are types, not calls (C2).

ReDoS: every quantifier is bounded, and the pattern check runs only where a capitalised word starts. The tests include 8 pathological payloads. The contract doc's C3 records all of this.

Cross-repo

keyword-rosetta needs a re-bless after this merges. Its Rust folder moves in two places:

  • a.rs → probe_test gains assert and assert_eq;
  • b.rs → probe_telemetry gains info and error.

These are exactly the macro calls that the corpus's docs/calls_out_truth.json lists under known_gaps.macros ("not captured by the paren paradigm"). So the move is the intended improvement, not a regression. This PR carries rosetta:rebless-owed.

Merge order: this PR first. Then a keyword-rosetta PR against engine main re-blesses the Rust manifest and removes the macros known gap from calls_out_truth.json. I'll open that PR once this one merges.

Type of change

  • Bug fix
  • New feature / language support
  • Parsing or engine logic (gitgalaxy/core/detector.py, language_standards.py, prism.py, or a per-language rule)
  • Docs, tooling, or CI only
  • Other (describe above)

CI checklist

  • python tests/tools/audit_check.py passes (bundles the ruff/mypy/dead-key baseline-gated audits + ruff format --check)
  • python -m pytest tests/ passes
  • Touches parsing/engine logic? python tests/tools/crucible_check.py passes: no drift in either mode (see below)
  • Touches parsing/engine logic? tree_sitter_accuracy_audit.py --all --ci: not run locally. It scores functions, classes and args, which this PR doesn't touch; CI runs it.
  • Changes the CLI's output JSON schema? No.

Measurements

call_graph_accuracy.py (Level 1, against tree-sitter), on language-crucible v1.5.0, for Rust:

rust before after
precision 89.8% 96.6%
recall 90.3% 99.9%
false positives 734 250
missed calls 697 5

No other language moved. The baseline is regenerated.

Of the 250 remaining false positives, 220 are calls inside macro arguments (assert_eq!(x, Some(y)), vec[Some(&A(1))]). tree-sitter leaves a macro's argument tokens unparsed, but they are real calls under C1/C3, so the engine keeps them. The rest are smaller pattern shapes:

  • struct-pattern fields (lit: syn::Lit::Str(lit),);
  • tuple patterns ((Some(c), None) =>);
  • tuple-struct declarations inside a function body.

Golden masters: no drift in either mode. Every callee this adds or drops (macros, Some/Ok/Err, variants) is external or a variant, so none of them resolves to a confident cross-file call edge.

Differential Scan target

language-crucible rust/ (bevy, serde, syn, tokio).

Verification

$ pytest tests/extraction/languages/ -k "calls_out or rust"               -- 417 passed
$ pytest tests/                                                           -- 11536 passed, 333 skipped
$ python tests/tools/audit_check.py                                       -- all clear
$ python tests/tools/call_graph_accuracy.py --ci --buckets 3              -- OK (rust 89.8/90.3 -> 96.6/99.9)
$ python tests/tools/crucible_check.py --mode both --update --yes         -- no drift in either fixture
$ python tests/tools/rosetta_audit.py --corpus ../keyword-rosetta         -- 51 languages; rust MOV (2, the macro gap above)

New test file: tests/extraction/languages/test_calls_out_rust_3643.py. It covers:

  • macros and their decoys;
  • turbofish;
  • nine pattern shapes, including multi-line | arms and guards;
  • expression calls that must stay calls;
  • closure-trait bounds;
  • an end-to-end splice() case;
  • ReDoS payloads.

🤖 Generated with Claude Code

https://claude.ai/code/session_01GCpfMCUMpco98QGbsuv2sr


Generated by Claude Code

…ns are not (#3643)

rust gets CALLS_OUT_RUST (group 1 = callee, so qualifier capture and the C5
header check are unchanged):
- a macro is a call to its name: `format!(`, `vec![`, `quote!{`; never
  `macro_rules! name {`;
- a turbofish between name and `(`: `collect::<Vec<_>>()`, two nesting levels;
- a capitalised `Name(...)` whose one-line argument list is followed by `=>`,
  a pattern `|` (also on the next line, as multi-line arms write it), a
  binding `=` or a match guard `if` is a pattern, not a call.
`Fn`/`FnMut`/`FnOnce` join rust's keyword set: `F: Fn(&T)` is a type.

call_graph_accuracy (rust): precision 89.8% -> 96.6%, recall 90.3% -> 99.9%
(FP 734 -> 250, FN 697 -> 5). Most remaining FPs (220) are calls inside macro
arguments, which tree-sitter cannot see into. No other language moved; golden
masters unchanged (no newly seen callee resolves to a file edge).

keyword-rosetta: rust moves (probe_test gains assert/assert_eq, probe_telemetry
info/error), the macro gap its calls_out_truth.json lists as known. Needs a
corpus re-bless after merge.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01GCpfMCUMpco98QGbsuv2sr
@squid-protocol squid-protocol added the rosetta:rebless-owed Intentionally moves keyword-rosetta counts; audit warns, corpus re-blesses after merge label Sep 26, 2026 — with Claude
…-3643

# Conflicts:
#	gitgalaxy/standards/language_standards/_shared_patterns.py
@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 dfdb3d6 into main Sep 26, 2026
36 checks passed
@squid-protocol
squid-protocol deleted the claude/rust-calls-out-3643 branch September 26, 2026 12:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

rosetta:rebless-owed Intentionally moves keyword-rosetta counts; audit warns, corpus re-blesses after merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

calls_out (rust): macros name!( and turbofish name::<T>( missed; match/let patterns counted as calls

2 participants