Simplify arity implementation #2236
Merged
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.
Originally the annotations in the
for_each_operator!
macro were intended to be used to implement the validator in addition to arity, but during the PR this part was removed and the annotations were only used for arity. As such the macro/annotations were a bit more complicated than they might otherwise need to be. Coupled with #2235 where some changes may be needed to arity calculations the macro was a bit difficult to understand. As a result this commit simplifies the arity annotations to either:arity N -> N
arity custom
All "custom" instructions are now written as Rust functions in the
arity.rs
module. They delegate to each other internally as appropriate in a similar manner to how the macro calculated before.Overall this passes tests but I can clarify that I only have a tenuous understanding at best of the previous macro. I did my best to faithfully translate it from what it used to be but it's possible I got something wrong along the way.