Repository navigation
feat(errlanes): enum-level shared rejection code - #279
Merged
Merged
Conversation
`#[rejection(code = .., description = ..)]` on an enum is the code, description and level of every variant that declares neither its own `code`, `code_and_level_from` nor `delegate`. The generated code type gets one variant per distinct code, named after the enum, so `CODES`/`ALL` list a shared code once. A lift arm under a shared-code enum takes the enum's code rather than forwarding the source case's, because forwarding only applies when the destination has no locally declared code. Compile errors: shared code unused (every variant declares its own), on an enum with no variants, next to `code_prefix`, or a variant that takes the shared code declaring its own `description`. `#[rejection(from)]` on several variants already emitted one `From` per variant; it is now covered by a test. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
bodymindarts
marked this pull request as ready for review
October 15, 2026 20:23
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Want higher recall? High effort reviews run extra passes and find more bugs. A team admin can switch effort levels in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 5dc0480. Configure here.
The shared code's variant in the generated code type is named after the enum. The clash check looked at the variants that take the shared code, which emit no code variant of their own, and missed the ones that do: a variant with its own `code`, `delegate` or `code_and_level_from` named like the enum produced a second identical code variant and a derive output that did not compile. Reject that case with a clear error, and allow a shared-code variant named like its enum. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
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.

Implements §1 of the handoff
handoff-errlanes-shared-rejection-code-and-unique-key-ensure(es-entity-dev space).#[rejection(code, description, level)]on an enum is the default for every variant without its owncode/code_and_level_from/delegate.CODESlists a shared code once.code_prefix, variantdescriptionunder a shared code.#[rejection(from)]on several variants was already allowed (oneFromper variant); now tested.Decisions (handoff §4), all recommended options taken:
codeis a compile error)Deviations: the handoff asks for a book mirror in an "errlanes chapter", but the book has no errlanes chapter, so only the README (the crate docs) is updated. An explicit
code_and_level_fromcounts as declaring its own code. No CHANGELOG edit (git-cliff generates it from this title).Pre-existing:
cargo clippy --all-targets -D warningsreports lints in untouched errlanes tests (codes.rs,lift_into.rs,lift_newtype.rs,lift_struct.rs).🤖 Generated with Claude Code
Note
Medium Risk
Changes proc-macro code generation for rejection metadata and lift/catalogue behavior; mistakes could mis-report API error codes, though coverage is strong and misuse is mostly caught at compile time.
Overview
Adds enum-level
#[rejection(code, description, level)]onRejectionderives so every variant without its owncode,delegate, orcode_and_level_fromreports the same rejection code (and shared description/level, with per-variantlevelstill allowed).The derive emits a single code-type variant named after the enum for that shared string, deduplicates it in
CODES, and does not auto-forward lift metadata from source variants when shared code applies—lifted arms use the family code instead. Variants that keep their own code or delegate unchanged can mix with shared-code variants.Compile-time guards reject unused enum-level
code,codeon empty enums,codetogether withcode_prefix, per-variantdescriptionunder shared code, and a self-coded variant whose name matches the enum (shared code owns the enum-named code variant).Docs add a README “One code, several causes” section; trybuild compile-fail cases and integration tests cover catalogue shape, display/
source, lift, compose, and mixed delegate/shared families.Reviewed by Cursor Bugbot for commit 5c039ba. Bugbot is set up for automated code reviews on this repo. Configure here.