Repository navigation
Avoid temporary vectors in derive trait checks - #683
Merged
Merged
Conversation
Signed-off-by: Perfloop Agent <agent@perfloop.ai>
Signed-off-by: Perfloop Agent <agent@perfloop.ai>
Contributor
|
@perfloop-agent remove all the test stuff; leave just the optimization. |
Contributor
Author
|
The iterator substitution can stand alone; the test allocator, compiler callback, and allocation assertions do not need to ship. |
Contributor
ok, remove them then. |
Removed test-related code for allocation counting and assertions from semantic.rs.
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.
Each available derive-trait check builds a temporary vector just to pass repeated type arguments to rustc. Pass
std::iter::repeat_ninstead, avoiding that disposable storage while using the existing iterator-taking API.The argument count still comes from
tcx.generics_of(trait_def_id).count(). Trait filtering, result order, and the caller’s parameter environment are unchanged, including the parameter-environment handling added in #586. Both translation models continue through the same trait solver and IR serialization paths.The allocation regression test in
rule-preprocessor/src/semantic.rscalls the actual derive routine and detects restoration of the vector. It requires a release-mode test build; its allocator and observations are compiled only for tests.This removes temporary argument-container allocations, not rustc’s trait-reference or solver allocations. Preprocessing latency has not been measured, so no time saving is claimed.
Cargo’s release-mode preprocessor test run reported 1 passed, 0 failed, and 0 ignored. Rust formatting and release Clippy checks passed for the changed preprocessor code. The ordinary rule-preprocessor CLI completed the shipped rule modules for each available translation model.
Case and evidence
Made by Perfloop.