-
-
Notifications
You must be signed in to change notification settings - Fork 313
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
Not all repr expressions in enums can be parsed with derive
feature
#1513
Comments
I would love to have this issue fixed in derive_more. Any thoughts on this? Is this fixable in syn? |
I don't think I would want to change this in the Parse impl for Expr, or DeriveInput. But it should be possible for derive_more to use syn::parse to parse the macro input directly itself using different parsing logic that behaves as you want. |
This would more or less require reimplementing a decent chunk of syn's AST. Probably enabling |
It would not. My informed estimate is 2.25%. The actual amount to be implemented is so small that My estimate is we are talking about under 90 lines of code to implement a correct expression parser with syn that recognizes all Rust syntax. |
If it's really only 90 lines of code, then I'm not really sure why you wouldn't want to have it in the Parse impl for DeriveInput. To be clear, I'm not opposed to derive_more taking ownership of writing this parser that recognizes rust syntax. I'm simply not understanding why that parser should then live in derive_more, instead of in syn. Because right now not all inputs to a derive can actually be parsed by DeriveInput its Parse impl. It seems to me that this is not a problem specific to derive_more. |
Fixed in 2.0.45. |
@ModProg reported an issue that a derive on one of his structs did not work in my
derive_more
crate:Source: JelteF/derive_more#301
Do you think there's a way to work around this. For this specific derive (and really for most) there's no need to actually inspect the expression, we only care about the field names. So even if syn would parse it to something like
Expr::Unknown(TokenStream)
that would be much better than completely failing the parsing (like it does now).The text was updated successfully, but these errors were encountered: