-
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
Data::try_from reached unreachable!()
.
#85
Comments
I wonder if it's possible to get the span of the |
TedDriggs
added a commit
that referenced
this issue
Feb 10, 2021
Finally getting around to implementing this; it turns out that leaving the span information off completely produces the most helpful error; it's pretty clear where the union is, but it's less clear which macro is objecting to the presence of a union. Otherwise, this is very straightforward. |
TedDriggs
added a commit
that referenced
this issue
Feb 16, 2021
TedDriggs
added a commit
that referenced
this issue
Feb 16, 2021
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The function
Data::try_from
has anunreachable!()
, which will trigger, if you try to call this function withsyn::Data::Union
.darling/core/src/ast/data.rs
Line 121 in c0e0cfd
Because this is definitely reachable, it should be either replaced with an
Error
or exposed by the data struct.
This should definitely not panic, because it makes it unnecessarily difficult to find the problem and it would be nice to get a beautiful error, instead of this:
Implementation
I am not sure, if the span is correct, or if there shouldn't be any span attached to it and instead the docs show how to attach the correct span:
There is also
darling/core/src/ast/data.rs
Line 21 in c0e0cfd
which should do the same as above, but this would be a breaking change, so it might be better to simply document, that this could panic, if called with
Data::Union
. I would also replace theunreachable!()
withunreachable!("::darling::ast::Data::empty_from: Union structs are not supported.")
Another one is here (this can error?)
darling/core/src/options/mod.rs
Line 133 in c0e0cfd
The text was updated successfully, but these errors were encountered: