fix: Panic in debug profile for tuple deconstruct with arity mismatch

This commit is contained in:
Shoyu Vanilla 2024-07-21 02:37:14 +09:00
parent 062822ce91
commit 6e728df43a
2 changed files with 21 additions and 0 deletions

View file

@ -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.

View file

@ -745,6 +745,18 @@ fn f() {
0
}
}
"#,
);
}
#[test]
fn regression_17585() {
check_diagnostics(
r#"
fn f() {
let (_, _, _, ..) = (true, 42);
// ^^^^^^^^^^^^^ error: expected (bool, i32), found (bool, i32, {unknown})
}
"#,
);
}