mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-01 11:31:15 +00:00
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:
commit
8d489e21eb
@ -86,6 +86,15 @@ impl<'db> MatchCheckCtx<'db> {
|
|||||||
arms: &[MatchArm<'db>],
|
arms: &[MatchArm<'db>],
|
||||||
scrut_ty: Ty,
|
scrut_ty: Ty,
|
||||||
) -> Result<UsefulnessReport<'db, Self>, ()> {
|
) -> 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.
|
// FIXME: Determine place validity correctly. For now, err on the safe side.
|
||||||
let place_validity = PlaceValidity::MaybeInvalid;
|
let place_validity = PlaceValidity::MaybeInvalid;
|
||||||
// Measured to take ~100ms on modern hardware.
|
// Measured to take ~100ms on modern hardware.
|
||||||
|
@ -745,6 +745,18 @@ fn f() {
|
|||||||
0
|
0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
"#,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn regression_17585() {
|
||||||
|
check_diagnostics(
|
||||||
|
r#"
|
||||||
|
fn f() {
|
||||||
|
let (_, _, _, ..) = (true, 42);
|
||||||
|
// ^^^^^^^^^^^^^ error: expected (bool, i32), found (bool, i32, {unknown})
|
||||||
|
}
|
||||||
"#,
|
"#,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user