Make the match lowering state machine explicit#128515
Make the match lowering state machine explicit#128515Nadrieril wants to merge 8 commits intorust-lang:masterfrom
Conversation
`match_candidates` can change the `otherwise_block`, so the previous code was morally incorrect (if not in practice, for some reason).
|
The job Click to see the possible cause of the failure (guessed by this bot) |
| all_except_last | ||
| .all(|candidate| matches!(candidate.state, CandidateState::Complete { .. })) |
There was a problem hiding this comment.
It looks like this is overly strict, because we can also have CandidateState::Expanded with remaining_match_pairs.is_empty().
That seems to be the cause of the assertion failure in debug-assertion builds.
|
With the existing code, it's nice that the code that handles |
|
Yeahh, it's not great, but reusing code as before requires a 4th state I think (see the last commit) |
|
Hmm yeah, I tried a simplification that I had in mind and it almost worked, but not quite. To me, it feels like the code is not quite ready to be broken up into crisp candidate states, like there's some other change that needs to happen first to make this smoother. But I'm not sure what that change is. |
|
I know what you mean. The other change I have in mind is to choose success/failure blocks before processing candidates, which would mean we can do the "post-processing" of or-patterns before passing them through |
|
☔ The latest upstream changes (presumably #122792) made this pull request unmergeable. Please resolve the merge conflicts. |
|
More thought needed then |
One of the trickiest parts of match lowering is what happens to the
Candidates. They're used for a bunch of things at once, especially for or-patterns. This PR moves the important data ofCandidateinto an enum, to make the various stages of processing explicit.This is a bit rough, I'm open to feedback on whether this is clear enough. cc @Zalathar in particular.
r? @ghost