THIR patterns: Explicitly distinguish &pin from plain &/&mut#151282
Merged
rust-bors[bot] merged 1 commit intorust-lang:mainfrom Jan 24, 2026
Merged
THIR patterns: Explicitly distinguish &pin from plain &/&mut#151282rust-bors[bot] merged 1 commit intorust-lang:mainfrom
&pin from plain &/&mut#151282rust-bors[bot] merged 1 commit intorust-lang:mainfrom
Conversation
Collaborator
|
Some changes occurred in match checking cc @Nadrieril Some changes occurred in exhaustiveness checking cc @Nadrieril Some changes occurred in match lowering cc @Nadrieril |
Collaborator
|
|
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Member
Author
|
I'll probably need to rebase this again after #151295. |
This comment has been minimized.
This comment has been minimized.
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. |
Member
|
Big fan of this. The fact that this uncovered a bug is enough proof that we need this, if we needed any. @bors r+ |
Contributor
rust-timer
added a commit
that referenced
this pull request
Jan 24, 2026
Rollup merge of #151282 - Zalathar:pin-pat, r=Nadrieril THIR patterns: Explicitly distinguish `&pin` from plain `&`/`&mut` Currently, `thir::PatKind::Deref` is used for ordinary `&`/`&mut` patterns, and also for `&pin const` and `&pin mut` patterns under `feature(pin_ergonomics)`. The only way to distinguish between them is by inspecting the `Ty` attached to the pattern node. That's non-obvious, making it easy to miss, and is also a bit confusing to read when it does occur. This PR therefore adds an explicit `pin: hir::Pinnedness` field to `thir::PatKind::Deref`, to explicitly distinguish pin-deref nodes from ordinary builtin-deref nodes. (I'm not deeply familiar with the future of pin-patterns, so I'm not sure whether that information is best carried as a field or as a separate `PatKind`, but I think this approach is at least an improvement over the status quo.) r? Nadrieril (or compiler)
github-actions bot
pushed a commit
to rust-lang/miri
that referenced
this pull request
Jan 25, 2026
Rollup of 4 pull requests Successful merges: - rust-lang/rust#149174 (`const` blocks as a `mod` item) - rust-lang/rust#151282 (THIR patterns: Explicitly distinguish `&pin` from plain `&`/`&mut`) - rust-lang/rust#151593 (miri subtree update) - rust-lang/rust#151516 (Do not emit errors on non-metaitem diagnostic attr input) r? @ghost
vinDelphini
pushed a commit
to vinDelphini/rust
that referenced
this pull request
Jan 25, 2026
…iaskrgr Rollup of 4 pull requests Successful merges: - rust-lang#149174 (`const` blocks as a `mod` item) - rust-lang#151282 (THIR patterns: Explicitly distinguish `&pin` from plain `&`/`&mut`) - rust-lang#151593 (miri subtree update) - rust-lang#151516 (Do not emit errors on non-metaitem diagnostic attr input) r? @ghost
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Currently,
thir::PatKind::Derefis used for ordinary&/&mutpatterns, and also for&pin constand&pin mutpatterns underfeature(pin_ergonomics). The only way to distinguish between them is by inspecting theTyattached to the pattern node.That's non-obvious, making it easy to miss, and is also a bit confusing to read when it does occur.
This PR therefore adds an explicit
pin: hir::Pinnednessfield tothir::PatKind::Deref, to explicitly distinguish pin-deref nodes from ordinary builtin-deref nodes.(I'm not deeply familiar with the future of pin-patterns, so I'm not sure whether that information is best carried as a field or as a separate
PatKind, but I think this approach is at least an improvement over the status quo.)r? Nadrieril (or compiler)