@@ -77,13 +77,11 @@ impl<'a, 'b> ExprValidator<'a, 'b> {
77
77
}
78
78
}
79
79
let body_expr = & body[ body. body_expr ] ;
80
- if let Expr :: Block { tail : Some ( t) , .. } = body_expr {
81
- self . validate_results_in_tail_expr ( body. body_expr , * t, db) ;
82
- } else {
83
- if let Expr :: Block { statements, .. } = body_expr {
84
- if let Some ( Statement :: Expr ( id) ) = statements. last ( ) {
85
- self . validate_missing_tail_expr ( body. body_expr , * id, db) ;
86
- }
80
+ if let Expr :: Block { statements, tail, .. } = body_expr {
81
+ if let Some ( t) = tail {
82
+ self . validate_results_in_tail_expr ( body. body_expr , * t, db) ;
83
+ } else if let Some ( Statement :: Expr ( id) ) = statements. last ( ) {
84
+ self . validate_missing_tail_expr ( body. body_expr , * id, db) ;
87
85
}
88
86
}
89
87
}
@@ -336,17 +334,22 @@ impl<'a, 'b> ExprValidator<'a, 'b> {
336
334
None => return ,
337
335
} ;
338
336
339
- if let Some ( possible_tail_ty) = self . infer . type_of_expr . get ( possible_tail_id) {
340
- if mismatch. actual == Ty :: unit ( ) && mismatch. expected == * possible_tail_ty {
341
- let ( _, source_map) = db. body_with_source_map ( self . owner . into ( ) ) ;
337
+ let possible_tail_ty = if let Some ( possible_tail_ty) = self . infer . type_of_expr . get ( possible_tail_id) {
338
+ possible_tail_ty
339
+ } else {
340
+ return ;
341
+ } ;
342
342
343
- if let Ok ( source_ptr) = source_map. expr_syntax ( possible_tail_id) {
344
- self . sink . push ( RemoveThisSemicolon {
345
- file : source_ptr. file_id ,
346
- expr : source_ptr. value ,
347
- } ) ;
348
- }
349
- }
343
+ if mismatch. actual != Ty :: unit ( ) || mismatch. expected != * possible_tail_ty {
344
+ return ;
345
+ }
346
+
347
+ let ( _, source_map) = db. body_with_source_map ( self . owner . into ( ) ) ;
348
+ if let Ok ( source_ptr) = source_map. expr_syntax ( possible_tail_id) {
349
+ self . sink . push ( RemoveThisSemicolon {
350
+ file : source_ptr. file_id ,
351
+ expr : source_ptr. value ,
352
+ } ) ;
350
353
}
351
354
}
352
355
}
0 commit comments