Skip to content

Many errors#5

Draft
maxwase wants to merge 5 commits into
masterfrom
many-errors
Draft

Many errors#5
maxwase wants to merge 5 commits into
masterfrom
many-errors

Conversation

@maxwase
Copy link
Copy Markdown
Owner

@maxwase maxwase commented May 17, 2026

No description provided.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 + Listing formatting strategy (alloc feature) for aggregated, context-tagged iterator/fold errors.
  • Introduce AsDisplay sentinel Format strategy to delegate formatting to a value’s Display.
  • Consolidate test fixtures/format strategies into src/tests.rs and 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 thread src/many_errors/iter.rs
Comment thread src/with_context/mod.rs
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 thread src/lib.rs
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.
Comment thread src/many_errors/iter.rs

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> {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants