Extract an arguments struct for Builder::then_else_break
by Zalathar · Pull Request #121928 · rust-lang/rust (original) (raw)
Most of this method's arguments are usually or always forwarded as-is to recursive invocations.
Wrapping them in a dedicated struct allows us to document each struct field, and lets us use struct-update syntax to indicate which arguments are being modified when making a recursive call.
While trying to understand the lowering of if
expressions, I found it difficult to keep track of the half-dozen arguments passed through to every call to then_else_break
. I tried switching over to an arguments struct, and I found that it really helps to make sense of what each argument does, and how each call is modifying the arguments.
I have some further ideas for how to streamline these recursive calls, but I've kept those out of this PR so that it's a pure refactoring with no behavioural changes.