Skip to content

mir_build: Clearly distinguish or/refutable/irrefutable patterns during match lowering - #160551

Open
Zalathar wants to merge 2 commits into
rust-lang:mainfrom
Zalathar:inter-pat
Open

mir_build: Clearly distinguish or/refutable/irrefutable patterns during match lowering#160551
Zalathar wants to merge 2 commits into
rust-lang:mainfrom
Zalathar:inter-pat

Conversation

@Zalathar

@Zalathar Zalathar commented Aug 5, 2026

Copy link
Copy Markdown
Member

This PR has two related parts.

  • The first commit divides the various fields of InterPat into three different InterPatKind variants, 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 MatchPairKind variants: 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.



r? Nadrieril

@rustbot

rustbot commented Aug 5, 2026

Copy link
Copy Markdown
Collaborator

Some changes occurred in match lowering

cc @Nadrieril

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Aug 5, 2026
@rustbot

rustbot commented Aug 5, 2026

Copy link
Copy Markdown
Collaborator

Nadrieril is currently at their maximum review capacity.
They may take a while to respond.

@rust-log-analyzer

This comment has been minimized.

@rustbot

rustbot commented Aug 5, 2026

Copy link
Copy Markdown
Collaborator

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.

@Zalathar

Zalathar commented Aug 6, 2026

Copy link
Copy Markdown
Member Author

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

@rust-timer

This comment has been minimized.

@rust-bors

This comment has been minimized.

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Aug 6, 2026
rust-bors Bot pushed a commit that referenced this pull request Aug 6, 2026
mir_build: Clearly distinguish or/refutable/irrefutable patterns during match lowering
@rust-bors

rust-bors Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: fcfa9a7 (fcfa9a7ac1652c381facd5e795b16ffc8808607d)
Base parent: f73951d (f73951df0a5566d94d13b7954acd9f4ab1fa3734)

@rust-timer

This comment has been minimized.

@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (fcfa9a7): comparison URL.

Overall result: ❌ regressions - no action needed

Benchmarking 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 count

Our most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
0.1% [0.1%, 0.1%] 2
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

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.

mean range count
Regressions ❌
(primary)
1.5% [0.8%, 2.1%] 2
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-3.5% [-6.0%, -2.1%] 3
Improvements ✅
(secondary)
-2.0% [-2.0%, -2.0%] 1
All ❌✅ (primary) -1.5% [-6.0%, 2.1%] 5

Cycles

This perf run didn't have relevant results for this metric.

Binary size

Results (primary -0.0%, secondary -0.0%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-0.0% [-0.0%, -0.0%] 11
Improvements ✅
(secondary)
-0.0% [-0.1%, -0.0%] 5
All ❌✅ (primary) -0.0% [-0.0%, -0.0%] 11

Bootstrap: 460.81s -> 462.278s (0.32%)
Artifact size: 398.76 MiB -> 398.61 MiB (-0.04%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Aug 6, 2026
@Zalathar

Zalathar commented Aug 8, 2026

Copy link
Copy Markdown
Member Author

A tiny regression in match-stress is potentially real, but not worth worrying about.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants