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 @@ fn check_fn(&mut self, cx: &EarlyContext, kind: FnKind, _: &ast::FnDecl, _: Span
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() {