Support parentheses in patterns
This commit is contained in:
parent
520f0d65ef
commit
3f0b630845
@ -1536,7 +1536,9 @@ fn is_short_pattern_inner(pat: &ast::Pat) -> bool {
|
||||
ast::PatKind::TupleStruct(ref path, ref subpats, _) => {
|
||||
path.segments.len() <= 1 && subpats.len() <= 1
|
||||
}
|
||||
ast::PatKind::Box(ref p) | ast::PatKind::Ref(ref p, _) => is_short_pattern_inner(&*p),
|
||||
ast::PatKind::Box(ref p) | ast::PatKind::Ref(ref p, _) | ast::PatKind::Paren(ref p) => {
|
||||
is_short_pattern_inner(&*p)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -129,6 +129,8 @@ impl Rewrite for Pat {
|
||||
rewrite_struct_pat(path, fields, ellipsis, self.span, context, shape)
|
||||
}
|
||||
PatKind::Mac(ref mac) => rewrite_macro(mac, None, context, shape, MacroPosition::Pat),
|
||||
PatKind::Paren(ref pat) => pat.rewrite(context, shape.offset_left(1)?.sub_width(1)?)
|
||||
.map(|inner_pat| format!("({})", inner_pat)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user