| #![warn(clippy::collapsible_match)] |
| #![allow(clippy::redundant_guards, clippy::single_match)] |
| |
| fn issue16558() { |
| let opt = Some(1); |
| let _ = match opt { |
| Some(s) |
| if s == 1 => { s } |
| //~^ collapsible_match |
| , |
| _ => 1, |
| }; |
| |
| match opt { |
| Some(s) |
| if s == 1 => { |
| //~^ collapsible_match |
| todo!() |
| }, |
| _ => {}, |
| }; |
| |
| let _ = match opt { |
| Some(s) if s > 2 |
| && s == 1 => { s } |
| //~^ collapsible_match |
| , |
| _ => 1, |
| }; |
| } |
| |
| // https://github.com/rust-lang/rust-clippy/issues/16875 |
| // lint still fires when only wildcard-like arms follow (fall-through is harmless) |
| fn issue16875(a: Option<&str>, b: i32) -> i32 { |
| let mut res = 0; |
| match a { |
| Some(_) |
| if b == 0 => { |
| //~^ collapsible_match |
| res = 1; |
| }, |
| _ => {}, |
| } |
| res |
| } |
| |
| #[rustfmt::skip] |
| fn issue16716(n: u32) { |
| match n { |
| 0 | 1 if false => { println!("hello world"); }, |
| //~^ collapsible_match |
| _ => (), |
| } |
| |
| let opt = Some(1); |
| let _ = match opt { |
| Some(s) if s == 1 => { s } |
| //~^ collapsible_match |
| _ => 1, |
| }; |
| } |
| |
| #[rustfmt::skip] |
| fn issue16894() { |
| let a = 5_u8; |
| let b = a; |
| _ = match a { |
| 11 => 0, |
| 13 if a > b => { 1 }, _ => 0, |
| //~^ collapsible_match |
| }; |
| |
| _ = match a { |
| 11 => 0, 12 if a == b => { 1 }, _ => 0, |
| //~^ collapsible_match |
| }; |
| } |