Add a per-item-kind index of public items in the crate. #676
+351
−7
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.
Most items we'll see in the crate either aren't public, or aren't top-level items that would be returned by the
Crate -[item]-> Item
edge. For example, many of those items are methods, impls, trait associated types, associated constants, etc.In this PR, we ensure we don't bother iterating over such items in queries where they can't possibly match. Queries that look at public structs should only iterate over structs, ones that look at enums should only iterate over enums, etc.
This has a substantial performance effect: it speeds up the median
cargo-semver-checks
lint by ~100x, and makes it so that a tiny handful (~5) of lints dominate all linting runtime — the combined runtime of all other lints becomes negligible. In end-to-end terms,cargo-semver-checks
becomes about ~35% faster on our largest workload, but this number is misleadingly small w.r.t. the impact of this optimization: the new runtime is now equal to ~101% of the slowest lint, whereas that number was ~140% previously. If we can now optimize that slow lint in particular, we'll get tens of percent of additional speedup from the optimization in this PR.