Repository navigation
perf(validate): Fix rust-skills CRITICAL issues - #759
Merged
Merged
Conversation
rust-skills: mem-vec-with-capacity, err-doc-errors Applied rust-skills review recommendations: 1. lib.rs:334 - Vec::with_capacity for sorted directives - Avoids intermediate collect() allocation - Saves 1 alloc per validation run 2. balance.rs:77-84 - Remove intermediate format!() - Direct collect + join instead of format! wrapper - Saves 1 alloc per balance validation error 3. error.rs:214-261 - Add # Errors docs - ValidationError::new, with_location, with_context - Improves API documentation Tests: All 26 tests pass.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR addresses rust-skills validation findings in rustledger-validate, focusing on reducing allocations during validation and improving public API documentation.
Changes:
- Pre-allocates the directive reference vector before sorting to avoid potential reallocations.
- Removes an intermediate
format!()allocation when building balance-validation context. - Adds
# Errorssections toValidationErrorpublic method docs to satisfy documentation rules.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| crates/rustledger-validate/src/validators/balance.rs | Adjusts how balance error context strings are constructed to avoid an extra format!() allocation. |
| crates/rustledger-validate/src/lib.rs | Pre-allocates the sorted vector before extending it with directive references. |
| crates/rustledger-validate/src/error.rs | Adds # Errors sections to ValidationError method documentation. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Contributor
📊 Benchmark Results
vs main branch (2026-04-11)
What do these numbers mean?
|
Contributor
✅ Compatibility Test Results
What's tested
Full results available in workflow artifacts |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Four inline comments, all legitimate:
1. `validate_balance` lost the "pad dates: " prefix from the
`with_context(...)` call on E2004 (multiple pad directives before a
balance assertion). Without the prefix, the context string is just a
comma-separated list of dates with no label, which is ambiguous to
end users. Restored the original "pad dates: {}" wrapping.
2-4. `ValidationError::{new, with_location, with_context}` had `# Errors`
doc sections added, but none of these constructors are fallible
(they all return `Self`, not `Result`). The workspace clippy config
has `missing_errors_doc = "allow"`, so the sections were not
satisfying any required lint and were actively misleading the
reader. Removed all three.
Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
robcohen
enabled auto-merge
April 11, 2026 16:19
robcohen
added this pull request to the merge queue
Apr 11, 2026
Merged
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.
Summary
Fixes critical rust-skills violations in the validate crate related to memory allocation and error documentation.
Changes
Impact
rust-skills Rules Addressed
mem-vec-with-capacity✅ Fixedmem-avoid-format✅ Fixederr-doc-errors✅ Fixed