File tree 2 files changed +32
-12
lines changed
ide-diagnostics/src/handlers
2 files changed +32
-12
lines changed Original file line number Diff line number Diff line change @@ -1914,17 +1914,20 @@ impl DefWithBody {
1914
1914
if let ast:: Expr :: MatchExpr ( match_expr) =
1915
1915
& source_ptr. value . to_node ( & root)
1916
1916
{
1917
- if let Some ( scrut_expr) = match_expr. expr ( ) {
1918
- acc. push (
1919
- MissingMatchArms {
1920
- scrutinee_expr : InFile :: new (
1921
- source_ptr. file_id ,
1922
- AstPtr :: new ( & scrut_expr) ,
1923
- ) ,
1924
- uncovered_patterns,
1925
- }
1926
- . into ( ) ,
1927
- ) ;
1917
+ match match_expr. expr ( ) {
1918
+ Some ( scrut_expr) if match_expr. match_arm_list ( ) . is_some ( ) => {
1919
+ acc. push (
1920
+ MissingMatchArms {
1921
+ scrutinee_expr : InFile :: new (
1922
+ source_ptr. file_id ,
1923
+ AstPtr :: new ( & scrut_expr) ,
1924
+ ) ,
1925
+ uncovered_patterns,
1926
+ }
1927
+ . into ( ) ,
1928
+ ) ;
1929
+ }
1930
+ _ => { }
1928
1931
}
1929
1932
}
1930
1933
}
Original file line number Diff line number Diff line change @@ -17,14 +17,31 @@ pub(crate) fn missing_match_arms(
17
17
18
18
#[ cfg( test) ]
19
19
mod tests {
20
- use crate :: tests:: check_diagnostics;
20
+ use crate :: {
21
+ tests:: { check_diagnostics, check_diagnostics_with_config} ,
22
+ DiagnosticsConfig ,
23
+ } ;
21
24
22
25
#[ track_caller]
23
26
fn check_diagnostics_no_bails ( ra_fixture : & str ) {
24
27
cov_mark:: check_count!( validate_match_bailed_out, 0 ) ;
25
28
crate :: tests:: check_diagnostics ( ra_fixture)
26
29
}
27
30
31
+ #[ test]
32
+ fn empty_body ( ) {
33
+ let mut config = DiagnosticsConfig :: test_sample ( ) ;
34
+ config. disabled . insert ( "syntax-error" . to_string ( ) ) ;
35
+ check_diagnostics_with_config (
36
+ config,
37
+ r#"
38
+ fn main() {
39
+ match 0;
40
+ }
41
+ "# ,
42
+ ) ;
43
+ }
44
+
28
45
#[ test]
29
46
fn empty_tuple ( ) {
30
47
check_diagnostics_no_bails (
You can’t perform that action at this time.
0 commit comments