Auto merge of #17649 - ShoyuVanilla:issue-17585, r=Veykril

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

Fixes #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 #17534, skipping match usefulness check for patterns containing errors
This commit is contained in:
bors 2024-07-20 18:04:01 +00:00
commit 8d489e21eb
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})
}
"#,
);
}