Skip to content

Conversation

@Zalathar
Copy link
Member

While looking for improvements to match-lowering, I had been trying to figure out why pin-patterns sometimes use PatKind::Deref and sometimes use PatKind::DerefPattern, which seemed confusing to me. In particular, both pattern kinds are being used with an inner type of & or &mut, which is very surprising.

The conclusion I came to was that DerefPattern (normally associated with calls to Deref/DerefMut) was only being used for implicit pin-patterns produced by match-ergonomics adjustment, whereas Deref was being used for explicit pin-patterns.

The inconsistency seems like a mistake to me, so this PR removes all uses of DerefPattern for pin-patterns, and consistently uses PatKind::Deref for pin-patterns instead. I'm not entirely happy with that outcome, because I think pin-patterns should probably have their own thir::PatKind variant, but this change will at least make that easier to achieve in a later PR.

r? Nadrieril

@Zalathar Zalathar added the F-pin_ergonomics `#![feature(pin_ergonomics)]` label Dec 18, 2025
@rustbot
Copy link
Collaborator

rustbot commented Dec 18, 2025

Some changes occurred in match checking

cc @Nadrieril

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 Dec 18, 2025
@rustbot
Copy link
Collaborator

rustbot commented Dec 18, 2025

Nadrieril is not on the review rotation at the moment.
They may take a while to respond.

@Nadrieril
Copy link
Member

Oh, the use of DerefPattern was for the purposes of match exhaustiveness, but turns out match exhaustiveness also got a special case for pin added to PatKind::Deref. So yep, looks good.

@bors r+ rollup

@bors
Copy link
Collaborator

bors commented Dec 19, 2025

📌 Commit 1ae9604 has been approved by Nadrieril

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Dec 19, 2025
bors added a commit that referenced this pull request Dec 19, 2025
Rollup of 3 pull requests

Successful merges:

 - #150121 (mir_build: Don't use a mixture of THIR pattern kinds for pin-patterns)
 - #150148 (mir_build: Remove unnecessary lifetime from THIR `PatCtxt`)
 - #150150 (move eii tests)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 0e64ced into rust-lang:main Dec 19, 2025
11 checks passed
@rustbot rustbot added this to the 1.94.0 milestone Dec 19, 2025
rust-timer added a commit that referenced this pull request Dec 19, 2025
Rollup merge of #150121 - Zalathar:pin-pat, r=Nadrieril

mir_build: Don't use a mixture of THIR pattern kinds for pin-patterns

While looking for improvements to match-lowering, I had been trying to figure out why pin-patterns sometimes use `PatKind::Deref` and sometimes use `PatKind::DerefPattern`, which seemed confusing to me. In particular, both pattern kinds are being used with an inner type of `&` or `&mut`, which is very surprising.

The conclusion I came to was that `DerefPattern` (normally associated with calls to Deref/DerefMut) was only being used for *implicit* pin-patterns produced by match-ergonomics adjustment, whereas `Deref` was being used for explicit pin-patterns.

The inconsistency seems like a mistake to me, so this PR removes all uses of `DerefPattern` for pin-patterns, and consistently uses `PatKind::Deref` for pin-patterns instead. I'm not entirely happy with that outcome, because I think pin-patterns should probably have their own `thir::PatKind` variant, but this change will at least make that easier to achieve in a later PR.

r? Nadrieril
@Zalathar Zalathar deleted the pin-pat branch December 19, 2025 22:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

F-pin_ergonomics `#![feature(pin_ergonomics)]` S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. 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.

4 participants