2020-01-15 00:56:56 -06:00
|
|
|
error: this match could be written as a `let` statement
|
2024-02-27 08:25:18 -06:00
|
|
|
--> tests/ui/match_single_binding.rs:33:5
|
2020-01-15 00:56:56 -06:00
|
|
|
|
|
|
|
|
LL | / match (a, b, c) {
|
|
|
|
LL | | (x, y, z) => {
|
|
|
|
LL | | println!("{} {} {}", x, y, z);
|
|
|
|
LL | | },
|
|
|
|
LL | | }
|
2020-01-19 04:07:13 -06:00
|
|
|
| |_____^
|
2020-01-15 00:56:56 -06:00
|
|
|
|
|
|
|
|
= note: `-D clippy::match-single-binding` implied by `-D warnings`
|
2023-08-01 07:02:21 -05:00
|
|
|
= help: to override `-D warnings` add `#[allow(clippy::match_single_binding)]`
|
2022-05-21 06:24:00 -05:00
|
|
|
help: consider using a `let` statement
|
2020-01-19 04:07:13 -06:00
|
|
|
|
|
2021-08-11 09:21:33 -05:00
|
|
|
LL ~ let (x, y, z) = (a, b, c);
|
|
|
|
LL + {
|
|
|
|
LL + println!("{} {} {}", x, y, z);
|
|
|
|
LL + }
|
2020-01-19 04:07:13 -06:00
|
|
|
|
|
2020-01-15 00:56:56 -06:00
|
|
|
|
2020-01-26 10:03:39 -06:00
|
|
|
error: this match could be written as a `let` statement
|
2024-02-27 08:25:18 -06:00
|
|
|
--> tests/ui/match_single_binding.rs:39:5
|
2020-01-26 10:03:39 -06:00
|
|
|
|
|
|
|
|
LL | / match (a, b, c) {
|
|
|
|
LL | | (x, y, z) => println!("{} {} {}", x, y, z),
|
|
|
|
LL | | }
|
|
|
|
| |_____^
|
|
|
|
|
|
2022-05-21 06:24:00 -05:00
|
|
|
help: consider using a `let` statement
|
2020-01-26 10:03:39 -06:00
|
|
|
|
|
2021-08-11 09:21:33 -05:00
|
|
|
LL ~ let (x, y, z) = (a, b, c);
|
|
|
|
LL + println!("{} {} {}", x, y, z);
|
2020-01-26 10:03:39 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
error: this match could be replaced by its body itself
|
2024-02-27 08:25:18 -06:00
|
|
|
--> tests/ui/match_single_binding.rs:56:5
|
2020-01-26 10:03:39 -06:00
|
|
|
|
|
|
|
|
LL | / match a {
|
|
|
|
LL | | _ => println!("whatever"),
|
|
|
|
LL | | }
|
|
|
|
| |_____^ help: consider using the match body instead: `println!("whatever");`
|
|
|
|
|
|
|
|
error: this match could be replaced by its body itself
|
2024-02-27 08:25:18 -06:00
|
|
|
--> tests/ui/match_single_binding.rs:60:5
|
2020-01-26 10:03:39 -06:00
|
|
|
|
|
|
|
|
LL | / match a {
|
|
|
|
LL | | _ => {
|
|
|
|
LL | | let x = 29;
|
|
|
|
LL | | println!("x has a value of {}", x);
|
|
|
|
LL | | },
|
|
|
|
LL | | }
|
|
|
|
| |_____^
|
|
|
|
|
|
|
|
|
help: consider using the match body instead
|
|
|
|
|
|
2021-08-11 09:21:33 -05:00
|
|
|
LL ~ {
|
|
|
|
LL + let x = 29;
|
|
|
|
LL + println!("x has a value of {}", x);
|
|
|
|
LL + }
|
2020-01-26 10:03:39 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
error: this match could be replaced by its body itself
|
2024-02-27 08:25:18 -06:00
|
|
|
--> tests/ui/match_single_binding.rs:67:5
|
2020-01-26 10:03:39 -06:00
|
|
|
|
|
|
|
|
LL | / match a {
|
|
|
|
LL | | _ => {
|
|
|
|
LL | | let e = 5 * a;
|
|
|
|
LL | | if e >= 5 {
|
|
|
|
... |
|
|
|
|
LL | | },
|
|
|
|
LL | | }
|
|
|
|
| |_____^
|
|
|
|
|
|
|
|
|
help: consider using the match body instead
|
|
|
|
|
|
2021-08-11 09:21:33 -05:00
|
|
|
LL ~ {
|
|
|
|
LL + let e = 5 * a;
|
|
|
|
LL + if e >= 5 {
|
|
|
|
LL + println!("e is superior to 5");
|
|
|
|
LL + }
|
|
|
|
LL + }
|
2020-01-26 10:03:39 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
error: this match could be written as a `let` statement
|
2024-02-27 08:25:18 -06:00
|
|
|
--> tests/ui/match_single_binding.rs:77:5
|
2020-01-26 10:03:39 -06:00
|
|
|
|
|
|
|
|
LL | / match p {
|
|
|
|
LL | | Point { x, y } => println!("Coords: ({}, {})", x, y),
|
|
|
|
LL | | }
|
|
|
|
| |_____^
|
|
|
|
|
|
2022-05-21 06:24:00 -05:00
|
|
|
help: consider using a `let` statement
|
2020-01-26 10:03:39 -06:00
|
|
|
|
|
2021-08-11 09:21:33 -05:00
|
|
|
LL ~ let Point { x, y } = p;
|
|
|
|
LL + println!("Coords: ({}, {})", x, y);
|
2020-01-26 10:03:39 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
error: this match could be written as a `let` statement
|
2024-02-27 08:25:18 -06:00
|
|
|
--> tests/ui/match_single_binding.rs:81:5
|
2020-01-26 10:03:39 -06:00
|
|
|
|
|
|
|
|
LL | / match p {
|
|
|
|
LL | | Point { x: x1, y: y1 } => println!("Coords: ({}, {})", x1, y1),
|
|
|
|
LL | | }
|
|
|
|
| |_____^
|
|
|
|
|
|
2022-05-21 06:24:00 -05:00
|
|
|
help: consider using a `let` statement
|
2020-01-26 10:03:39 -06:00
|
|
|
|
|
2021-08-11 09:21:33 -05:00
|
|
|
LL ~ let Point { x: x1, y: y1 } = p;
|
|
|
|
LL + println!("Coords: ({}, {})", x1, y1);
|
2020-01-26 10:03:39 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
error: this match could be written as a `let` statement
|
2024-02-27 08:25:18 -06:00
|
|
|
--> tests/ui/match_single_binding.rs:86:5
|
2020-01-26 10:03:39 -06:00
|
|
|
|
|
|
|
|
LL | / match x {
|
|
|
|
LL | | ref r => println!("Got a reference to {}", r),
|
|
|
|
LL | | }
|
|
|
|
| |_____^
|
|
|
|
|
|
2022-05-21 06:24:00 -05:00
|
|
|
help: consider using a `let` statement
|
2020-01-26 10:03:39 -06:00
|
|
|
|
|
2021-08-11 09:21:33 -05:00
|
|
|
LL ~ let ref r = x;
|
|
|
|
LL + println!("Got a reference to {}", r);
|
2020-01-26 10:03:39 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
error: this match could be written as a `let` statement
|
2024-02-27 08:25:18 -06:00
|
|
|
--> tests/ui/match_single_binding.rs:91:5
|
2020-01-26 10:03:39 -06:00
|
|
|
|
|
|
|
|
LL | / match x {
|
|
|
|
LL | | ref mut mr => println!("Got a mutable reference to {}", mr),
|
|
|
|
LL | | }
|
|
|
|
| |_____^
|
|
|
|
|
|
2022-05-21 06:24:00 -05:00
|
|
|
help: consider using a `let` statement
|
2020-01-26 10:03:39 -06:00
|
|
|
|
|
2021-08-11 09:21:33 -05:00
|
|
|
LL ~ let ref mut mr = x;
|
|
|
|
LL + println!("Got a mutable reference to {}", mr);
|
2020-01-26 10:03:39 -06:00
|
|
|
|
|
|
|
|
|
2020-03-08 16:57:35 -05:00
|
|
|
error: this match could be written as a `let` statement
|
2024-02-27 08:25:18 -06:00
|
|
|
--> tests/ui/match_single_binding.rs:95:5
|
2020-03-08 16:57:35 -05:00
|
|
|
|
|
|
|
|
LL | / let product = match coords() {
|
|
|
|
LL | | Point { x, y } => x * y,
|
|
|
|
LL | | };
|
|
|
|
| |______^
|
|
|
|
|
|
2022-05-21 06:24:00 -05:00
|
|
|
help: consider using a `let` statement
|
2020-03-08 16:57:35 -05:00
|
|
|
|
|
2021-08-11 09:21:33 -05:00
|
|
|
LL ~ let Point { x, y } = coords();
|
|
|
|
LL + let product = x * y;
|
2020-03-08 16:57:35 -05:00
|
|
|
|
|
|
|
|
|
2020-03-21 14:26:55 -05:00
|
|
|
error: this match could be written as a `let` statement
|
2024-02-27 08:25:18 -06:00
|
|
|
--> tests/ui/match_single_binding.rs:103:18
|
2020-03-21 14:26:55 -05:00
|
|
|
|
|
|
|
|
LL | .map(|i| match i.unwrap() {
|
|
|
|
| __________________^
|
|
|
|
LL | | unwrapped => unwrapped,
|
|
|
|
LL | | })
|
|
|
|
| |_________^
|
|
|
|
|
|
2022-05-21 06:24:00 -05:00
|
|
|
help: consider using a `let` statement
|
2020-03-21 14:26:55 -05:00
|
|
|
|
|
2021-08-11 09:21:33 -05:00
|
|
|
LL ~ .map(|i| {
|
|
|
|
LL + let unwrapped = i.unwrap();
|
|
|
|
LL + unwrapped
|
|
|
|
LL ~ })
|
2020-03-21 14:26:55 -05:00
|
|
|
|
|
|
|
|
|
2022-02-26 07:26:21 -06:00
|
|
|
error: this match could be replaced by its body itself
|
2024-02-27 08:25:18 -06:00
|
|
|
--> tests/ui/match_single_binding.rs:129:5
|
2022-02-26 07:26:21 -06:00
|
|
|
|
|
|
|
|
LL | / match x {
|
|
|
|
LL | | // =>
|
|
|
|
LL | | _ => println!("Not an array index start"),
|
|
|
|
LL | | }
|
2023-03-24 08:04:35 -05:00
|
|
|
| |_____^ help: consider using the match body instead: `println!("Not an array index start")`
|
2022-02-26 07:26:21 -06:00
|
|
|
|
2022-05-21 06:24:00 -05:00
|
|
|
error: this assignment could be simplified
|
2024-02-27 08:25:18 -06:00
|
|
|
--> tests/ui/match_single_binding.rs:138:5
|
2022-05-21 06:24:00 -05:00
|
|
|
|
|
|
|
|
LL | / val = match val.split_at(idx) {
|
|
|
|
LL | | (pre, suf) => {
|
|
|
|
LL | | println!("{}", pre);
|
|
|
|
LL | | suf
|
|
|
|
LL | | },
|
|
|
|
LL | | };
|
|
|
|
| |_____^
|
|
|
|
|
|
|
|
|
help: consider removing the `match` expression
|
|
|
|
|
|
|
|
|
LL ~ let (pre, suf) = val.split_at(idx);
|
|
|
|
LL + val = {
|
|
|
|
LL + println!("{}", pre);
|
|
|
|
LL + suf
|
|
|
|
LL ~ };
|
|
|
|
|
|
|
|
|
|
2022-10-23 08:18:45 -05:00
|
|
|
error: this match could be replaced by its scrutinee and body
|
2024-02-27 08:25:18 -06:00
|
|
|
--> tests/ui/match_single_binding.rs:151:16
|
2022-10-23 08:18:45 -05:00
|
|
|
|
|
|
|
|
LL | let _ = || match side_effects() {
|
|
|
|
| ________________^
|
|
|
|
LL | | _ => println!("Needs curlies"),
|
|
|
|
LL | | };
|
|
|
|
| |_____^
|
|
|
|
|
|
|
|
|
help: consider using the scrutinee and body instead
|
|
|
|
|
|
|
|
|
LL ~ let _ = || {
|
|
|
|
LL + side_effects();
|
2023-03-24 08:04:35 -05:00
|
|
|
LL + println!("Needs curlies")
|
2022-10-23 08:18:45 -05:00
|
|
|
LL ~ };
|
|
|
|
|
|
|
|
|
|
2022-12-29 07:28:34 -06:00
|
|
|
error: this match could be written as a `let` statement
|
2024-02-27 08:25:18 -06:00
|
|
|
--> tests/ui/match_single_binding.rs:157:5
|
2022-12-29 07:28:34 -06:00
|
|
|
|
|
|
|
|
LL | / match r {
|
|
|
|
LL | | x => match x {
|
|
|
|
LL | | Some(_) => {
|
|
|
|
LL | | println!("Some");
|
|
|
|
... |
|
|
|
|
LL | | },
|
|
|
|
LL | | };
|
|
|
|
| |_____^
|
|
|
|
|
|
|
|
|
help: consider using a `let` statement
|
|
|
|
|
|
|
|
|
LL ~ let x = r;
|
|
|
|
LL + match x {
|
|
|
|
LL + Some(_) => {
|
|
|
|
LL + println!("Some");
|
|
|
|
LL + },
|
|
|
|
LL + None => {
|
|
|
|
LL + println!("None");
|
|
|
|
LL + },
|
|
|
|
LL ~ };
|
|
|
|
|
|
|
|
|
|
2023-03-24 08:04:35 -05:00
|
|
|
error: this match could be replaced by its body itself
|
2024-02-27 08:25:18 -06:00
|
|
|
--> tests/ui/match_single_binding.rs:170:5
|
2023-03-24 08:04:35 -05:00
|
|
|
|
|
|
|
|
LL | / match 1 {
|
|
|
|
LL | | _ => (),
|
|
|
|
LL | | }
|
|
|
|
| |_____^ help: consider using the match body instead: `();`
|
|
|
|
|
|
|
|
error: this match could be replaced by its body itself
|
2024-02-27 08:25:18 -06:00
|
|
|
--> tests/ui/match_single_binding.rs:174:13
|
2023-03-24 08:04:35 -05:00
|
|
|
|
|
|
|
|
LL | let a = match 1 {
|
|
|
|
| _____________^
|
|
|
|
LL | | _ => (),
|
|
|
|
LL | | };
|
|
|
|
| |_____^ help: consider using the match body instead: `()`
|
|
|
|
|
|
|
|
error: this match could be replaced by its body itself
|
2024-02-27 08:25:18 -06:00
|
|
|
--> tests/ui/match_single_binding.rs:178:5
|
2023-03-24 08:04:35 -05:00
|
|
|
|
|
|
|
|
LL | / match 1 {
|
|
|
|
LL | | _ => side_effects(),
|
|
|
|
LL | | }
|
|
|
|
| |_____^ help: consider using the match body instead: `side_effects();`
|
|
|
|
|
|
|
|
error: this match could be replaced by its body itself
|
2024-02-27 08:25:18 -06:00
|
|
|
--> tests/ui/match_single_binding.rs:182:13
|
2023-03-24 08:04:35 -05:00
|
|
|
|
|
|
|
|
LL | let b = match 1 {
|
|
|
|
| _____________^
|
|
|
|
LL | | _ => side_effects(),
|
|
|
|
LL | | };
|
|
|
|
| |_____^ help: consider using the match body instead: `side_effects()`
|
|
|
|
|
|
|
|
error: this match could be replaced by its body itself
|
2024-02-27 08:25:18 -06:00
|
|
|
--> tests/ui/match_single_binding.rs:186:5
|
2023-03-24 08:04:35 -05:00
|
|
|
|
|
|
|
|
LL | / match 1 {
|
|
|
|
LL | | _ => println!("1"),
|
|
|
|
LL | | }
|
|
|
|
| |_____^ help: consider using the match body instead: `println!("1");`
|
|
|
|
|
|
|
|
error: this match could be replaced by its body itself
|
2024-02-27 08:25:18 -06:00
|
|
|
--> tests/ui/match_single_binding.rs:190:13
|
2023-03-24 08:04:35 -05:00
|
|
|
|
|
|
|
|
LL | let c = match 1 {
|
|
|
|
| _____________^
|
|
|
|
LL | | _ => println!("1"),
|
|
|
|
LL | | };
|
|
|
|
| |_____^ help: consider using the match body instead: `println!("1")`
|
|
|
|
|
|
|
|
error: this match could be replaced by its body itself
|
2024-02-27 08:25:18 -06:00
|
|
|
--> tests/ui/match_single_binding.rs:195:9
|
2023-03-24 08:04:35 -05:00
|
|
|
|
|
|
|
|
LL | / match 1 {
|
|
|
|
LL | | _ => (),
|
|
|
|
LL | | },
|
|
|
|
| |_________^ help: consider using the match body instead: `()`
|
|
|
|
|
|
|
|
error: this match could be replaced by its body itself
|
2024-02-27 08:25:18 -06:00
|
|
|
--> tests/ui/match_single_binding.rs:198:9
|
2023-03-24 08:04:35 -05:00
|
|
|
|
|
|
|
|
LL | / match 1 {
|
|
|
|
LL | | _ => side_effects(),
|
|
|
|
LL | | },
|
|
|
|
| |_________^ help: consider using the match body instead: `side_effects()`
|
|
|
|
|
|
|
|
error: this match could be replaced by its body itself
|
2024-02-27 08:25:18 -06:00
|
|
|
--> tests/ui/match_single_binding.rs:201:9
|
2023-03-24 08:04:35 -05:00
|
|
|
|
|
|
|
|
LL | / match 1 {
|
|
|
|
LL | | _ => println!("1"),
|
|
|
|
LL | | },
|
|
|
|
| |_________^ help: consider using the match body instead: `println!("1")`
|
|
|
|
|
|
|
|
error: aborting due to 24 previous errors
|
2020-01-15 00:56:56 -06:00
|
|
|
|