Skip to content

Commit

Permalink
Use closure body span (fixes #1405)
Browse files Browse the repository at this point in the history
  • Loading branch information
sinkuu committed Jan 15, 2017
1 parent 57e056d commit cdfe002
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion clippy_lints/src/returns.rs
Expand Up @@ -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)),
}
}

Expand Down
4 changes: 4 additions & 0 deletions tests/compile-fail/needless_return.rs
Expand Up @@ -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() {
Expand Down

0 comments on commit cdfe002

Please sign in to comment.