-
Notifications
You must be signed in to change notification settings - Fork 68
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unsure if with_span within FromMeta is working #110
Comments
I’m traveling today but will take a look tomorrow. Do you have a public repo I can look at? If not, no worries |
I just landed the unfinished migration to darling so you can take a look. The entity and entity_macros crates haven't been published outside of 0.0.0 to reserve space, but you can check out the examples in the macros lib.rs to see what I'm going for. This is the file that has some of the code above: https://github.com/chipsenkbeil/entity-rs/blob/main/entity_macros/src/derive/ent/struct/data/internal.rs I've been piecing together how to use parts of darling from reported issues and reading the source, so I may be approaching some of it incorrectly. |
I'm not seeing the exact error you shared when I run That said, after looking at your code my working theory is that this line and/or this line is causing the problem. Referencing the darling docs because my own memory on this is a bit fuzzy, it appears the right way to turn these into compile errors is to use the I started trying to test this theory, but there are a lot of references to |
@TedDriggs, sorry, I had to move forward after giving you that link, so code moved around a bit. I also switched to having the UI tests only run on nightly, but the problem I was seeing was with stable. The code still runs on stable (minimum version 1.45.0), but these tests are now limited to nightly as that's what I've seen others using trybuild do. As it turns out, I was trying to use the darling Custom error type to populate a specific message and span. From there, after running As you mentioned, there can be more than one darling error. My hope was to be able to grab the first darling error and use its span for a more specific location, but from what I could see if the error code there is no way to get a span back out once it's inserted. So my result is wrapping the darling errors in a single syn error that uses the display output from darling as its message and the entire derive input's span as the error's span: https://github.com/chipsenkbeil/entity-rs/blob/main/entity_macros/src/derive/ent/struct/data/mod.rs#L100 |
If you do that then you'll definitely get the unwanted behavior described in your original issue report. Going from It doesn't appear there's a problem in |
If there was documentation for it, I believe I would have seen it. I've been reading through the documentation available and filling in gaps by reading through issues and code. E.g. I don't believe that More documentation on this matter is definitely a positive in my eyes! 😄 Any guidance that can be captured regarding ways to approach this would also be helpful. Personally, I'd already written my code with bubbling up |
Cool, in that case I'll put a little guide in the error. I need to look at |
I'm porting my custom parsing of attributes over to darling and one such case is marking a field in the form:
FromMeta derive attempt
Originally, I had this implementation:
Manual implementation
But darling wouldn't support a standalone word of
#[ent(field)]
, so I needed to implement it myself and check for each of the possible attributes:Not pointing to location of error
I'm using trybuild to compare my old output to the new before saving it. For the example below, I can't seem to get it to be more specific like I used to have.
The text was updated successfully, but these errors were encountered: