Use closure body span (fixes #1405)

This commit is contained in:
sinkuu 2017-01-15 13:16:02 +09:00
parent 57e056dfc7
commit cdfe002ee1
2 changed files with 5 additions and 1 deletions

View File

@ -138,7 +138,7 @@ impl EarlyLintPass for ReturnPass {
match kind { match kind {
FnKind::ItemFn(.., block) | FnKind::ItemFn(.., block) |
FnKind::Method(.., block) => self.check_block_return(cx, 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)),
} }
} }

View File

@ -58,6 +58,10 @@ fn test_closure() {
//~| HELP remove `return` as shown //~| HELP remove `return` as shown
//~| SUGGESTION true //~| SUGGESTION true
}; };
let _ = || return true;
//~^ ERROR unneeded return statement
//~| HELP remove `return` as shown
//~| SUGGESTION true
} }
fn main() { fn main() {