This repository was archived by the owner on Feb 11, 2026. It is now read-only.
derive: make error messages slightly more readable, add manually-driven test#133
Merged
tertsdiepraam merged 1 commit intouutils:mainfrom Apr 14, 2025
Merged
Conversation
9919060 to
b2e78d3
Compare
Contributor
Author
|
Changes since last push: |
Collaborator
tertsdiepraam
left a comment
There was a problem hiding this comment.
I think this is a clear improvement, but maybe not enough to close the issue for two reasons.
The first is that I think a proper compile-test framework sounds pretty good for this crate, because it is so focused on derive-based functionality.
The second is that we would ideally use the spans from syn to generate error messages, so that the errors don't just get reported on the #[derive(Arguments)] but on the parts that are failing.
Contributor
Author
|
Ah, well, then I'll add compile-fail-tests in the next PR :) |
Collaborator
|
I unlinked the issue, but this is of course merge-worthy! |
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Closes a bit of #129.
Using a fully-fledged compile-error testsuite is a bit overkill, but we still want to make sure that the
derivecrate generates reasonable error messages. That's what this "example" is for. In the following, there are blocks of lines, one marked as POSITIVE and multiple lines marked as NEGATIVE. The committed version of this file should only contain POSITIVE. In order to run a test, comment out the POSITIVE line, and use a NEGATIVE line instead, and manually check whether you see a reasonable error message – ideally the error message indicated by the comment. One way to do this is:Example output with the type that I did in #129:
It's not a particularly nice error message, but it's more readable than the current
called `Option::unwrap()` on a `None` value.