-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #4084 - mikerite:fix-4019, r=oli-obk
Fix 4019 Fixes #4019
- Loading branch information
Showing
4 changed files
with
100 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,82 +1,88 @@ | ||
error: use of `unwrap_or` followed by a function call | ||
--> $DIR/or_fun_call.rs:31:22 | ||
--> $DIR/or_fun_call.rs:32:22 | ||
| | ||
LL | with_constructor.unwrap_or(make()); | ||
| ^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(make)` | ||
| | ||
= note: `-D clippy::or-fun-call` implied by `-D warnings` | ||
|
||
error: use of `unwrap_or` followed by a call to `new` | ||
--> $DIR/or_fun_call.rs:34:5 | ||
--> $DIR/or_fun_call.rs:35:5 | ||
| | ||
LL | with_new.unwrap_or(Vec::new()); | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `with_new.unwrap_or_default()` | ||
|
||
error: use of `unwrap_or` followed by a function call | ||
--> $DIR/or_fun_call.rs:37:21 | ||
--> $DIR/or_fun_call.rs:38:21 | ||
| | ||
LL | with_const_args.unwrap_or(Vec::with_capacity(12)); | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| Vec::with_capacity(12))` | ||
|
||
error: use of `unwrap_or` followed by a function call | ||
--> $DIR/or_fun_call.rs:40:14 | ||
--> $DIR/or_fun_call.rs:41:14 | ||
| | ||
LL | with_err.unwrap_or(make()); | ||
| ^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|_| make())` | ||
|
||
error: use of `unwrap_or` followed by a function call | ||
--> $DIR/or_fun_call.rs:43:19 | ||
--> $DIR/or_fun_call.rs:44:19 | ||
| | ||
LL | with_err_args.unwrap_or(Vec::with_capacity(12)); | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|_| Vec::with_capacity(12))` | ||
|
||
error: use of `unwrap_or` followed by a call to `default` | ||
--> $DIR/or_fun_call.rs:46:5 | ||
--> $DIR/or_fun_call.rs:47:5 | ||
| | ||
LL | with_default_trait.unwrap_or(Default::default()); | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `with_default_trait.unwrap_or_default()` | ||
|
||
error: use of `unwrap_or` followed by a call to `default` | ||
--> $DIR/or_fun_call.rs:49:5 | ||
--> $DIR/or_fun_call.rs:50:5 | ||
| | ||
LL | with_default_type.unwrap_or(u64::default()); | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `with_default_type.unwrap_or_default()` | ||
|
||
error: use of `unwrap_or` followed by a function call | ||
--> $DIR/or_fun_call.rs:52:14 | ||
--> $DIR/or_fun_call.rs:53:14 | ||
| | ||
LL | with_vec.unwrap_or(vec![]); | ||
| ^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| vec![])` | ||
|
||
error: use of `unwrap_or` followed by a function call | ||
--> $DIR/or_fun_call.rs:57:21 | ||
--> $DIR/or_fun_call.rs:58:21 | ||
| | ||
LL | without_default.unwrap_or(Foo::new()); | ||
| ^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(Foo::new)` | ||
|
||
error: use of `or_insert` followed by a function call | ||
--> $DIR/or_fun_call.rs:60:19 | ||
--> $DIR/or_fun_call.rs:61:19 | ||
| | ||
LL | map.entry(42).or_insert(String::new()); | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `or_insert_with(String::new)` | ||
|
||
error: use of `or_insert` followed by a function call | ||
--> $DIR/or_fun_call.rs:63:21 | ||
--> $DIR/or_fun_call.rs:64:21 | ||
| | ||
LL | btree.entry(42).or_insert(String::new()); | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `or_insert_with(String::new)` | ||
|
||
error: use of `unwrap_or` followed by a function call | ||
--> $DIR/or_fun_call.rs:66:21 | ||
--> $DIR/or_fun_call.rs:67:21 | ||
| | ||
LL | let _ = stringy.unwrap_or("".to_owned()); | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| "".to_owned())` | ||
|
||
error: use of `ok_or` followed by a function call | ||
--> $DIR/or_fun_call.rs:70:17 | ||
--> $DIR/or_fun_call.rs:71:17 | ||
| | ||
LL | let _ = opt.ok_or(format!("{} world.", hello)); | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `ok_or_else(|| format!("{} world.", hello))` | ||
|
||
error: aborting due to 13 previous errors | ||
error: use of `or` followed by a function call | ||
--> $DIR/or_fun_call.rs:92:35 | ||
| | ||
LL | let _ = Some("a".to_string()).or(Some("b".to_string())); | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `or_else(|| Some("b".to_string()))` | ||
|
||
error: aborting due to 14 previous errors | ||
|