mirror of https://github.com/rust-lang/rust.git
Use closure body span (fixes #1405)
This commit is contained in:
parent
57e056dfc7
commit
cdfe002ee1
|
@ -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)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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() {
|
||||||
|
|
Loading…
Reference in New Issue