fix: don't make MissingMatchArms
diagnostic for empty match body
This commit is contained in:
parent
45136511a5
commit
cab91480b2
@ -1914,17 +1914,20 @@ pub fn diagnostics(self, db: &dyn HirDatabase, acc: &mut Vec<AnyDiagnostic>) {
|
||||
if let ast::Expr::MatchExpr(match_expr) =
|
||||
&source_ptr.value.to_node(&root)
|
||||
{
|
||||
if let Some(scrut_expr) = match_expr.expr() {
|
||||
acc.push(
|
||||
MissingMatchArms {
|
||||
scrutinee_expr: InFile::new(
|
||||
source_ptr.file_id,
|
||||
AstPtr::new(&scrut_expr),
|
||||
),
|
||||
uncovered_patterns,
|
||||
}
|
||||
.into(),
|
||||
);
|
||||
match match_expr.expr() {
|
||||
Some(scrut_expr) if match_expr.match_arm_list().is_some() => {
|
||||
acc.push(
|
||||
MissingMatchArms {
|
||||
scrutinee_expr: InFile::new(
|
||||
source_ptr.file_id,
|
||||
AstPtr::new(&scrut_expr),
|
||||
),
|
||||
uncovered_patterns,
|
||||
}
|
||||
.into(),
|
||||
);
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -25,6 +25,18 @@ fn check_diagnostics_no_bails(ra_fixture: &str) {
|
||||
crate::tests::check_diagnostics(ra_fixture)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn empty_body() {
|
||||
check_diagnostics_no_bails(
|
||||
r#"
|
||||
fn main() {
|
||||
match 0;
|
||||
//^ error: Syntax Error: expected `{`
|
||||
}
|
||||
"#,
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn empty_tuple() {
|
||||
check_diagnostics_no_bails(
|
||||
|
Loading…
Reference in New Issue
Block a user