Unnamed repository; edit this file 'description' to name the repository.
fix: Panic in debug profile for tuple deconstruct with arity mismatch
| -rw-r--r-- | crates/hir-ty/src/diagnostics/match_check/pat_analysis.rs | 9 | ||||
| -rw-r--r-- | crates/ide-diagnostics/src/handlers/type_mismatch.rs | 12 |
2 files changed, 21 insertions, 0 deletions
diff --git a/crates/hir-ty/src/diagnostics/match_check/pat_analysis.rs b/crates/hir-ty/src/diagnostics/match_check/pat_analysis.rs index 7bf8af4cab..a12e201cf3 100644 --- a/crates/hir-ty/src/diagnostics/match_check/pat_analysis.rs +++ b/crates/hir-ty/src/diagnostics/match_check/pat_analysis.rs @@ -86,6 +86,15 @@ impl<'db> MatchCheckCtx<'db> { arms: &[MatchArm<'db>], scrut_ty: Ty, ) -> Result<UsefulnessReport<'db, Self>, ()> { + if scrut_ty.contains_unknown() { + return Err(()); + } + for arm in arms { + if arm.pat.ty().contains_unknown() { + return Err(()); + } + } + // FIXME: Determine place validity correctly. For now, err on the safe side. let place_validity = PlaceValidity::MaybeInvalid; // Measured to take ~100ms on modern hardware. diff --git a/crates/ide-diagnostics/src/handlers/type_mismatch.rs b/crates/ide-diagnostics/src/handlers/type_mismatch.rs index 4c25532228..4e52d28051 100644 --- a/crates/ide-diagnostics/src/handlers/type_mismatch.rs +++ b/crates/ide-diagnostics/src/handlers/type_mismatch.rs @@ -748,4 +748,16 @@ fn f() { "#, ); } + + #[test] + fn regression_17585() { + check_diagnostics( + r#" +fn f() { + let (_, _, _, ..) = (true, 42); + // ^^^^^^^^^^^^^ error: expected (bool, i32), found (bool, i32, {unknown}) +} +"#, + ); + } } |