Repository navigation
fix(index): record functions passed as values and serde attribute functions as calls - #805
Merged
Merged
Conversation
…ctions as calls Closes #802.
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.
What
In the Rust extractor (
src/index/ast.rs):.map(helper),.and_then(quote_key)) or aType::f/module::fpath (.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,letandforpatterns including tuples,if letand match-arm bindings, struct patterns (Command::X { symbol, limit } =>) and closure parameters.serdeattributes 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_VERSIONis 2 (fix(index): re-extract unchanged files after an extractor change #804), so the firstcora indexafter the upgrade re-extracts every file once.Why
The extractor recorded a call only for a
call_expressionand inside macros, so a function used as a value or named in a serde attribute looked unused tocora dead-code,callersandimpact. Closes #802.Testing
.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.cora index --rebuild:cora dead-codereports 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 calledproject_idorlimitwas 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 -- --checkand clippy with-D warningsclean; Cora review of the staged diff: no findings.