mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-26 20:09:19 +00:00
fix: don't make MissingMatchArms
diagnostic for empty match body
This commit is contained in:
parent
45136511a5
commit
cab91480b2
2 changed files with 26 additions and 11 deletions
|
@ -1914,7 +1914,8 @@ impl DefWithBody {
|
|||
if let ast::Expr::MatchExpr(match_expr) =
|
||||
&source_ptr.value.to_node(&root)
|
||||
{
|
||||
if let Some(scrut_expr) = match_expr.expr() {
|
||||
match match_expr.expr() {
|
||||
Some(scrut_expr) if match_expr.match_arm_list().is_some() => {
|
||||
acc.push(
|
||||
MissingMatchArms {
|
||||
scrutinee_expr: InFile::new(
|
||||
|
@ -1926,6 +1927,8 @@ impl DefWithBody {
|
|||
.into(),
|
||||
);
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
}
|
||||
Err(SyntheticSyntax) => (),
|
||||
|
|
|
@ -25,6 +25,18 @@ mod tests {
|
|||
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…
Add table
Add a link
Reference in a new issue