Merge pull request #1445 from sinkuu/fix_closure_return

Use closure body span for needless_return lint (fixes #1405)
This commit is contained in:
llogiq 2017-01-15 06:20:54 +01:00 committed by GitHub
commit 6d22aa42e0
2 changed files with 5 additions and 1 deletions

View File

@ -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)),
}
}

View File

@ -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() {