rust-clippy/tests/ui/single_match.stderr

202 lines
6.1 KiB
Text
Raw Normal View History

error: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let`
2023-06-10 11:43:30 +00:00
--> $DIR/single_match.rs:14:5
|
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
| |_____^
|
= note: `-D clippy::single-match` implied by `-D warnings`
2018-12-10 05:27:19 +00:00
help: try this
|
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
|
error: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let`
2023-06-10 11:43:30 +00:00
--> $DIR/single_match.rs:22: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 | | }
| |_____^ help: try this: `if let Some(y) = x { println!("{:?}", y) }`
error: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let`
2023-06-10 11:43:30 +00:00
--> $DIR/single_match.rs:31:5
|
2018-12-27 15:57:55 +00:00
LL | / match z {
LL | | (2..=3, 7..=9) => dummy(),
2018-12-27 15:57:55 +00:00
LL | | _ => {},
LL | | };
| |_____^ help: try this: `if let (2..=3, 7..=9) = z { dummy() }`
error: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let`
2023-06-10 11:43:30 +00:00
--> $DIR/single_match.rs:60:5
|
LL | / match x {
LL | | Some(y) => dummy(),
LL | | None => (),
LL | | };
| |_____^ help: try this: `if let Some(y) = x { dummy() }`
error: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let`
2023-06-10 11:43:30 +00:00
--> $DIR/single_match.rs:65:5
|
2018-12-27 15:57:55 +00:00
LL | / match y {
LL | | Ok(y) => dummy(),
LL | | Err(..) => (),
LL | | };
| |_____^ help: try this: `if let Ok(y) = y { dummy() }`
error: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let`
2023-06-10 11:43:30 +00:00
--> $DIR/single_match.rs:72:5
|
2018-12-27 15:57:55 +00:00
LL | / match c {
LL | | Cow::Borrowed(..) => dummy(),
LL | | Cow::Owned(..) => (),
LL | | };
| |_____^ help: try this: `if let Cow::Borrowed(..) = c { dummy() }`
error: you seem to be trying to use `match` for an equality check. Consider using `if`
2023-06-10 11:43:30 +00:00
--> $DIR/single_match.rs:93:5
|
LL | / match x {
LL | | "test" => println!(),
LL | | _ => (),
LL | | }
| |_____^ help: try this: `if x == "test" { println!() }`
error: you seem to be trying to use `match` for an equality check. Consider using `if`
2023-06-10 11:43:30 +00:00
--> $DIR/single_match.rs:106:5
|
LL | / match x {
LL | | Foo::A => println!(),
LL | | _ => (),
LL | | }
| |_____^ help: try this: `if x == Foo::A { println!() }`
error: you seem to be trying to use `match` for an equality check. Consider using `if`
2023-06-10 11:43:30 +00:00
--> $DIR/single_match.rs:112:5
|
LL | / match x {
LL | | FOO_C => println!(),
LL | | _ => (),
LL | | }
| |_____^ help: try this: `if x == FOO_C { println!() }`
error: you seem to be trying to use `match` for an equality check. Consider using `if`
2023-06-10 11:43:30 +00:00
--> $DIR/single_match.rs:117:5
|
LL | / match &&x {
LL | | Foo::A => println!(),
LL | | _ => (),
LL | | }
| |_____^ help: try this: `if x == Foo::A { println!() }`
error: you seem to be trying to use `match` for an equality check. Consider using `if`
2023-06-10 11:43:30 +00:00
--> $DIR/single_match.rs:123:5
|
LL | / match &x {
LL | | Foo::A => println!(),
LL | | _ => (),
LL | | }
| |_____^ help: try this: `if x == &Foo::A { println!() }`
error: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let`
2023-06-10 11:43:30 +00:00
--> $DIR/single_match.rs:140:5
|
LL | / match x {
LL | | Bar::A => println!(),
LL | | _ => (),
LL | | }
| |_____^ help: try this: `if let Bar::A = x { println!() }`
error: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let`
2023-06-10 11:43:30 +00:00
--> $DIR/single_match.rs:148:5
|
LL | / match x {
LL | | None => println!(),
LL | | _ => (),
LL | | };
| |_____^ help: try this: `if let None = x { println!() }`
error: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let`
2023-06-10 11:43:30 +00:00
--> $DIR/single_match.rs:170:5
|
LL | / match x {
LL | | (Some(_), _) => {},
LL | | (None, _) => {},
LL | | }
| |_____^ help: try this: `if let (Some(_), _) = x {}`
error: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let`
2023-06-10 11:43:30 +00:00
--> $DIR/single_match.rs:176:5
|
LL | / match x {
LL | | (Some(E::V), _) => todo!(),
LL | | (_, _) => {},
LL | | }
| |_____^ help: try this: `if let (Some(E::V), _) = x { todo!() }`
error: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let`
2023-06-10 11:43:30 +00:00
--> $DIR/single_match.rs:182:5
|
LL | / match (Some(42), Some(E::V), Some(42)) {
LL | | (.., Some(E::V), _) => {},
LL | | (..) => {},
LL | | }
| |_____^ help: try this: `if let (.., Some(E::V), _) = (Some(42), Some(E::V), Some(42)) {}`
2023-05-22 08:07:17 +00:00
error: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let`
2023-06-10 11:43:30 +00:00
--> $DIR/single_match.rs:254:5
2023-05-22 08:07:17 +00:00
|
LL | / match bar {
LL | | Some(v) => unsafe {
LL | | let r = &v as *const i32;
LL | | println!("{}", *r);
LL | | },
LL | | _ => {},
LL | | }
| |_____^
|
help: try this
|
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`
2023-06-10 11:43:30 +00:00
--> $DIR/single_match.rs:262:5
2023-05-22 08:07:17 +00:00
|
LL | / match bar {
2023-05-23 00:02:45 +00:00
LL | | #[rustfmt::skip]
2023-05-22 08:07:17 +00:00
LL | | Some(v) => {
LL | | unsafe {
... |
LL | | _ => {},
LL | | }
| |_____^
|
help: try this
|
LL ~ if let Some(v) = bar {
LL + unsafe {
LL + let r = &v as *const i32;
LL + println!("{}", *r);
LL + }
LL + }
|
error: aborting due to 18 previous errors