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

Commit 97d29ff

Browse files
authored
Merge pull request rust-lang#2942 from crw5996/fix-ellipsis-bug
Fix Issue with ellipsis matching in pattern.rs
2 parents d456161 + 4e748a2 commit 97d29ff

File tree

3 files changed

+41
-1
lines changed

3 files changed

+41
-1
lines changed

src/patterns.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,9 @@ fn rewrite_tuple_pat(
369369
shape,
370370
span,
371371
context.config.max_width(),
372-
if add_comma {
372+
if dotdot_pos.is_some() {
373+
Some(SeparatorTactic::Never)
374+
} else if add_comma {
373375
Some(SeparatorTactic::Always)
374376
} else {
375377
None

tests/source/issue-2936.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
struct AStruct {
2+
A: u32,
3+
B: u32,
4+
C: u32,
5+
}
6+
7+
impl Something for AStruct {
8+
fn a_func() {
9+
match a_val {
10+
ContextualParseError::InvalidMediaRule(ref err) => {
11+
let err: &CStr = match err.kind {
12+
ParseErrorKind::Custom(StyleParseErrorKind::MediaQueryExpectedFeatureName(..)) => {
13+
cstr!("PEMQExpectedFeatureName")
14+
},
15+
};
16+
}
17+
};
18+
}
19+
}

tests/target/issue-2936.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
struct AStruct {
2+
A: u32,
3+
B: u32,
4+
C: u32,
5+
}
6+
7+
impl Something for AStruct {
8+
fn a_func() {
9+
match a_val {
10+
ContextualParseError::InvalidMediaRule(ref err) => {
11+
let err: &CStr = match err.kind {
12+
ParseErrorKind::Custom(StyleParseErrorKind::MediaQueryExpectedFeatureName(
13+
..
14+
)) => cstr!("PEMQExpectedFeatureName"),
15+
};
16+
}
17+
};
18+
}
19+
}

0 commit comments

Comments
 (0)