2020-10-23 22:16:59 +02:00
|
|
|
error: this pattern reimplements `Option::unwrap_or`
|
2024-03-21 22:20:40 +01:00
|
|
|
--> tests/ui/manual_unwrap_or.rs:11:5
|
2020-10-23 22:16:59 +02:00
|
|
|
|
|
|
|
|
|
LL | / match Some(1) {
|
2025-02-11 17:57:08 +01:00
|
|
|
LL | |
|
2020-10-23 22:16:59 +02:00
|
|
|
LL | | Some(i) => i,
|
|
|
|
|
LL | | None => 42,
|
|
|
|
|
LL | | };
|
|
|
|
|
| |_____^ help: replace with: `Some(1).unwrap_or(42)`
|
|
|
|
|
|
|
|
|
|
|
= note: `-D clippy::manual-unwrap-or` implied by `-D warnings`
|
2023-08-01 14:02:21 +02:00
|
|
|
= help: to override `-D warnings` add `#[allow(clippy::manual_unwrap_or)]`
|
2020-10-23 22:16:59 +02:00
|
|
|
|
|
|
|
|
error: this pattern reimplements `Option::unwrap_or`
|
2025-02-11 17:57:08 +01:00
|
|
|
--> tests/ui/manual_unwrap_or.rs:18:5
|
2020-10-23 22:16:59 +02:00
|
|
|
|
|
|
|
|
|
LL | / match Some(1) {
|
2025-02-11 17:57:08 +01:00
|
|
|
LL | |
|
2020-10-23 22:16:59 +02:00
|
|
|
LL | | None => 42,
|
|
|
|
|
LL | | Some(i) => i,
|
|
|
|
|
LL | | };
|
|
|
|
|
| |_____^ help: replace with: `Some(1).unwrap_or(42)`
|
|
|
|
|
|
|
|
|
|
error: this pattern reimplements `Option::unwrap_or`
|
2025-02-11 17:57:08 +01:00
|
|
|
--> tests/ui/manual_unwrap_or.rs:25:5
|
2020-10-23 22:16:59 +02:00
|
|
|
|
|
|
|
|
|
LL | / match Some(1) {
|
2025-02-11 17:57:08 +01:00
|
|
|
LL | |
|
2020-10-23 22:16:59 +02:00
|
|
|
LL | | Some(i) => i,
|
|
|
|
|
LL | | None => 1 + 42,
|
|
|
|
|
LL | | };
|
|
|
|
|
| |_____^ help: replace with: `Some(1).unwrap_or(1 + 42)`
|
|
|
|
|
|
|
|
|
|
error: this pattern reimplements `Option::unwrap_or`
|
2025-02-11 17:57:08 +01:00
|
|
|
--> tests/ui/manual_unwrap_or.rs:33:5
|
2020-10-23 22:16:59 +02:00
|
|
|
|
|
|
|
|
|
LL | / match Some(1) {
|
2025-02-11 17:57:08 +01:00
|
|
|
LL | |
|
2020-10-23 22:16:59 +02:00
|
|
|
LL | | Some(i) => i,
|
|
|
|
|
LL | | None => {
|
|
|
|
|
... |
|
|
|
|
|
LL | | };
|
|
|
|
|
| |_____^
|
|
|
|
|
|
|
|
|
|
|
help: replace with
|
|
|
|
|
|
|
2021-08-11 14:21:33 +00:00
|
|
|
LL ~ Some(1).unwrap_or({
|
|
|
|
|
LL + 42 + 42
|
|
|
|
|
LL + + 42 + 42 + 42
|
|
|
|
|
LL + + 42 + 42 + 42
|
|
|
|
|
LL ~ });
|
2020-10-23 22:16:59 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
error: this pattern reimplements `Option::unwrap_or`
|
2025-02-11 17:57:08 +01:00
|
|
|
--> tests/ui/manual_unwrap_or.rs:44:5
|
2020-10-23 22:16:59 +02:00
|
|
|
|
|
|
|
|
|
LL | / match Some("Bob") {
|
2025-02-11 17:57:08 +01:00
|
|
|
LL | |
|
2020-10-23 22:16:59 +02:00
|
|
|
LL | | Some(i) => i,
|
|
|
|
|
LL | | None => "Alice",
|
|
|
|
|
LL | | };
|
|
|
|
|
| |_____^ help: replace with: `Some("Bob").unwrap_or("Alice")`
|
|
|
|
|
|
2024-06-27 18:56:04 +02:00
|
|
|
error: this pattern reimplements `Option::unwrap_or`
|
2025-02-11 17:57:08 +01:00
|
|
|
--> tests/ui/manual_unwrap_or.rs:92:5
|
2024-06-27 18:56:04 +02:00
|
|
|
|
|
|
|
|
|
LL | / if let Some(x) = Some(1) {
|
2025-02-11 17:57:08 +01:00
|
|
|
LL | |
|
2024-06-27 18:56:04 +02:00
|
|
|
LL | | x
|
|
|
|
|
LL | | } else {
|
|
|
|
|
LL | | 42
|
|
|
|
|
LL | | };
|
|
|
|
|
| |_____^ help: replace with: `Some(1).unwrap_or(42)`
|
|
|
|
|
|
2020-10-28 23:36:07 +01:00
|
|
|
error: this pattern reimplements `Result::unwrap_or`
|
2025-02-11 17:57:08 +01:00
|
|
|
--> tests/ui/manual_unwrap_or.rs:126:5
|
2020-10-28 23:36:07 +01:00
|
|
|
|
|
|
|
|
|
LL | / match Ok::<i32, &str>(1) {
|
2025-02-11 17:57:08 +01:00
|
|
|
LL | |
|
2020-10-28 23:36:07 +01:00
|
|
|
LL | | Ok(i) => i,
|
|
|
|
|
LL | | Err(_) => 42,
|
|
|
|
|
LL | | };
|
|
|
|
|
| |_____^ help: replace with: `Ok::<i32, &str>(1).unwrap_or(42)`
|
|
|
|
|
|
|
|
|
|
error: this pattern reimplements `Result::unwrap_or`
|
2025-02-11 17:57:08 +01:00
|
|
|
--> tests/ui/manual_unwrap_or.rs:134:5
|
2020-10-28 23:36:07 +01:00
|
|
|
|
|
|
|
|
|
LL | / match a {
|
2025-02-11 17:57:08 +01:00
|
|
|
LL | |
|
2020-10-28 23:36:07 +01:00
|
|
|
LL | | Ok(i) => i,
|
|
|
|
|
LL | | Err(_) => 42,
|
|
|
|
|
LL | | };
|
|
|
|
|
| |_____^ help: replace with: `a.unwrap_or(42)`
|
|
|
|
|
|
|
|
|
|
error: this pattern reimplements `Result::unwrap_or`
|
2025-02-11 17:57:08 +01:00
|
|
|
--> tests/ui/manual_unwrap_or.rs:141:5
|
2020-10-28 23:36:07 +01:00
|
|
|
|
|
|
|
|
|
LL | / match Ok(1) as Result<i32, &str> {
|
2025-02-11 17:57:08 +01:00
|
|
|
LL | |
|
2020-10-28 23:36:07 +01:00
|
|
|
LL | | Ok(i) => i,
|
|
|
|
|
LL | | Err(_) => 42,
|
|
|
|
|
LL | | };
|
|
|
|
|
| |_____^ help: replace with: `(Ok(1) as Result<i32, &str>).unwrap_or(42)`
|
|
|
|
|
|
|
|
|
|
error: this pattern reimplements `Option::unwrap_or`
|
2025-02-11 17:57:08 +01:00
|
|
|
--> tests/ui/manual_unwrap_or.rs:155:5
|
2020-10-28 23:36:07 +01:00
|
|
|
|
|
|
|
|
|
LL | / match s.method() {
|
2025-02-11 17:57:08 +01:00
|
|
|
LL | |
|
2020-10-28 23:36:07 +01:00
|
|
|
LL | | Some(i) => i,
|
|
|
|
|
LL | | None => 42,
|
|
|
|
|
LL | | };
|
|
|
|
|
| |_____^ help: replace with: `s.method().unwrap_or(42)`
|
|
|
|
|
|
|
|
|
|
error: this pattern reimplements `Result::unwrap_or`
|
2025-02-11 17:57:08 +01:00
|
|
|
--> tests/ui/manual_unwrap_or.rs:162:5
|
2020-10-28 23:36:07 +01:00
|
|
|
|
|
|
|
|
|
LL | / match Ok::<i32, &str>(1) {
|
2025-02-11 17:57:08 +01:00
|
|
|
LL | |
|
2020-10-28 23:36:07 +01:00
|
|
|
LL | | Err(_) => 42,
|
|
|
|
|
LL | | Ok(i) => i,
|
|
|
|
|
LL | | };
|
|
|
|
|
| |_____^ help: replace with: `Ok::<i32, &str>(1).unwrap_or(42)`
|
|
|
|
|
|
|
|
|
|
error: this pattern reimplements `Result::unwrap_or`
|
2025-02-11 17:57:08 +01:00
|
|
|
--> tests/ui/manual_unwrap_or.rs:169:5
|
2020-10-28 23:36:07 +01:00
|
|
|
|
|
|
|
|
|
LL | / match Ok::<i32, &str>(1) {
|
2025-02-11 17:57:08 +01:00
|
|
|
LL | |
|
2020-10-28 23:36:07 +01:00
|
|
|
LL | | Ok(i) => i,
|
|
|
|
|
LL | | Err(_) => 1 + 42,
|
|
|
|
|
LL | | };
|
|
|
|
|
| |_____^ help: replace with: `Ok::<i32, &str>(1).unwrap_or(1 + 42)`
|
|
|
|
|
|
|
|
|
|
error: this pattern reimplements `Result::unwrap_or`
|
2025-02-11 17:57:08 +01:00
|
|
|
--> tests/ui/manual_unwrap_or.rs:177:5
|
2020-10-28 23:36:07 +01:00
|
|
|
|
|
|
|
|
|
LL | / match Ok::<i32, &str>(1) {
|
2025-02-11 17:57:08 +01:00
|
|
|
LL | |
|
2020-10-28 23:36:07 +01:00
|
|
|
LL | | Ok(i) => i,
|
|
|
|
|
LL | | Err(_) => {
|
|
|
|
|
... |
|
|
|
|
|
LL | | };
|
|
|
|
|
| |_____^
|
|
|
|
|
|
|
|
|
|
|
help: replace with
|
|
|
|
|
|
|
2021-08-11 14:21:33 +00:00
|
|
|
LL ~ Ok::<i32, &str>(1).unwrap_or({
|
|
|
|
|
LL + 42 + 42
|
|
|
|
|
LL + + 42 + 42 + 42
|
|
|
|
|
LL + + 42 + 42 + 42
|
|
|
|
|
LL ~ });
|
2020-10-28 23:36:07 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
error: this pattern reimplements `Result::unwrap_or`
|
2025-02-11 17:57:08 +01:00
|
|
|
--> tests/ui/manual_unwrap_or.rs:188:5
|
2020-10-28 23:36:07 +01:00
|
|
|
|
|
|
|
|
|
LL | / match Ok::<&str, &str>("Bob") {
|
2025-02-11 17:57:08 +01:00
|
|
|
LL | |
|
2020-10-28 23:36:07 +01:00
|
|
|
LL | | Ok(i) => i,
|
|
|
|
|
LL | | Err(_) => "Alice",
|
|
|
|
|
LL | | };
|
|
|
|
|
| |_____^ help: replace with: `Ok::<&str, &str>("Bob").unwrap_or("Alice")`
|
|
|
|
|
|
2024-06-27 18:56:04 +02:00
|
|
|
error: this pattern reimplements `Result::unwrap_or`
|
2025-02-11 17:57:08 +01:00
|
|
|
--> tests/ui/manual_unwrap_or.rs:225:5
|
2024-06-27 18:56:04 +02:00
|
|
|
|
|
|
|
|
|
LL | / if let Ok(x) = Ok::<i32, i32>(1) {
|
2025-02-11 17:57:08 +01:00
|
|
|
LL | |
|
2024-06-27 18:56:04 +02:00
|
|
|
LL | | x
|
|
|
|
|
LL | | } else {
|
|
|
|
|
LL | | 42
|
|
|
|
|
LL | | };
|
|
|
|
|
| |_____^ help: replace with: `Ok::<i32, i32>(1).unwrap_or(42)`
|
|
|
|
|
|
2021-04-27 16:55:11 +02:00
|
|
|
error: this pattern reimplements `Option::unwrap_or`
|
2025-02-11 17:57:08 +01:00
|
|
|
--> tests/ui/manual_unwrap_or.rs:280:17
|
2021-04-27 16:55:11 +02:00
|
|
|
|
|
|
|
|
|
LL | let _ = match some_macro!() {
|
|
|
|
|
| _________________^
|
2025-02-11 17:57:08 +01:00
|
|
|
LL | |
|
2021-04-27 16:55:11 +02:00
|
|
|
LL | | Some(val) => val,
|
|
|
|
|
LL | | None => 0,
|
|
|
|
|
LL | | };
|
|
|
|
|
| |_________^ help: replace with: `some_macro!().unwrap_or(0)`
|
|
|
|
|
|
2024-06-27 18:56:04 +02:00
|
|
|
error: aborting due to 16 previous errors
|
2020-10-23 22:16:59 +02:00
|
|
|
|