From cdfe002ee1395a499c2f37b99512b3f27d9d573f Mon Sep 17 00:00:00 2001 From: sinkuu Date: Sun, 15 Jan 2017 13:16:02 +0900 Subject: [PATCH] Use closure body span (fixes #1405) --- clippy_lints/src/returns.rs | 2 +- tests/compile-fail/needless_return.rs | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/clippy_lints/src/returns.rs b/clippy_lints/src/returns.rs index b9054f72164..1e31c0ea374 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 5a391a358b1..442a0b925cb 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() {