Skip to content

Commit c1c7547

Browse files
authored
Merge pull request #2108 from topecongiro/combine-pat-tuplestruct
Combine ast::PatKind::TupleStruct
2 parents b607508 + 87afdf4 commit c1c7547

File tree

3 files changed

+30
-3
lines changed

3 files changed

+30
-3
lines changed

src/patterns.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -247,9 +247,10 @@ impl<'a> Spanned for TuplePatField<'a> {
247247
pub fn can_be_overflowed_pat(context: &RewriteContext, pat: &TuplePatField, len: usize) -> bool {
248248
match *pat {
249249
TuplePatField::Pat(pat) => match pat.node {
250-
ast::PatKind::Path(..) | ast::PatKind::Tuple(..) | ast::PatKind::Struct(..) => {
251-
context.use_block_indent() && len == 1
252-
}
250+
ast::PatKind::Path(..) |
251+
ast::PatKind::Tuple(..) |
252+
ast::PatKind::Struct(..) |
253+
ast::PatKind::TupleStruct(..) => context.use_block_indent() && len == 1,
253254
ast::PatKind::Ref(ref p, _) | ast::PatKind::Box(ref p) => {
254255
can_be_overflowed_pat(context, &TuplePatField::Pat(p), len)
255256
}

tests/source/pattern.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,18 @@ fn issue_1874() {
4848
y
4949
}
5050
}
51+
52+
fn combine_patterns() {
53+
let x = match y {
54+
Some(
55+
Some(
56+
Foo {
57+
z: Bar(..),
58+
a: Bar(..),
59+
b: Bar(..),
60+
},
61+
),
62+
) => z,
63+
_ => return,
64+
};
65+
}

tests/target/pattern.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,3 +63,14 @@ fn issue_1874() {
6363
y
6464
}
6565
}
66+
67+
fn combine_patterns() {
68+
let x = match y {
69+
Some(Some(Foo {
70+
z: Bar(..),
71+
a: Bar(..),
72+
b: Bar(..),
73+
})) => z,
74+
_ => return,
75+
};
76+
}

0 commit comments

Comments
 (0)