From ded4e7cc836dd2f00ab5825e783c11e52db18d38 Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Wed, 2 Jun 2021 20:00:39 +0200 Subject: Fix bind patterns always being treated as ref taking patterns --- crates/hir_ty/src/infer/pat.rs | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'crates/hir_ty/src/infer') diff --git a/crates/hir_ty/src/infer/pat.rs b/crates/hir_ty/src/infer/pat.rs index 83e0a7a9e..c97b49544 100644 --- a/crates/hir_ty/src/infer/pat.rs +++ b/crates/hir_ty/src/infer/pat.rs @@ -290,6 +290,10 @@ fn is_non_ref_pat(body: &hir_def::body::Body, pat: PatId) -> bool { Expr::Literal(Literal::String(..)) => false, _ => true, }, + Pat::Bind { mode: BindingAnnotation::Mutable, subpat: Some(subpat), .. } + | Pat::Bind { mode: BindingAnnotation::Unannotated, subpat: Some(subpat), .. } => { + is_non_ref_pat(body, *subpat) + } Pat::Wild | Pat::Bind { .. } | Pat::Ref { .. } | Pat::Box { .. } | Pat::Missing => false, } } -- cgit v1.2.3