@@ -67,25 +67,21 @@ impl LateLintPass<'_> for SemicolonBlock {
67
67
fn check_stmt ( & mut self , cx : & LateContext < ' _ > , stmt : & Stmt < ' _ > ) {
68
68
match stmt. kind {
69
69
StmtKind :: Expr ( Expr {
70
- kind :
71
- ExprKind :: Block (
72
- block @ Block {
73
- expr : None ,
74
- stmts :
75
- & [
76
- ..,
77
- Stmt {
78
- kind : StmtKind :: Semi ( expr) ,
79
- span,
80
- ..
81
- } ,
82
- ] ,
83
- ..
84
- } ,
85
- _,
86
- ) ,
70
+ kind : ExprKind :: Block ( block, _) ,
87
71
..
88
- } ) if !block. span . from_expansion ( ) => semicolon_outside_block ( cx, block, expr, span) ,
72
+ } ) if !block. span . from_expansion ( ) => {
73
+ let Block {
74
+ expr : None ,
75
+ stmts : [ .., stmt] ,
76
+ ..
77
+ } = block else { return } ;
78
+ let & Stmt {
79
+ kind : StmtKind :: Semi ( expr) ,
80
+ span,
81
+ ..
82
+ } = stmt else { return } ;
83
+ semicolon_outside_block ( cx, block, expr, span)
84
+ } ,
89
85
StmtKind :: Semi ( Expr {
90
86
kind : ExprKind :: Block ( block @ Block { expr : Some ( tail) , .. } , _) ,
91
87
..
@@ -96,8 +92,7 @@ impl LateLintPass<'_> for SemicolonBlock {
96
92
}
97
93
98
94
fn semicolon_inside_block ( cx : & LateContext < ' _ > , block : & Block < ' _ > , tail : & Expr < ' _ > , semi_span : Span ) {
99
- let tail_span_end = tail. span . source_callsite ( ) . hi ( ) ;
100
- let insert_span = Span :: with_root_ctxt ( tail_span_end, tail_span_end) ;
95
+ let insert_span = tail. span . source_callsite ( ) . shrink_to_hi ( ) ;
101
96
let remove_span = semi_span. with_lo ( block. span . hi ( ) ) ;
102
97
103
98
span_lint_and_then (
0 commit comments