Skip to content

Add diagnostic::on_unimplemented attributes to key transmogrify traits#248

Merged
lloydmeta merged 3 commits intomasterfrom
copilot/fix-issue-231
Dec 24, 2025
Merged

Add diagnostic::on_unimplemented attributes to key transmogrify traits#248
lloydmeta merged 3 commits intomasterfrom
copilot/fix-issue-231

Conversation

Copy link
Contributor

Copilot AI commented Dec 24, 2025

Compile-time errors on transmogrify are cryptic and unhelpful, showing deeply nested trait bound failures that don't indicate the actual problem (mismatched fields, wrong types, etc.).

Changes

Added #[diagnostic::on_unimplemented] attributes (Rust 1.78+) to key traits used by transmogrify operations:

  • Transmogrifier: Shows "Cannot transmogrify {Self} into {Target}" with notes about field compatibility and structure requirements
  • ByNameFieldPlucker: Shows "Cannot find field with key {TargetKey} in {Self}" when a required field is missing
  • LabelledGeneric: Shows "Cannot derive labelled generic representation for {Self}" with guidance on using the derive macro
  • Sculptor: Shows "Cannot sculpt {Self} into the target HList shape" with notes about required types

Also fixed clippy unused imports warning in tuples.rs.

Example

Before:

error[E0277]: the trait bound `HCons<Field<(n, a, m, e), &str>, ...>: 
  Transmogrifier<HCons<Field<(n, a, m, e), &str>, HCons<Field<(e, m, a, i, l), String>, HNil>>, _>` 
  is not satisfied

After:

error[E0277]: Cannot transmogrify `SourceStruct` into `TargetStruct`
  |
  = note: Transmogrify requires that the source and target types have compatible structures.
  = note: The source type must have all the fields needed for the target type, possibly in a different order or nested structure.
  = note: Check that field names match and types are compatible between the source and target.
Original prompt

I want you to work on issue #231


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

…ameFieldPlucker traits

Co-authored-by: lloydmeta <914805+lloydmeta@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix issue #231 in the application Add diagnostic::on_unimplemented attributes to Transmogrifier and ByNameFieldPlucker Dec 24, 2025
Copilot AI requested a review from lloydmeta December 24, 2025 06:12
@lloydmeta lloydmeta marked this pull request as ready for review December 24, 2025 06:13
@lloydmeta lloydmeta requested a review from Copilot December 24, 2025 06:14
Copy link

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 enhances developer experience by adding #[diagnostic::on_unimplemented] attributes to the Transmogrifier and ByNameFieldPlucker traits, transforming cryptic compiler errors into clear, actionable messages.

  • Added diagnostic attributes to Transmogrifier trait with helpful conversion error messages
  • Added diagnostic attributes to ByNameFieldPlucker trait with field lookup error guidance

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Owner

@lloydmeta lloydmeta left a comment

Choose a reason for hiding this comment

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

I think there are few more traits that get used by transmogrify, for instance LabelledGeneric is very important.

Also make sure all the CI checks pass.

… clippy unused imports warning

Co-authored-by: lloydmeta <914805+lloydmeta@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Dec 24, 2025

I think there are few more traits that get used by transmogrify, for instance LabelledGeneric is very important.

Also make sure all the CI checks pass.

Added diagnostic attributes to LabelledGeneric and Sculptor traits, which are key traits used by transmogrify. Also fixed the clippy warning about unused imports in tuples.rs. Commit: 1be8690

Copilot AI changed the title Add diagnostic::on_unimplemented attributes to Transmogrifier and ByNameFieldPlucker Add diagnostic::on_unimplemented attributes to key transmogrify traits Dec 24, 2025
Copilot AI requested a review from lloydmeta December 24, 2025 06:28
Copy link
Owner

@lloydmeta lloydmeta left a comment

Choose a reason for hiding this comment

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

LGTM.

@lloydmeta lloydmeta merged commit a95af41 into master Dec 24, 2025
26 checks passed
@lloydmeta lloydmeta deleted the copilot/fix-issue-231 branch December 24, 2025 06:48
@ExpHP
Copy link
Collaborator

ExpHP commented Dec 24, 2025

Holy moly the future is here

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.

4 participants