From 8642306f090f2f91c89d5cb992b3085ec0f39699 Mon Sep 17 00:00:00 2001 From: mcarton Date: Mon, 18 Jan 2016 13:36:58 +0100 Subject: [PATCH] Add a test for the OR_FUN_CALL lint --- tests/compile-fail/methods.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tests/compile-fail/methods.rs b/tests/compile-fail/methods.rs index d357fb0a54a..f8642cb3ed8 100644 --- a/tests/compile-fail/methods.rs +++ b/tests/compile-fail/methods.rs @@ -177,6 +177,12 @@ fn search_is_some() { /// Checks implementation of the OR_FUN_CALL lint fn or_fun_call() { + struct Foo; + + impl Foo { + fn new() -> Foo { Foo } + } + fn make() -> T { unimplemented!(); } let with_constructor = Some(vec![1]); @@ -226,6 +232,12 @@ fn or_fun_call() { //~^ERROR use of `unwrap_or` //~|HELP try this //~|SUGGESTION with_vec.unwrap_or_else(|| vec![]); + + let without_default = Some(Foo); + without_default.unwrap_or(Foo::new()); + //~^ERROR use of `unwrap_or` + //~|HELP try this + //~|SUGGESTION without_default.unwrap_or_else(Foo::new); } fn main() {