Unnamed repository; edit this file 'description' to name the repository.
| -rw-r--r-- | crates/hir-ty/src/mir/lower/pattern_matching.rs | 3 | ||||
| -rw-r--r-- | crates/hir-ty/src/mir/lower/tests.rs | 13 |
2 files changed, 15 insertions, 1 deletions
diff --git a/crates/hir-ty/src/mir/lower/pattern_matching.rs b/crates/hir-ty/src/mir/lower/pattern_matching.rs index f273a823ba..66b51a0e95 100644 --- a/crates/hir-ty/src/mir/lower/pattern_matching.rs +++ b/crates/hir-ty/src/mir/lower/pattern_matching.rs @@ -137,7 +137,8 @@ impl<'db> MirLowerCtx<'_, 'db> { } Pat::Wild => (current, current_else), Pat::Tuple { args, ellipsis } => { - let subst = match self.infer.pat_ty(pattern).kind() { + let place_ty = cond_place.ty(&self.result, &self.infcx, self.env).ty; + let subst = match place_ty.kind() { TyKind::Tuple(s) => s, _ => { return Err(MirLowerError::TypeError( diff --git a/crates/hir-ty/src/mir/lower/tests.rs b/crates/hir-ty/src/mir/lower/tests.rs index bf13b4c46e..d8f7d549d6 100644 --- a/crates/hir-ty/src/mir/lower/tests.rs +++ b/crates/hir-ty/src/mir/lower/tests.rs @@ -121,3 +121,16 @@ fn tuple_field() { "#, ); } + +#[test] +fn borrowck_alias_projection_recovery_does_not_panic() { + check_borrowck( + r#" +//- minicore: sized +trait Tr { type A; } +fn alias<T: Tr>(x: T::A) { + let (a, b) = x; +} + "#, + ); +} |