THIR patterns: Explicitly distinguish &pin from plain &/&mut
#151282
+74
−25
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)