Skip to content

docs(guide/dev): refine error handling guidelines for derive_more traits#366

Merged
KSXGitHub merged 4 commits into
masterfrom
claude/remove-error-derives-4dwAM
Mar 23, 2026
Merged

docs(guide/dev): refine error handling guidelines for derive_more traits#366
KSXGitHub merged 4 commits into
masterfrom
claude/remove-error-derives-4dwAM

Conversation

@KSXGitHub

Copy link
Copy Markdown
Owner

Summary

Updated error handling documentation across all guidance files to clarify when to derive Display and Error traits from derive_more, emphasizing that not all types need both traits.

Key Changes

  • CONTRIBUTING.md: Expanded the error handling section with detailed guidance on when to derive Display vs Error, including examples of types that only need Display for formatting purposes
  • AI instruction files (.github/copilot-instructions.md, AGENTS.md, CLAUDE.md, template/ai-instructions/shared.md): Updated the error type guidance to match the more nuanced approach, replacing the blanket #[derive(Debug, Display, Error)] recommendation with conditional trait derivation

Notable Details

The changes clarify that:

  • Display should be derived when a type needs to be displayed (e.g., printed to stderr, used in format strings)
  • Error should be derived when the type is used as std::error::Error (e.g., as a Result error type or as a source of another error)
  • Types that only need formatting should derive Display without Error, avoiding unnecessary trait implementations

https://claude.ai/code/session_012YdPMpQ3UiSmqFSU2vUULm

claude added 2 commits March 22, 2026 23:12
`ParsedValue` is not an error type — it's a display wrapper for
formatted byte values. Remove the unused `Error` derive and update
documentation to clarify that `Display` and `Error` should only be
derived when actually used.

https://claude.ai/code/session_012YdPMpQ3UiSmqFSU2vUULm
Update CONTRIBUTING.md and AI instruction templates to clarify that
`Display` and `Error` should only be derived when each trait is actually
used, rather than always bundling them together as `#[derive(Debug,
Display, Error)]`.

https://claude.ai/code/session_012YdPMpQ3UiSmqFSU2vUULm

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Refines developer guidance to clarify when Rust types should derive Display and/or std::error::Error via derive_more, aiming to avoid unnecessary trait implementations while keeping error-handling patterns consistent across the repo’s docs and AI instruction files.

Changes:

  • Expanded CONTRIBUTING.md error-handling guidance to differentiate when to derive Display vs Error.
  • Updated AI instruction documents to replace the blanket “derive Debug, Display, Error” recommendation with conditional guidance.
  • Aligned the shared AI-instructions template fragment with the updated recommendations.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
template/ai-instructions/shared.md Updates the shared “Quick Reference” bullet for error trait derivation guidance.
CONTRIBUTING.md Expands the “Error Handling” section with more nuanced derive guidance.
CLAUDE.md Updates the “Quick Reference” bullet for error trait derivation guidance.
AGENTS.md Updates the “Quick Reference” bullet for error trait derivation guidance.
.github/copilot-instructions.md Updates the “Quick Reference” bullet for error trait derivation guidance.

Comment thread template/ai-instructions/shared.md Outdated
Comment thread CLAUDE.md Outdated
Comment thread AGENTS.md Outdated
Comment thread .github/copilot-instructions.md Outdated
@github-actions

github-actions Bot commented Mar 22, 2026

Copy link
Copy Markdown

Performance Regression Reports

commit: cced310

There are no regressions.

`std::error::Error` requires `Display` as a supertrait, so saying "not
all error types need Display" was inaccurate. Simplify the guideline to
focus on the valid point: not all displayable types are errors.

https://claude.ai/code/session_012YdPMpQ3UiSmqFSU2vUULm

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Comment thread CONTRIBUTING.md
@KSXGitHub KSXGitHub marked this pull request as ready for review March 23, 2026 00:56
@KSXGitHub KSXGitHub merged commit 800e537 into master Mar 23, 2026
13 checks passed
@KSXGitHub KSXGitHub deleted the claude/remove-error-derives-4dwAM branch March 23, 2026 00:56
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.

3 participants