Skip to content

Commit ea7f367

Browse files
committed
Auto merge of rust-lang#17649 - ShoyuVanilla:issue-17585, r=Veykril
fix: Panic in debug profile for tuple deconstruct with arity mismatch Fixes rust-lang#17585, which doesn't affect daily use cases but quite annoying in development of r-a itself like writing tests. This PR applies similar approach as in rust-lang#17534, skipping match usefulness check for patterns containing errors
2 parents 60dfe6c + 96b3003 commit ea7f367

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

Diff for: src/tools/rust-analyzer/crates/hir-ty/src/diagnostics/match_check/pat_analysis.rs

+9
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,15 @@ impl<'db> MatchCheckCtx<'db> {
8686
arms: &[MatchArm<'db>],
8787
scrut_ty: Ty,
8888
) -> Result<UsefulnessReport<'db, Self>, ()> {
89+
if scrut_ty.contains_unknown() {
90+
return Err(());
91+
}
92+
for arm in arms {
93+
if arm.pat.ty().contains_unknown() {
94+
return Err(());
95+
}
96+
}
97+
8998
// FIXME: Determine place validity correctly. For now, err on the safe side.
9099
let place_validity = PlaceValidity::MaybeInvalid;
91100
// Measured to take ~100ms on modern hardware.

Diff for: src/tools/rust-analyzer/crates/ide-diagnostics/src/handlers/type_mismatch.rs

+12
Original file line numberDiff line numberDiff line change
@@ -745,6 +745,18 @@ fn f() {
745745
0
746746
}
747747
}
748+
"#,
749+
);
750+
}
751+
752+
#[test]
753+
fn regression_17585() {
754+
check_diagnostics(
755+
r#"
756+
fn f() {
757+
let (_, _, _, ..) = (true, 42);
758+
// ^^^^^^^^^^^^^ error: expected (bool, i32), found (bool, i32, {unknown})
759+
}
748760
"#,
749761
);
750762
}

0 commit comments

Comments
 (0)