mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-26 21:13:37 +00:00
fix: Panic in debug profile for tuple deconstruct with arity mismatch
This commit is contained in:
parent
062822ce91
commit
6e728df43a
2 changed files with 21 additions and 0 deletions
|
@ -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.
|
||||
|
|
|
@ -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})
|
||||
}
|
||||
"#,
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue