fix error with complex enums with many fields#4832
Conversation
davidhewitt
left a comment
There was a problem hiding this comment.
Super, many thanks! Happy New Year :)
| let spec = FnSpec::parse( | ||
| &mut match_args_impl.sig, | ||
| &mut match_args_impl.attrs, | ||
| Default::default(), | ||
| )?; | ||
| let variant_match_args = impl_py_class_attribute(variant_cls_type, &spec, ctx)?; |
There was a problem hiding this comment.
I had an initial feeling that building the syntax tree and then parsing it might be a bit convoluted (we could just construct a FnSpec directly) but maybe this is actually quite elegant because it means the #[classattr] defined above fully defines the final result.
It would have been nice to avoid the fallibility, but I think it's fine on balance.
There was a problem hiding this comment.
it means the
#[classattr]defined above fully defines the final result.
This was my motivation for this. I think it's more robust against accidental inconsistencies (now and in the future)
It would have been nice to avoid the fallibility, but I think it's fine on balance.
Yeah, I was a bit sad as well . It should never fail, so we could also expect, but that did not feel much better to me.
Happy New Year to you as well 🎆
Changes the expansion of
__match_args__for complex enums to not use Rust tuples to lift the limit of 12 fields.Closes #4827