Many errors#5
Draft
maxwase wants to merge 5 commits into
Draft
Conversation
There was a problem hiding this comment.
Pull request overview
This PR extends errortools with an alloc-enabled aggregated error type (ManyErrors) for collecting multiple context-tagged errors, while also refactoring and centralizing test fixtures/strategies to reduce per-module test boilerplate.
Changes:
- Add
ManyErrors+Listingformatting strategy (alloc feature) for aggregated, context-tagged iterator/fold errors. - Introduce
AsDisplaysentinelFormatstrategy to delegate formatting to a value’sDisplay. - Consolidate test fixtures/format strategies into
src/tests.rsand update existing unit tests accordingly.
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/with_context.rs | Renames the format type parameter and updates tests to use shared fixtures. |
| src/tree.rs | Updates tests to use shared Inner fixture and minor naming tweaks. |
| src/tests.rs | New shared test fixtures and reusable Format strategies. |
| src/suggestion.rs | Reworks tests around the “Suggest is not delegated” invariant using shared fixtures. |
| src/oneline.rs | Updates tests to reuse shared Arrow formatter and shared fixtures. |
| src/many_errors/mod.rs | New alloc-only ManyErrors aggregate error type + Listing formatting strategy. |
| src/many_errors/iter.rs | New iterator + collection (FromIterator/Extend) integrations for ManyErrors. |
| src/main_result.rs | Updates tests to use shared fixtures instead of local test-only error types. |
| src/lib.rs | Adds alloc support + exports, introduces AsDisplay, and switches tests to src/tests.rs. |
| src/add.rs | Updates tests to use shared fixtures. |
| Cargo.toml | Adds alloc feature and makes std imply alloc. |
| .github/workflows/ci.yml | Expands CI matrix to include --no-default-features --features alloc. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
253
to
+257
| /// Realistic use: a function tags an inner error with context via | ||
| /// `map_err`, then `?` routes it through `#[from]` into the caller's | ||
| /// error type. | ||
| /// Most importantly, `F` is inferred from the `From` impl on `Error`. | ||
| fn returning_error() -> Result<(), Error> { | ||
| /// Most importantly, `WithContextFormat` is inferred from the `From` impl on `Error`. | ||
| fn returning_error() -> Result<(), PropError> { |
Comment on lines
+132
to
+134
| /// These genetic bounds actually define whether a strategy can be used to format a given error type | ||
| /// Any error type can be put into a strategy, but not every can actually be formatted. | ||
| /// That's why it's possible to construct, but get a compiler error when trying to call [`fmt::Display`] on the combination. |
|
|
||
| impl<C, E, WithContextFormat> ManyErrors<C, E, WithContextFormat> { | ||
| /// Returns an iterator over references to each recorded [`WithContext`]. | ||
| pub fn iter(&self) -> Iter<'_, C, E, WithContextFormat> { |
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.
No description provided.