File tree Expand file tree Collapse file tree 2 files changed +22
-7
lines changed Expand file tree Collapse file tree 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 {
4848 then {
4949 // make sure that the block does not belong to a function
5050 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+ }
5865 }
5966 }
6067 // 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() {
6161fn just_get_unit ( ) {
6262 get_unit ( ) ;
6363}
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