Skip to content

Commit 16b016e

Browse files
committed
Address reviews
1 parent 8fc889c commit 16b016e

File tree

1 file changed

+15
-20
lines changed

1 file changed

+15
-20
lines changed

clippy_lints/src/semicolon_block.rs

+15-20
Original file line numberDiff line numberDiff line change
@@ -67,25 +67,21 @@ impl LateLintPass<'_> for SemicolonBlock {
6767
fn check_stmt(&mut self, cx: &LateContext<'_>, stmt: &Stmt<'_>) {
6868
match stmt.kind {
6969
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, _),
8771
..
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+
},
8985
StmtKind::Semi(Expr {
9086
kind: ExprKind::Block(block @ Block { expr: Some(tail), .. }, _),
9187
..
@@ -96,8 +92,7 @@ impl LateLintPass<'_> for SemicolonBlock {
9692
}
9793

9894
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();
10196
let remove_span = semi_span.with_lo(block.span.hi());
10297

10398
span_lint_and_then(

0 commit comments

Comments
 (0)