File tree 2 files changed +22
-7
lines changed
2 files changed +22
-7
lines changed Original file line number Diff line number Diff line change @@ -48,13 +48,20 @@ impl LateLintPass<'_> for SemicolonOutsideBlock {
48
48
then {
49
49
// make sure that the block does not belong to a function
50
50
for ( hir_id, _) in cx. tcx. hir( ) . parent_iter( block. hir_id) {
51
- if_chain! {
52
- if let Some ( body_id) = cx. tcx. hir( ) . maybe_body_owned_by( hir_id) ;
53
- if let BodyOwnerKind :: Fn = cx. tcx. hir( ) . body_owner_kind( hir_id) ;
54
- let item_body = cx. tcx. hir( ) . body( body_id) ;
55
- if let ExprKind :: Block ( fn_block, _) = item_body. value. kind;
56
- if fn_block. hir_id == block. hir_id;
57
- then { return }
51
+ if let Some ( body_id) = cx. tcx. hir( ) . maybe_body_owned_by( hir_id) {
52
+ if let BodyOwnerKind :: Fn = cx. tcx. hir( ) . body_owner_kind( hir_id) {
53
+ let item_body = cx. tcx. hir( ) . body( body_id) ;
54
+ if let ExprKind :: Block ( fn_block, _) = item_body. value. kind {
55
+ if let Some ( pot_if) = fn_block. expr {
56
+ if let ExprKind :: If ( ..) = pot_if. kind {
57
+ return ;
58
+ }
59
+ }
60
+ if fn_block. hir_id == block. hir_id {
61
+ return
62
+ }
63
+ }
64
+ }
58
65
}
59
66
}
60
67
// filter out other blocks and the desugared for loop
Original file line number Diff line number Diff line change @@ -61,3 +61,11 @@ fn my_own_block() {
61
61
fn just_get_unit ( ) {
62
62
get_unit ( ) ;
63
63
}
64
+
65
+ fn test_if ( ) {
66
+ if 1 > 2 {
67
+ get_unit ( ) ;
68
+ } else {
69
+ println ! ( "everything alright!" ) ;
70
+ }
71
+ }
You can’t perform that action at this time.
0 commit comments