mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-11-20 21:26:43 +00:00
#5171 ran into an issue where the wrong kind was associated with an arg (`auto arg1 = RefineOperand(context, loc_id, arg0_kind, action.arg1());`). This PR is trying to reduce risk of similar errors by replaced `ArgKinds()` with instead an `ArgAndKind` structure and corresponding accessors. A couple things I considered and discarded were: - Adding `CARBON_KIND_SWITCH` support (in this PR -- see #5216). - The particular way that `ForCase` works would need to change, and I was hesitant to do that here. - But this is why I did add `As` to `ArgAndKind`, because it had me thinking in that direction. - Trying to make wrapper functions like `MutateArgs(callback_fn);`. This kind of approach gets a little messy due to some of the conditional passes, and in particular the reverse-iteration done for `PopOperand` in subst.cpp - Making something like `args_and_kinds() -> std::array<ArgAndKind, 2>`. There's one spot where iteration is already set up as a loop, but for others it felt a little convoluted with less gain than `MutateArgs`-style things. I'm not sure if there's a better way to set up the table generators, I might keep tinkering with those for ideas.