Skip to content

Commit 111cf2a

Browse files
committed
Auto merge of #4023 - phansch:add_test, r=flip1995
Add test for or_fun_call macro suggestion changelog: none Closes #1018
2 parents bcf0805 + de24a74 commit 111cf2a

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

tests/ui/or_fun_call.rs

+4
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@ fn or_fun_call() {
6464

6565
let stringy = Some(String::from(""));
6666
let _ = stringy.unwrap_or("".to_owned());
67+
68+
let opt = Some(1);
69+
let hello = "Hello";
70+
let _ = opt.ok_or(format!("{} world.", hello));
6771
}
6872

6973
fn main() {}

tests/ui/or_fun_call.stderr

+7-1
Original file line numberDiff line numberDiff line change
@@ -72,5 +72,11 @@ error: use of `unwrap_or` followed by a function call
7272
LL | let _ = stringy.unwrap_or("".to_owned());
7373
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| "".to_owned())`
7474

75-
error: aborting due to 12 previous errors
75+
error: use of `ok_or` followed by a function call
76+
--> $DIR/or_fun_call.rs:70:17
77+
|
78+
LL | let _ = opt.ok_or(format!("{} world.", hello));
79+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `ok_or_else(|| format!("{} world.", hello))`
80+
81+
error: aborting due to 13 previous errors
7682

0 commit comments

Comments
 (0)