diff --git a/clippy_lints/src/semicolon_if_nothing_returned.rs b/clippy_lints/src/semicolon_if_nothing_returned.rs index 3698e548b..eff6cdf36 100644 --- a/clippy_lints/src/semicolon_if_nothing_returned.rs +++ b/clippy_lints/src/semicolon_if_nothing_returned.rs @@ -1,6 +1,7 @@ +use crate::rustc_lint::LintContext; use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::source::snippet_with_macro_callsite; -use clippy_utils::{get_parent_expr_for_hir, in_macro, spans_on_same_line, sugg}; +use clippy_utils::{get_parent_expr_for_hir, in_macro, sugg}; use if_chain::if_chain; use rustc_errors::Applicability; use rustc_hir::Expr; @@ -83,7 +84,8 @@ fn check_if_inside_block_on_same_line<'tcx>( if block.stmts.is_empty(); then { - return spans_on_same_line(cx, parent.span, last_expr.span); + let source_map = cx.sess().source_map(); + return !source_map.is_multiline(parent.span.to(last_expr.span)); } } false diff --git a/clippy_utils/src/lib.rs b/clippy_utils/src/lib.rs index be625eb26..769836aaf 100644 --- a/clippy_utils/src/lib.rs +++ b/clippy_utils/src/lib.rs @@ -820,11 +820,6 @@ fn line_span(cx: &T, span: Span) -> Span { Span::new(line_start, span.hi(), span.ctxt()) } -/// Checks if two spans begin on the same line. -pub fn spans_on_same_line(cx: &T, left_span: Span, right_span: Span) -> bool { - line_span(cx, left_span).lo() == line_span(cx, right_span).lo() -} - /// Gets the parent node, if any. pub fn get_parent_node(tcx: TyCtxt<'_>, id: HirId) -> Option> { tcx.hir().parent_iter(id).next().map(|(_, node)| node)