mirror of
https://github.com/rust-lang/rust-clippy
synced 2025-02-17 14:38:46 +00:00
Add a test for the OR_FUN_CALL lint
This commit is contained in:
parent
21ba315102
commit
8642306f09
1 changed files with 12 additions and 0 deletions
|
@ -177,6 +177,12 @@ fn search_is_some() {
|
||||||
|
|
||||||
/// Checks implementation of the OR_FUN_CALL lint
|
/// Checks implementation of the OR_FUN_CALL lint
|
||||||
fn or_fun_call() {
|
fn or_fun_call() {
|
||||||
|
struct Foo;
|
||||||
|
|
||||||
|
impl Foo {
|
||||||
|
fn new() -> Foo { Foo }
|
||||||
|
}
|
||||||
|
|
||||||
fn make<T>() -> T { unimplemented!(); }
|
fn make<T>() -> T { unimplemented!(); }
|
||||||
|
|
||||||
let with_constructor = Some(vec![1]);
|
let with_constructor = Some(vec![1]);
|
||||||
|
@ -226,6 +232,12 @@ fn or_fun_call() {
|
||||||
//~^ERROR use of `unwrap_or`
|
//~^ERROR use of `unwrap_or`
|
||||||
//~|HELP try this
|
//~|HELP try this
|
||||||
//~|SUGGESTION with_vec.unwrap_or_else(|| vec![]);
|
//~|SUGGESTION with_vec.unwrap_or_else(|| vec![]);
|
||||||
|
|
||||||
|
let without_default = Some(Foo);
|
||||||
|
without_default.unwrap_or(Foo::new());
|
||||||
|
//~^ERROR use of `unwrap_or`
|
||||||
|
//~|HELP try this
|
||||||
|
//~|SUGGESTION without_default.unwrap_or_else(Foo::new);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
|
Loading…
Add table
Reference in a new issue