Skip to content

Commit a3a29f5

Browse files
max-niedermanNadrieril
authored andcommitted
cover guard patterns in rustfmt
1 parent 9b8bfed commit a3a29f5

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

Diff for: src/tools/rustfmt/src/patterns.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ fn is_short_pattern_inner(pat: &ast::Pat) -> bool {
4848
| ast::PatKind::MacCall(..)
4949
| ast::PatKind::Slice(..)
5050
| ast::PatKind::Path(..)
51-
| ast::PatKind::Range(..) => false,
51+
| ast::PatKind::Range(..)
52+
| ast::PatKind::Guard(..) => false,
5253
ast::PatKind::Tuple(ref subpats) => subpats.len() <= 1,
5354
ast::PatKind::TupleStruct(_, ref path, ref subpats) => {
5455
path.segments.len() <= 1 && subpats.len() <= 1
@@ -340,6 +341,7 @@ impl Rewrite for Pat {
340341
.map(|inner_pat| format!("({})", inner_pat)),
341342
PatKind::Err(_) => Err(RewriteError::Unknown),
342343
PatKind::Deref(_) => Err(RewriteError::Unknown),
344+
PatKind::Guard(..) => Err(RewriteError::Unknown),
343345
}
344346
}
345347
}

0 commit comments

Comments
 (0)