Skip to content

Commit

Permalink
cover guard patterns in rustfmt
Browse files Browse the repository at this point in the history
  • Loading branch information
max-niederman committed Oct 30, 2024
1 parent 91b8bed commit 13c00b7
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/tools/rustfmt/src/patterns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ fn is_short_pattern_inner(pat: &ast::Pat) -> bool {
| ast::PatKind::MacCall(..)
| ast::PatKind::Slice(..)
| ast::PatKind::Path(..)
| ast::PatKind::Range(..) => false,
| ast::PatKind::Range(..)
| ast::PatKind::Guard(..) => false,
ast::PatKind::Tuple(ref subpats) => subpats.len() <= 1,
ast::PatKind::TupleStruct(_, ref path, ref subpats) => {
path.segments.len() <= 1 && subpats.len() <= 1
Expand Down Expand Up @@ -340,6 +341,7 @@ impl Rewrite for Pat {
.map(|inner_pat| format!("({})", inner_pat)),
PatKind::Err(_) => Err(RewriteError::Unknown),
PatKind::Deref(_) => Err(RewriteError::Unknown),
PatKind::Guard(..) => Err(RewriteError::Unknown),
}
}
}
Expand Down

0 comments on commit 13c00b7

Please sign in to comment.