diff --git a/src/patterns.rs b/src/patterns.rs index e7b7f8adbb2..57051a286a7 100644 --- a/src/patterns.rs +++ b/src/patterns.rs @@ -133,7 +133,7 @@ impl Rewrite for Pat { .iter() .map(|p| { if let Some(rw) = p.rewrite(context, shape) { - format!("{}", if rw == "_" { "" } else { &rw }) + rw } else { format!("{}", context.snippet(p.span)) } diff --git a/tests/target/issue-3718.rs b/tests/target/issue-3718.rs new file mode 100644 index 00000000000..8ad21ffc708 --- /dev/null +++ b/tests/target/issue-3718.rs @@ -0,0 +1,7 @@ +fn main() { + let x: &[i32] = &[2, 2]; + match x { + [_a, _] => println!("Wrong username or password"), + _ => println!("Logged in"), + } +}