]> git.lizzy.rs Git - rust.git/blob - src/tools/clippy/tests/ui/if_then_some_else_none.stderr
Auto merge of #102026 - Bryanskiy:resolve_update, r=petrochenkov
[rust.git] / src / tools / clippy / tests / ui / if_then_some_else_none.stderr
1 error: this could be simplified with `bool::then`
2   --> $DIR/if_then_some_else_none.rs:6:13
3    |
4 LL |       let _ = if foo() {
5    |  _____________^
6 LL | |         println!("true!");
7 LL | |         Some("foo")
8 LL | |     } else {
9 LL | |         None
10 LL | |     };
11    | |_____^
12    |
13    = help: consider using `bool::then` like: `foo().then(|| { /* snippet */ "foo" })`
14    = note: `-D clippy::if-then-some-else-none` implied by `-D warnings`
15
16 error: this could be simplified with `bool::then`
17   --> $DIR/if_then_some_else_none.rs:14:13
18    |
19 LL |       let _ = if matches!(true, true) {
20    |  _____________^
21 LL | |         println!("true!");
22 LL | |         Some(matches!(true, false))
23 LL | |     } else {
24 LL | |         None
25 LL | |     };
26    | |_____^
27    |
28    = help: consider using `bool::then` like: `matches!(true, true).then(|| { /* snippet */ matches!(true, false) })`
29
30 error: this could be simplified with `bool::then_some`
31   --> $DIR/if_then_some_else_none.rs:23:28
32    |
33 LL |     let _ = x.and_then(|o| if o < 32 { Some(o) } else { None });
34    |                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
35    |
36    = help: consider using `bool::then_some` like: `(o < 32).then_some(o)`
37
38 error: this could be simplified with `bool::then_some`
39   --> $DIR/if_then_some_else_none.rs:27:13
40    |
41 LL |     let _ = if !x { Some(0) } else { None };
42    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
43    |
44    = help: consider using `bool::then_some` like: `(!x).then_some(0)`
45
46 error: this could be simplified with `bool::then`
47   --> $DIR/if_then_some_else_none.rs:82:13
48    |
49 LL |       let _ = if foo() {
50    |  _____________^
51 LL | |         println!("true!");
52 LL | |         Some(150)
53 LL | |     } else {
54 LL | |         None
55 LL | |     };
56    | |_____^
57    |
58    = help: consider using `bool::then` like: `foo().then(|| { /* snippet */ 150 })`
59
60 error: aborting due to 5 previous errors
61