Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Rustup to #71796
  • Loading branch information
flip1995 committed Jun 7, 2020
1 parent 1a8a69d commit 5bdbc45
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
4 changes: 2 additions & 2 deletions tests/ui/or_fun_call.fixed
Expand Up @@ -29,7 +29,7 @@ fn or_fun_call() {
with_enum.unwrap_or(Enum::A(5));

let with_const_fn = Some(Duration::from_secs(1));
with_const_fn.unwrap_or(Duration::from_secs(5));
with_const_fn.unwrap_or_else(|| Duration::from_secs(5));

let with_constructor = Some(vec![1]);
with_constructor.unwrap_or_else(make);
Expand Down Expand Up @@ -94,7 +94,7 @@ fn test_or_with_ctors() {

let b = "b".to_string();
let _ = Some(Bar("a".to_string(), Duration::from_secs(1)))
.or(Some(Bar(b, Duration::from_secs(2))));
.or_else(|| Some(Bar(b, Duration::from_secs(2))));

let vec = vec!["foo"];
let _ = opt.ok_or(vec.len());
Expand Down
18 changes: 15 additions & 3 deletions tests/ui/or_fun_call.stderr
@@ -1,10 +1,16 @@
error: use of `unwrap_or` followed by a function call
--> $DIR/or_fun_call.rs:32:19
|
LL | with_const_fn.unwrap_or(Duration::from_secs(5));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| Duration::from_secs(5))`
|
= note: `-D clippy::or-fun-call` implied by `-D warnings`

error: use of `unwrap_or` followed by a function call
--> $DIR/or_fun_call.rs:35:22
|
LL | with_constructor.unwrap_or(make());
| ^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(make)`
|
= note: `-D clippy::or-fun-call` implied by `-D warnings`

error: use of `unwrap_or` followed by a call to `new`
--> $DIR/or_fun_call.rs:38:5
Expand Down Expand Up @@ -78,5 +84,11 @@ error: use of `or` followed by a function call
LL | let _ = Some("a".to_string()).or(Some("b".to_string()));
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `or_else(|| Some("b".to_string()))`

error: aborting due to 13 previous errors
error: use of `or` followed by a function call
--> $DIR/or_fun_call.rs:97:10
|
LL | .or(Some(Bar(b, Duration::from_secs(2))));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `or_else(|| Some(Bar(b, Duration::from_secs(2))))`

error: aborting due to 15 previous errors

0 comments on commit 5bdbc45

Please sign in to comment.