Auto merge of #4023 - phansch:add_test, r=flip1995

Add test for or_fun_call macro suggestion

changelog: none

Closes #1018
This commit is contained in:
bors 2019-04-24 17:16:59 +00:00
commit 111cf2a067
2 changed files with 11 additions and 1 deletions

View file

@ -64,6 +64,10 @@ fn or_fun_call() {
let stringy = Some(String::from(""));
let _ = stringy.unwrap_or("".to_owned());
let opt = Some(1);
let hello = "Hello";
let _ = opt.ok_or(format!("{} world.", hello));
}
fn main() {}

View file

@ -72,5 +72,11 @@ error: use of `unwrap_or` followed by a function call
LL | let _ = stringy.unwrap_or("".to_owned());
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| "".to_owned())`
error: aborting due to 12 previous errors
error: use of `ok_or` followed by a function call
--> $DIR/or_fun_call.rs:70: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