2021-01-30 17:06:34 +00:00
|
|
|
error: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let`
|
2024-03-09 17:19:43 +00:00
|
|
|
--> tests/ui/single_match.rs:15:5
|
2018-04-05 19:18:38 +00:00
|
|
|
|
|
2018-12-27 15:57:55 +00:00
|
|
|
LL | / match x {
|
|
|
|
LL | | Some(y) => {
|
|
|
|
LL | | println!("{:?}", y);
|
|
|
|
LL | | },
|
|
|
|
LL | | _ => (),
|
|
|
|
LL | | };
|
2018-12-10 05:27:19 +00:00
|
|
|
| |_____^
|
2018-04-05 19:18:38 +00:00
|
|
|
|
|
2018-08-01 14:30:44 +00:00
|
|
|
= note: `-D clippy::single-match` implied by `-D warnings`
|
2023-08-01 12:02:21 +00:00
|
|
|
= help: to override `-D warnings` add `#[allow(clippy::single_match)]`
|
2023-07-17 08:19:29 +00:00
|
|
|
help: try
|
2018-12-10 05:27:19 +00:00
|
|
|
|
|
2021-08-11 14:21:33 +00:00
|
|
|
LL ~ if let Some(y) = x {
|
|
|
|
LL + println!("{:?}", y);
|
|
|
|
LL ~ };
|
2018-12-10 05:27:19 +00:00
|
|
|
|
|
2018-04-05 19:18:38 +00:00
|
|
|
|
2021-01-30 17:06:34 +00:00
|
|
|
error: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let`
|
2024-03-09 17:19:43 +00:00
|
|
|
--> tests/ui/single_match.rs:23:5
|
2018-12-10 05:27:19 +00:00
|
|
|
|
|
2018-12-27 15:57:55 +00:00
|
|
|
LL | / match x {
|
|
|
|
LL | | // Note the missing block braces.
|
|
|
|
LL | | // We suggest `if let Some(y) = x { .. }` because the macro
|
|
|
|
LL | | // is expanded before we can do anything.
|
|
|
|
LL | | Some(y) => println!("{:?}", y),
|
|
|
|
LL | | _ => (),
|
|
|
|
LL | | }
|
2023-07-17 08:19:29 +00:00
|
|
|
| |_____^ help: try: `if let Some(y) = x { println!("{:?}", y) }`
|
2018-10-27 12:45:02 +00:00
|
|
|
|
2021-01-30 17:06:34 +00:00
|
|
|
error: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let`
|
2024-03-09 17:19:43 +00:00
|
|
|
--> tests/ui/single_match.rs:32:5
|
2018-10-27 12:45:02 +00:00
|
|
|
|
|
2018-12-27 15:57:55 +00:00
|
|
|
LL | / match z {
|
2019-06-01 05:54:47 +00:00
|
|
|
LL | | (2..=3, 7..=9) => dummy(),
|
2018-12-27 15:57:55 +00:00
|
|
|
LL | | _ => {},
|
|
|
|
LL | | };
|
2023-07-17 08:19:29 +00:00
|
|
|
| |_____^ help: try: `if let (2..=3, 7..=9) = z { dummy() }`
|
2018-04-05 19:18:38 +00:00
|
|
|
|
2022-06-30 08:50:09 +00:00
|
|
|
error: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let`
|
2024-03-09 17:19:43 +00:00
|
|
|
--> tests/ui/single_match.rs:61:5
|
2022-06-30 08:50:09 +00:00
|
|
|
|
|
|
|
|
LL | / match x {
|
|
|
|
LL | | Some(y) => dummy(),
|
|
|
|
LL | | None => (),
|
|
|
|
LL | | };
|
2023-07-17 08:19:29 +00:00
|
|
|
| |_____^ help: try: `if let Some(y) = x { dummy() }`
|
2022-06-30 08:50:09 +00:00
|
|
|
|
2021-01-30 17:06:34 +00:00
|
|
|
error: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let`
|
2024-03-09 17:19:43 +00:00
|
|
|
--> tests/ui/single_match.rs:66:5
|
2018-04-05 19:18:38 +00:00
|
|
|
|
|
2018-12-27 15:57:55 +00:00
|
|
|
LL | / match y {
|
|
|
|
LL | | Ok(y) => dummy(),
|
|
|
|
LL | | Err(..) => (),
|
|
|
|
LL | | };
|
2023-07-17 08:19:29 +00:00
|
|
|
| |_____^ help: try: `if let Ok(y) = y { dummy() }`
|
2018-04-05 19:18:38 +00:00
|
|
|
|
2021-01-30 17:06:34 +00:00
|
|
|
error: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let`
|
2024-03-09 17:19:43 +00:00
|
|
|
--> tests/ui/single_match.rs:73:5
|
2018-04-05 19:18:38 +00:00
|
|
|
|
|
2018-12-27 15:57:55 +00:00
|
|
|
LL | / match c {
|
|
|
|
LL | | Cow::Borrowed(..) => dummy(),
|
|
|
|
LL | | Cow::Owned(..) => (),
|
|
|
|
LL | | };
|
2023-07-17 08:19:29 +00:00
|
|
|
| |_____^ help: try: `if let Cow::Borrowed(..) = c { dummy() }`
|
2018-04-05 19:18:38 +00:00
|
|
|
|
2021-01-30 17:06:34 +00:00
|
|
|
error: you seem to be trying to use `match` for an equality check. Consider using `if`
|
2024-03-09 17:19:43 +00:00
|
|
|
--> tests/ui/single_match.rs:94:5
|
2021-01-30 17:06:34 +00:00
|
|
|
|
|
|
|
|
LL | / match x {
|
|
|
|
LL | | "test" => println!(),
|
|
|
|
LL | | _ => (),
|
|
|
|
LL | | }
|
2023-07-17 08:19:29 +00:00
|
|
|
| |_____^ help: try: `if x == "test" { println!() }`
|
2021-01-30 17:06:34 +00:00
|
|
|
|
|
|
|
error: you seem to be trying to use `match` for an equality check. Consider using `if`
|
2024-03-09 17:19:43 +00:00
|
|
|
--> tests/ui/single_match.rs:107:5
|
2021-01-30 17:06:34 +00:00
|
|
|
|
|
|
|
|
LL | / match x {
|
|
|
|
LL | | Foo::A => println!(),
|
|
|
|
LL | | _ => (),
|
|
|
|
LL | | }
|
2023-07-17 08:19:29 +00:00
|
|
|
| |_____^ help: try: `if x == Foo::A { println!() }`
|
2021-01-30 17:06:34 +00:00
|
|
|
|
|
|
|
error: you seem to be trying to use `match` for an equality check. Consider using `if`
|
2024-03-09 17:19:43 +00:00
|
|
|
--> tests/ui/single_match.rs:113:5
|
2021-01-30 17:06:34 +00:00
|
|
|
|
|
|
|
|
LL | / match x {
|
|
|
|
LL | | FOO_C => println!(),
|
|
|
|
LL | | _ => (),
|
|
|
|
LL | | }
|
2023-07-17 08:19:29 +00:00
|
|
|
| |_____^ help: try: `if x == FOO_C { println!() }`
|
2021-01-30 17:06:34 +00:00
|
|
|
|
|
|
|
error: you seem to be trying to use `match` for an equality check. Consider using `if`
|
2024-03-09 17:19:43 +00:00
|
|
|
--> tests/ui/single_match.rs:118:5
|
2021-01-30 17:06:34 +00:00
|
|
|
|
|
|
|
|
LL | / match &&x {
|
|
|
|
LL | | Foo::A => println!(),
|
|
|
|
LL | | _ => (),
|
|
|
|
LL | | }
|
2023-07-17 08:19:29 +00:00
|
|
|
| |_____^ help: try: `if x == Foo::A { println!() }`
|
2021-01-30 17:06:34 +00:00
|
|
|
|
|
|
|
error: you seem to be trying to use `match` for an equality check. Consider using `if`
|
2024-03-09 17:19:43 +00:00
|
|
|
--> tests/ui/single_match.rs:124:5
|
2021-01-30 17:06:34 +00:00
|
|
|
|
|
|
|
|
LL | / match &x {
|
|
|
|
LL | | Foo::A => println!(),
|
|
|
|
LL | | _ => (),
|
|
|
|
LL | | }
|
2023-07-17 08:19:29 +00:00
|
|
|
| |_____^ help: try: `if x == &Foo::A { println!() }`
|
2021-01-30 17:06:34 +00:00
|
|
|
|
|
|
|
error: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let`
|
2024-03-09 17:19:43 +00:00
|
|
|
--> tests/ui/single_match.rs:141:5
|
2021-01-30 17:06:34 +00:00
|
|
|
|
|
|
|
|
LL | / match x {
|
|
|
|
LL | | Bar::A => println!(),
|
|
|
|
LL | | _ => (),
|
|
|
|
LL | | }
|
2023-07-17 08:19:29 +00:00
|
|
|
| |_____^ help: try: `if let Bar::A = x { println!() }`
|
2021-01-30 17:06:34 +00:00
|
|
|
|
2021-04-22 09:31:13 +00:00
|
|
|
error: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let`
|
2024-03-09 17:19:43 +00:00
|
|
|
--> tests/ui/single_match.rs:149:5
|
2021-04-22 09:31:13 +00:00
|
|
|
|
|
|
|
|
LL | / match x {
|
|
|
|
LL | | None => println!(),
|
|
|
|
LL | | _ => (),
|
|
|
|
LL | | };
|
2023-07-17 08:19:29 +00:00
|
|
|
| |_____^ help: try: `if let None = x { println!() }`
|
2021-04-22 09:31:13 +00:00
|
|
|
|
2022-02-10 17:40:06 +00:00
|
|
|
error: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let`
|
2024-03-09 17:19:43 +00:00
|
|
|
--> tests/ui/single_match.rs:171:5
|
2022-02-10 17:40:06 +00:00
|
|
|
|
|
|
|
|
LL | / match x {
|
|
|
|
LL | | (Some(_), _) => {},
|
|
|
|
LL | | (None, _) => {},
|
|
|
|
LL | | }
|
2023-07-17 08:19:29 +00:00
|
|
|
| |_____^ help: try: `if let (Some(_), _) = x {}`
|
2022-02-10 17:40:06 +00:00
|
|
|
|
|
|
|
error: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let`
|
2024-03-09 17:19:43 +00:00
|
|
|
--> tests/ui/single_match.rs:177:5
|
2022-02-10 17:40:06 +00:00
|
|
|
|
|
|
|
|
LL | / match x {
|
|
|
|
LL | | (Some(E::V), _) => todo!(),
|
|
|
|
LL | | (_, _) => {},
|
|
|
|
LL | | }
|
2023-07-17 08:19:29 +00:00
|
|
|
| |_____^ help: try: `if let (Some(E::V), _) = x { todo!() }`
|
2022-02-10 17:40:06 +00:00
|
|
|
|
|
|
|
error: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let`
|
2024-03-09 17:19:43 +00:00
|
|
|
--> tests/ui/single_match.rs:183:5
|
2022-02-10 17:40:06 +00:00
|
|
|
|
|
|
|
|
LL | / match (Some(42), Some(E::V), Some(42)) {
|
|
|
|
LL | | (.., Some(E::V), _) => {},
|
|
|
|
LL | | (..) => {},
|
|
|
|
LL | | }
|
2023-07-17 08:19:29 +00:00
|
|
|
| |_____^ help: try: `if let (.., Some(E::V), _) = (Some(42), Some(E::V), Some(42)) {}`
|
2022-02-10 17:40:06 +00:00
|
|
|
|
2023-06-02 09:41:57 +00:00
|
|
|
error: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let`
|
2024-03-09 17:19:43 +00:00
|
|
|
--> tests/ui/single_match.rs:255:5
|
2023-06-02 09:41:57 +00:00
|
|
|
|
|
|
|
|
LL | / match bar {
|
|
|
|
LL | | Some(v) => unsafe {
|
|
|
|
LL | | let r = &v as *const i32;
|
|
|
|
LL | | println!("{}", *r);
|
|
|
|
LL | | },
|
|
|
|
LL | | _ => {},
|
|
|
|
LL | | }
|
|
|
|
| |_____^
|
|
|
|
|
|
2023-07-17 08:19:29 +00:00
|
|
|
help: try
|
2023-06-02 09:41:57 +00:00
|
|
|
|
|
|
|
|
LL ~ if let Some(v) = bar { unsafe {
|
|
|
|
LL + let r = &v as *const i32;
|
|
|
|
LL + println!("{}", *r);
|
|
|
|
LL + } }
|
|
|
|
|
|
|
|
|
|
|
|
|
error: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let`
|
2024-03-09 17:19:43 +00:00
|
|
|
--> tests/ui/single_match.rs:263:5
|
2023-06-02 09:41:57 +00:00
|
|
|
|
|
|
|
|
LL | / match bar {
|
|
|
|
LL | | #[rustfmt::skip]
|
|
|
|
LL | | Some(v) => {
|
|
|
|
LL | | unsafe {
|
|
|
|
... |
|
|
|
|
LL | | _ => {},
|
|
|
|
LL | | }
|
|
|
|
| |_____^
|
|
|
|
|
|
2023-07-17 08:19:29 +00:00
|
|
|
help: try
|
2023-06-02 09:41:57 +00:00
|
|
|
|
|
|
|
|
LL ~ if let Some(v) = bar {
|
|
|
|
LL + unsafe {
|
|
|
|
LL + let r = &v as *const i32;
|
|
|
|
LL + println!("{}", *r);
|
|
|
|
LL + }
|
|
|
|
LL + }
|
|
|
|
|
|
|
|
|
|
2023-08-31 05:24:49 +00:00
|
|
|
error: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let`
|
|
|
|
--> tests/ui/single_match.rs:343:5
|
|
|
|
|
|
|
|
|
LL | / match Ok::<_, u32>(Some(A)) {
|
|
|
|
LL | | Ok(Some(A)) => println!(),
|
|
|
|
LL | | Err(_) | Ok(None | Some(_)) => {},
|
|
|
|
LL | | }
|
|
|
|
| |_____^ help: try: `if let Ok(Some(A)) = Ok::<_, u32>(Some(A)) { println!() }`
|
|
|
|
|
|
|
|
error: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let`
|
|
|
|
--> tests/ui/single_match.rs:358:5
|
|
|
|
|
|
|
|
|
LL | / match &Some(A) {
|
|
|
|
LL | | Some(A | B) => println!(),
|
|
|
|
LL | | None | Some(_) => {},
|
|
|
|
LL | | }
|
|
|
|
| |_____^ help: try: `if let Some(A | B) = &Some(A) { println!() }`
|
|
|
|
|
2024-08-30 21:02:07 +00:00
|
|
|
error: this pattern is irrefutable, `match` is useless
|
|
|
|
--> tests/ui/single_match.rs:371:5
|
|
|
|
|
|
|
|
|
LL | / match DATA {
|
|
|
|
LL | | DATA => println!(),
|
|
|
|
LL | | _ => {},
|
|
|
|
LL | | }
|
2024-09-06 15:10:42 +00:00
|
|
|
| |_____^ help: try: `println!();`
|
2024-08-30 21:02:07 +00:00
|
|
|
|
|
|
|
error: this pattern is irrefutable, `match` is useless
|
|
|
|
--> tests/ui/single_match.rs:376:5
|
|
|
|
|
|
|
|
|
LL | / match CONST_I32 {
|
|
|
|
LL | | CONST_I32 => println!(),
|
|
|
|
LL | | _ => {},
|
|
|
|
LL | | }
|
2024-09-06 15:10:42 +00:00
|
|
|
| |_____^ help: try: `println!();`
|
2024-08-30 21:02:07 +00:00
|
|
|
|
|
|
|
error: this pattern is irrefutable, `match` is useless
|
|
|
|
--> tests/ui/single_match.rs:382:5
|
|
|
|
|
|
|
|
|
LL | / match i {
|
|
|
|
LL | | i => {
|
|
|
|
LL | | let a = 1;
|
|
|
|
LL | | let b = 2;
|
|
|
|
LL | | },
|
|
|
|
LL | | _ => {},
|
|
|
|
LL | | }
|
|
|
|
| |_____^
|
|
|
|
|
|
|
|
|
help: try
|
|
|
|
|
|
|
|
|
LL ~ {
|
|
|
|
LL + let a = 1;
|
|
|
|
LL + let b = 2;
|
|
|
|
LL + }
|
|
|
|
|
|
|
|
|
|
2024-09-06 15:10:42 +00:00
|
|
|
error: this pattern is irrefutable, `match` is useless
|
|
|
|
--> tests/ui/single_match.rs:390:5
|
|
|
|
|
|
|
|
|
LL | / match i {
|
|
|
|
LL | | i => {},
|
|
|
|
LL | | _ => {},
|
|
|
|
LL | | }
|
|
|
|
| |_____^ help: `match` expression can be removed
|
|
|
|
|
|
|
|
error: this pattern is irrefutable, `match` is useless
|
|
|
|
--> tests/ui/single_match.rs:395:5
|
|
|
|
|
|
|
|
|
LL | / match i {
|
|
|
|
LL | | i => (),
|
|
|
|
LL | | _ => (),
|
|
|
|
LL | | }
|
|
|
|
| |_____^ help: `match` expression can be removed
|
|
|
|
|
|
|
|
error: this pattern is irrefutable, `match` is useless
|
|
|
|
--> tests/ui/single_match.rs:400:5
|
|
|
|
|
|
|
|
|
LL | / match CONST_I32 {
|
|
|
|
LL | | CONST_I32 => println!(),
|
|
|
|
LL | | _ => {},
|
|
|
|
LL | | }
|
|
|
|
| |_____^ help: try: `println!()`
|
|
|
|
|
|
|
|
error: aborting due to 26 previous errors
|
2018-04-05 19:18:38 +00:00
|
|
|
|