Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 3b7a518

Browse files
rchaser53topecongiro
authored andcommitted
fix underscore in slice patterns are removed (rust-lang#3719)
1 parent aeb3496 commit 3b7a518

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/patterns.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ impl Rewrite for Pat {
133133
.iter()
134134
.map(|p| {
135135
if let Some(rw) = p.rewrite(context, shape) {
136-
format!("{}", if rw == "_" { "" } else { &rw })
136+
rw
137137
} else {
138138
format!("{}", context.snippet(p.span))
139139
}

tests/target/issue-3718.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
fn main() {
2+
let x: &[i32] = &[2, 2];
3+
match x {
4+
[_a, _] => println!("Wrong username or password"),
5+
_ => println!("Logged in"),
6+
}
7+
}

0 commit comments

Comments
 (0)