From de24a74b45e2deff5cdae3f3f1f391c058fe1b90 Mon Sep 17 00:00:00 2001 From: Philipp Hansch Date: Wed, 24 Apr 2019 08:11:20 +0200 Subject: [PATCH] Add test for or_fun_call macro suggestion Closes #1018 --- tests/ui/or_fun_call.rs | 4 ++++ tests/ui/or_fun_call.stderr | 8 +++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/tests/ui/or_fun_call.rs b/tests/ui/or_fun_call.rs index 562120c3ea0..1b4732b5b56 100644 --- a/tests/ui/or_fun_call.rs +++ b/tests/ui/or_fun_call.rs @@ -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() {} diff --git a/tests/ui/or_fun_call.stderr b/tests/ui/or_fun_call.stderr index 40ae09cc20e..5d6ebb50a89 100644 --- a/tests/ui/or_fun_call.stderr +++ b/tests/ui/or_fun_call.stderr @@ -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