diff --git a/clippy_lints/src/returns/let_and_return.rs b/clippy_lints/src/returns/let_and_return.rs index 0a00981e15be..b19935959c4d 100644 --- a/clippy_lints/src/returns/let_and_return.rs +++ b/clippy_lints/src/returns/let_and_return.rs @@ -27,7 +27,7 @@ pub(super) fn check_block<'tcx>(cx: &LateContext<'tcx>, block: &'tcx Block<'_>) && !initexpr.span.in_external_macro(cx.sess().source_map()) && !retexpr.span.in_external_macro(cx.sess().source_map()) && !local.span.from_expansion() - && !span_contains_non_whitespace(cx, stmt.span.between(retexpr.span), true) + && !span_contains_non_whitespace(cx, stmt.span.between(retexpr.span), false) { span_lint_hir_and_then( cx, diff --git a/tests/ui/let_and_return.edition2021.fixed b/tests/ui/let_and_return.edition2021.fixed index e89e4476bf82..6ca0febc2b8d 100644 --- a/tests/ui/let_and_return.edition2021.fixed +++ b/tests/ui/let_and_return.edition2021.fixed @@ -271,4 +271,12 @@ fn issue15987() -> i32 { r } +fn has_comment() -> Vec { + let v = Vec::new(); + + // TODO: stuff + + v +} + fn main() {} diff --git a/tests/ui/let_and_return.edition2024.fixed b/tests/ui/let_and_return.edition2024.fixed index d2c76673ca03..0fce22936ae6 100644 --- a/tests/ui/let_and_return.edition2024.fixed +++ b/tests/ui/let_and_return.edition2024.fixed @@ -271,4 +271,12 @@ fn issue15987() -> i32 { r } +fn has_comment() -> Vec { + let v = Vec::new(); + + // TODO: stuff + + v +} + fn main() {} diff --git a/tests/ui/let_and_return.rs b/tests/ui/let_and_return.rs index 1af5f8ba5c16..301f153ca8b1 100644 --- a/tests/ui/let_and_return.rs +++ b/tests/ui/let_and_return.rs @@ -271,4 +271,12 @@ fn issue15987() -> i32 { r } +fn has_comment() -> Vec { + let v = Vec::new(); + + // TODO: stuff + + v +} + fn main() {}