Rollup merge of #138528 - dianne:implicit-deref-patterns, r=Nadrieril

deref patterns: implement implicit deref patterns

This implements implicit deref patterns (per https://hackmd.io/4qDDMcvyQ-GDB089IPcHGg#Implicit-deref-patterns) and adds tests and an unstable book chapter.

Best reviewed commit-by-commit. Overall there's a lot of additions, but a lot of that is tests, documentation, and simple(?) refactoring.

Tracking issue: #87121

r? ``@Nadrieril``
This commit is contained in:
Matthias Krüger 2025-04-18 05:16:28 +02:00 committed by GitHub
commit 66dd172961

View file

@ -179,7 +179,7 @@ fn find_first_mismatch(cx: &LateContext<'_>, pat: &Pat<'_>) -> Option<(Span, Mut
};
if let Some(adjustments) = cx.typeck_results().pat_adjustments().get(adjust_pat.hir_id) {
if let [first, ..] = **adjustments {
if let ty::Ref(.., mutability) = *first.kind() {
if let ty::Ref(.., mutability) = *first.source.kind() {
let level = if p.hir_id == pat.hir_id {
Level::Top
} else {