Skip to content

Commit 66abad9

Browse files
committed
Merge pull request #749 from sanxiyn/skip-arm
Add commas after skipped arms when needed
2 parents bd32589 + 16b348d commit 66abad9

File tree

3 files changed

+17
-2
lines changed

3 files changed

+17
-2
lines changed

src/expr.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -898,8 +898,7 @@ impl Rewrite for ast::Arm {
898898
attr_visitor.last_pos = attrs[0].span.lo;
899899
if attr_visitor.visit_attrs(attrs) {
900900
// Attributes included a skip instruction.
901-
let snippet = context.snippet(mk_sp(attrs[0].span.lo, body.span.hi));
902-
return Some(snippet);
901+
return None;
903902
}
904903
attr_visitor.format_missing(pats[0].span.lo);
905904
attr_visitor.buffer.to_string()

tests/source/match.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,14 @@ fn matches() {
100100
}
101101
}
102102

103+
fn match_skip() {
104+
let _ = match Some(1) {
105+
#[rustfmt_skip]
106+
Some( n ) => n,
107+
None => 1,
108+
};
109+
}
110+
103111
fn issue339() {
104112
match a {
105113
b => {}

tests/target/match.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,14 @@ fn matches() {
115115
}
116116
}
117117

118+
fn match_skip() {
119+
let _ = match Some(1) {
120+
#[rustfmt_skip]
121+
Some( n ) => n,
122+
None => 1,
123+
};
124+
}
125+
118126
fn issue339() {
119127
match a {
120128
b => {}

0 commit comments

Comments
 (0)