mir_build: Clearly distinguish or/refutable/irrefutable patterns during match lowering - #160551
mir_build: Clearly distinguish or/refutable/irrefutable patterns during match lowering#160551Zalathar wants to merge 2 commits into
Conversation
|
Some changes occurred in match lowering cc @Nadrieril |
|
|
This comment has been minimized.
This comment has been minimized.
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
|
This PR isn't motivated by perf, but I'm curious to see if it has any measurable perf effect. @bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
mir_build: Clearly distinguish or/refutable/irrefutable patterns during match lowering
This comment has been minimized.
This comment has been minimized.
|
Finished benchmarking commit (fcfa9a7): comparison URL. Overall result: ❌ regressions - no action neededBenchmarking means the PR may be perf-sensitive. Consider adding rollup=never if this change is not fit for rolling up. @rustbot label: -S-waiting-on-perf -perf-regression Instruction countOur most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.
Max RSS (memory usage)Results (primary -1.5%, secondary -2.0%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesThis perf run didn't have relevant results for this metric. Binary sizeResults (primary -0.0%, secondary -0.0%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Bootstrap: 460.81s -> 462.278s (0.32%) |
|
A tiny regression in match-stress is potentially real, but not worth worrying about. |
This PR has two related parts.
The first commit divides the various fields of InterPat into three different
InterPatKindvariants, which clearly distinguish between or-pattern nodes, refutable pattern nodes, and irrefutable pattern nodes. Such a split was suggested during review of mir_build: Add an extra intermediate step in MIR building for patterns #155144, but at the time I wasn't sure if it was the right direction. Now that I've thought more about how to make it work nicely with InterPat node building, I'm more comfortable with the explicit split.As a follow-on, the second commit then splits MatchPairTree into two different
MatchPairKindvariants: one for or-pattern nodes, and one for “testable” nodes.In both cases, dividing the outer struct into multiple kinds makes it easier to understand and uphold field invariants, since previously-optional fields can be made mandatory or absent.
There should be no change to compiler output.
MatchPairTreeinto testable and or-pattern variants #158551. Instead of splitting or-patterns and testable-patterns into separate lists, they still occupy the same list but are distinguished by kind.r? Nadrieril