2021-03-25 18:29:11 +00:00
|
|
|
error: this could be simplified with `bool::then`
|
2024-02-17 12:16:29 +00:00
|
|
|
--> tests/ui/if_then_some_else_none.rs:6:13
|
2021-03-25 18:29:11 +00:00
|
|
|
|
|
|
|
|
LL | let _ = if foo() {
|
|
|
|
| _____________^
|
2023-08-24 19:32:12 +00:00
|
|
|
LL | |
|
2021-03-25 18:29:11 +00:00
|
|
|
LL | | println!("true!");
|
|
|
|
LL | | Some("foo")
|
|
|
|
LL | | } else {
|
|
|
|
LL | | None
|
|
|
|
LL | | };
|
2024-07-21 09:00:02 +00:00
|
|
|
| |_____^ help: try: `foo().then(|| { println!("true!"); "foo" })`
|
2021-03-25 18:29:11 +00:00
|
|
|
|
|
2022-09-22 16:04:22 +00:00
|
|
|
= note: `-D clippy::if-then-some-else-none` implied by `-D warnings`
|
2023-08-01 12:02:21 +00:00
|
|
|
= help: to override `-D warnings` add `#[allow(clippy::if_then_some_else_none)]`
|
2021-03-25 18:29:11 +00:00
|
|
|
|
|
|
|
error: this could be simplified with `bool::then`
|
2024-02-17 12:16:29 +00:00
|
|
|
--> tests/ui/if_then_some_else_none.rs:15:13
|
2021-03-25 18:29:11 +00:00
|
|
|
|
|
|
|
|
LL | let _ = if matches!(true, true) {
|
|
|
|
| _____________^
|
2023-08-24 19:32:12 +00:00
|
|
|
LL | |
|
2021-03-25 18:29:11 +00:00
|
|
|
LL | | println!("true!");
|
|
|
|
LL | | Some(matches!(true, false))
|
|
|
|
LL | | } else {
|
|
|
|
LL | | None
|
|
|
|
LL | | };
|
2024-07-21 09:00:02 +00:00
|
|
|
| |_____^ help: try: `matches!(true, true).then(|| { println!("true!"); matches!(true, false) })`
|
2021-03-25 18:29:11 +00:00
|
|
|
|
2022-08-31 13:24:45 +00:00
|
|
|
error: this could be simplified with `bool::then_some`
|
2024-02-17 12:16:29 +00:00
|
|
|
--> tests/ui/if_then_some_else_none.rs:25:28
|
2021-03-25 18:29:11 +00:00
|
|
|
|
|
|
|
|
LL | let _ = x.and_then(|o| if o < 32 { Some(o) } else { None });
|
2024-07-21 09:00:02 +00:00
|
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `(o < 32).then_some(o)`
|
2021-03-25 18:29:11 +00:00
|
|
|
|
2022-08-31 13:24:45 +00:00
|
|
|
error: this could be simplified with `bool::then_some`
|
2024-02-17 12:16:29 +00:00
|
|
|
--> tests/ui/if_then_some_else_none.rs:30:13
|
2021-03-25 18:29:11 +00:00
|
|
|
|
|
|
|
|
LL | let _ = if !x { Some(0) } else { None };
|
2024-07-21 09:00:02 +00:00
|
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `(!x).then_some(0)`
|
2021-03-25 18:29:11 +00:00
|
|
|
|
|
|
|
error: this could be simplified with `bool::then`
|
2024-02-17 12:16:29 +00:00
|
|
|
--> tests/ui/if_then_some_else_none.rs:86:13
|
2021-03-25 18:29:11 +00:00
|
|
|
|
|
|
|
|
LL | let _ = if foo() {
|
|
|
|
| _____________^
|
2023-08-24 19:32:12 +00:00
|
|
|
LL | |
|
2021-03-25 18:29:11 +00:00
|
|
|
LL | | println!("true!");
|
|
|
|
LL | | Some(150)
|
|
|
|
LL | | } else {
|
|
|
|
LL | | None
|
|
|
|
LL | | };
|
2024-07-21 09:00:02 +00:00
|
|
|
| |_____^ help: try: `foo().then(|| { println!("true!"); 150 })`
|
2021-03-25 18:29:11 +00:00
|
|
|
|
2024-09-17 21:19:29 +00:00
|
|
|
error: this could be simplified with `bool::then`
|
|
|
|
--> tests/ui/if_then_some_else_none.rs:135:5
|
|
|
|
|
|
|
|
|
LL | if s == "1" { Some(true) } else { None }
|
|
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `(s == "1").then(|| true)`
|
|
|
|
|
|
|
|
error: aborting due to 6 previous errors
|
2021-03-25 18:29:11 +00:00
|
|
|
|