diff --git a/clippy_lints/src/returns.rs b/clippy_lints/src/returns.rs index b9054f721..1e31c0ea3 100644 --- a/clippy_lints/src/returns.rs +++ b/clippy_lints/src/returns.rs @@ -138,7 +138,7 @@ impl EarlyLintPass for ReturnPass { match kind { FnKind::ItemFn(.., block) | FnKind::Method(.., block) => self.check_block_return(cx, block), - FnKind::Closure(body) => self.check_final_expr(cx, body, None), + FnKind::Closure(body) => self.check_final_expr(cx, body, Some(body.span)), } } diff --git a/tests/compile-fail/needless_return.rs b/tests/compile-fail/needless_return.rs index 5a391a358..442a0b925 100644 --- a/tests/compile-fail/needless_return.rs +++ b/tests/compile-fail/needless_return.rs @@ -58,6 +58,10 @@ fn test_closure() { //~| HELP remove `return` as shown //~| SUGGESTION true }; + let _ = || return true; + //~^ ERROR unneeded return statement + //~| HELP remove `return` as shown + //~| SUGGESTION true } fn main() {