This repository was archived by the owner on May 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +32
-12
lines changed
ide-diagnostics/src/handlers Expand file tree Collapse file tree 2 files changed +32
-12
lines changed Original file line number Diff line number Diff line change @@ -1914,17 +1914,20 @@ impl DefWithBody {
19141914 if let ast:: Expr :: MatchExpr ( match_expr) =
19151915 & source_ptr. value . to_node ( & root)
19161916 {
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+ _ => { }
19281931 }
19291932 }
19301933 }
Original file line number Diff line number Diff line change @@ -17,14 +17,31 @@ pub(crate) fn missing_match_arms(
1717
1818#[ cfg( test) ]
1919mod tests {
20- use crate :: tests:: check_diagnostics;
20+ use crate :: {
21+ tests:: { check_diagnostics, check_diagnostics_with_config} ,
22+ DiagnosticsConfig ,
23+ } ;
2124
2225 #[ track_caller]
2326 fn check_diagnostics_no_bails ( ra_fixture : & str ) {
2427 cov_mark:: check_count!( validate_match_bailed_out, 0 ) ;
2528 crate :: tests:: check_diagnostics ( ra_fixture)
2629 }
2730
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+
2845 #[ test]
2946 fn empty_tuple ( ) {
3047 check_diagnostics_no_bails (
You can’t perform that action at this time.
0 commit comments