Repository navigation
fix(errlanes-derive): with = .. structs bind fields and emit source() - #298
Merged
Merged
Conversation
The `with = ..` branch of the Classify derive built its Display/Error
from a hard-coded unit shape with no source. An #[error("..")] on such
a struct could not name a field, and #[source], a field named
`source`, or `from` never produced a source() chain. Every
response-specific classifier downstream had to opt out with
`error = manual` and hand-write both impls.
Extract the field-binding Display/Error emission of the laned-struct
branch into `struct_display` and call it from both struct paths, so
they cannot drift. Emission bounds from it now flow into the Classify
impl's where clause, and `#[from]` on a field is rejected with the
same targeted diagnostic as laned structs.
`with = ..` on an enum is unchanged: it keeps the unit Display and no
source() through `unit_display`, pinned by a regression test.
Non-breaking: a with struct without field references or source
markers emits the same impls as before.
bodymindarts
marked this pull request as ready for review
October 30, 2026 17:55
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.
#[classify(with = .., lanes(..))]structs now bind fields in#[error(..)]and emitsource()from#[source]/ asourcefield /from, matching laned structs. Non-breaking.Implements handoff
es-entity-dev/handoff-errlanes-classify-with-binds-fields-and-source. Downstream (lana) sweep is out of scope.CHANGELOG (release-generated, so not hand-edited):
#[classify(with = ..)]structs now bind fields in#[error(..)]and emitsource()from#[source]/source/from, matching laned structs. Non-breaking.struct_displayis shared byderive_laned_structand the structwithpath.with = ..on enums (the handoff said struct-only; it is not) keeps its output viaunit_display: unitDisplay, nosource(). Pinned byenum_with_keeps_unit_display_and_no_source.#[from]on awithstruct field now errors (new trybuild case).🤖 Generated with Claude Code
Note
Medium Risk
Changes proc-macro codegen for all
with-classified structs (messages and error chains), though behavior is intended to align with laned structs and enums are pinned to prior semantics.Overview
#[classify(with = .., lanes(..))]on structs now generates the sameDisplay/Error/source()behavior as ordinary laned structs:#[error(..)]can interpolate fields, and causes come from#[source], a field namedsource, or type-levelfrom. Logic is centralized instruct_display, shared with the non-withstruct path;with_impltakes a display callback and merges its where-clause bounds into theClassifyimpl.Enums using
with = ..are unchanged:unit_displaystill emits type-level unit-style messages with no per-variantsource()(covered by new tests).#[from]on a field of awithstruct is now a compile error (usefromin#[classify(..)]orerror = manualinstead). Integration and trybuild tests lock in struct field binding, generics,error = manual, and enum behavior.Reviewed by Cursor Bugbot for commit 87950ca. Bugbot is set up for automated code reviews on this repo. Configure here.