Skip to content

Commit

Permalink
Auto merge of #6606 - ThibsG:AddTestNeedlessReturn, r=flip1995
Browse files Browse the repository at this point in the history
Add test for `needless_return` lint

Just a follow up of #6549 that adds a test for this lint.

changelog: none
  • Loading branch information
bors committed Jan 19, 2021
2 parents 91292f1 + e33ab3f commit ab1020b
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
6 changes: 6 additions & 0 deletions tests/ui/needless_return.fixed
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
6 changes: 6 additions & 0 deletions tests/ui/needless_return.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
8 changes: 7 additions & 1 deletion tests/ui/needless_return.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit ab1020b

Please sign in to comment.