Skip to content

Commit

Permalink
fix underscore in slice patterns are removed (rust-lang#3719)
Browse files Browse the repository at this point in the history
  • Loading branch information
rchaser53 authored and topecongiro committed Jul 31, 2019
1 parent aeb3496 commit 3b7a518
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/patterns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
Expand Down
7 changes: 7 additions & 0 deletions tests/target/issue-3718.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
fn main() {
let x: &[i32] = &[2, 2];
match x {
[_a, _] => println!("Wrong username or password"),
_ => println!("Logged in"),
}
}

0 comments on commit 3b7a518

Please sign in to comment.