about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2019-04-24 17:16:59 +0000
committerbors <bors@rust-lang.org>2019-04-24 17:16:59 +0000
commit111cf2a06745b3c54b46e430de534e4b10314656 (patch)
tree19f02599ed170bcb5595007a570ef3133d3731da
parentbcf0805614e1d0e115d6f0641dd4fcf2b40d3737 (diff)
parentde24a74b45e2deff5cdae3f3f1f391c058fe1b90 (diff)
downloadrust-111cf2a06745b3c54b46e430de534e4b10314656.tar.gz
rust-111cf2a06745b3c54b46e430de534e4b10314656.zip
Auto merge of #4023 - phansch:add_test, r=flip1995
Add test for or_fun_call macro suggestion

changelog: none

Closes #1018
-rw-r--r--tests/ui/or_fun_call.rs4
-rw-r--r--tests/ui/or_fun_call.stderr8
2 files changed, 11 insertions, 1 deletions
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