Skip to content

fix(index): record functions passed as values and serde attribute functions as calls - #805

Merged
ajianaz merged 1 commit into
developfrom
fix/references-as-callers
Nov 17, 2026
Merged

ajianaz merged 1 commit into
developfrom
fix/references-as-callers

Conversation

@ajianaz

@ajianaz ajianaz commented Nov 17, 2026 •

Copy link
Copy Markdown
Collaborator

What

In the Rust extractor (src/index/ast.rs):

  • A function path passed as an argument is recorded as a call by the function that passes it: a bare snake_case identifier (.map(helper), .and_then(quote_key)) or a Type::f / module::f path (.map(ScanFile::post_image), .is_some_and(commit_gate::alias_runs_commit)). Constants, enum variants and types (uppercase) are skipped, and so is a bare identifier the function binds itself: parameters, let and for patterns including tuples, if let and match-arm bindings, struct patterns (Command::X { symbol, limit } =>) and closure parameters.
  • The functions named in the serde attributes of a struct or enum and of its fields (default = "f", deserialize_with = "path::f", serialize_with, skip_serializing_if, with) are recorded as calls of that struct or enum.
  • EXTRACTOR_VERSION is 2 (fix(index): re-extract unchanged files after an extractor change #804), so the first cora index after the upgrade re-extracts every file once.

Why

The extractor recorded a call only for a call_expression and inside macros, so a function used as a value or named in a serde attribute looked unused to cora dead-code, callers and impact. Closes #802.

Testing

  • Two tests first, red before: a function and an associated function passed to .map(..), with a constant, None, an enum variant, a string, a reference and every kind of local binding in the same function that must not create an edge; serde attributes with a plain name and a path, and a doc comment that only looks like an attribute.
  • Measured on this repository after cora index --rebuild: cora dead-code reports 5 symbols instead of 43. The 43 held no dead code (25 serde attribute functions, 13 functions used as values or via a path, 5 real findings); the 5 left are the unwired bundling engine (decide: wire in or remove code that is written but not used (bundling engine, AstNode.parent, context stats) #792). Call edges that are function values or attribute names and name an existing function: 185 at first, 108 after the local-binding handling was tightened (a variable called project_id or limit was being recorded); what is left is real use (.map(Self::as_str), default_true, .map(String::from)).
  • cargo test --features tree-sitter: 1551 passed, 0 failed; cargo fmt --all -- --check and clippy with -D warnings clean; Cora review of the staged diff: no findings.

@ajianaz
ajianaz merged commit d44600d into develop Nov 17, 2026
24 of 25 checks 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.

fix(index): cora dead-code flags functions passed as values and functions named in serde attributes

1 participant