Skip to content

Commit 6d71ba7

Browse files
committed
Refactored multiline check
1 parent 6bf8303 commit 6d71ba7

File tree

1 file changed

+1
-22
lines changed

1 file changed

+1
-22
lines changed

clippy_lints/src/semicolon_if_nothing_returned.rs

+1-22
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ impl LateLintPass<'_> for SemicolonIfNothingReturned {
4747
if t_expr.is_unit();
4848
if let snippet = snippet_with_macro_callsite(cx, expr.span, "}");
4949
if !snippet.ends_with('}');
50-
if !check_if_inside_block_on_same_line(cx, block, expr);
50+
if cx.sess().source_map().is_multiline(block.span);
5151
then {
5252
// filter out the desugared `for` loop
5353
if let ExprKind::DropTemps(..) = &expr.kind {
@@ -69,24 +69,3 @@ impl LateLintPass<'_> for SemicolonIfNothingReturned {
6969
}
7070
}
7171
}
72-
73-
/// Check if this block is inside a closure or an unsafe block or a normal on the same line.
74-
fn check_if_inside_block_on_same_line<'tcx>(
75-
cx: &LateContext<'tcx>,
76-
block: &'tcx Block<'tcx>,
77-
last_expr: &'tcx Expr<'_>,
78-
) -> bool {
79-
if_chain! {
80-
if let Some(parent) = get_parent_expr_for_hir(cx, block.hir_id);
81-
82-
if !matches!(block.rules, BlockCheckMode::DefaultBlock) ||
83-
matches!(parent.kind, ExprKind::Closure(..) | ExprKind::Block(..));
84-
85-
if block.stmts.is_empty();
86-
then {
87-
let source_map = cx.sess().source_map();
88-
return !source_map.is_multiline(parent.span.to(last_expr.span));
89-
}
90-
}
91-
false
92-
}

0 commit comments

Comments
 (0)