mirror of
https://github.com/rust-lang/rust.git
synced 2025-04-13 20:46:48 +00:00
Add test for needless_return
lint
This commit is contained in:
parent
91292f1eef
commit
e33ab3fdd8
@ -112,6 +112,12 @@ mod issue6501 {
|
||||
};
|
||||
let _ = || {};
|
||||
}
|
||||
|
||||
struct Foo;
|
||||
#[allow(clippy::unnecessary_lazy_evaluations)]
|
||||
fn bar(res: Result<Foo, u8>) -> Foo {
|
||||
res.unwrap_or_else(|_| Foo)
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
@ -112,6 +112,12 @@ mod issue6501 {
|
||||
};
|
||||
let _ = || return;
|
||||
}
|
||||
|
||||
struct Foo;
|
||||
#[allow(clippy::unnecessary_lazy_evaluations)]
|
||||
fn bar(res: Result<Foo, u8>) -> Foo {
|
||||
res.unwrap_or_else(|_| return Foo)
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
@ -102,5 +102,11 @@ error: unneeded `return` statement
|
||||
LL | let _ = || return;
|
||||
| ^^^^^^ help: replace `return` with an empty block: `{}`
|
||||
|
||||
error: aborting due to 17 previous errors
|
||||
error: unneeded `return` statement
|
||||
--> $DIR/needless_return.rs:119:32
|
||||
|
|
||||
LL | res.unwrap_or_else(|_| return Foo)
|
||||
| ^^^^^^^^^^ help: remove `return`: `Foo`
|
||||
|
||||
error: aborting due to 18 previous errors
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user