Skip to content

Commit

Permalink
Apply updated matches! formatting to rustfmt
Browse files Browse the repository at this point in the history
Since rustfmt uses version two formatting the self tests were failing
due to the new special case handling for `matches!`. various `matches!`
calls in the codebase were updated to address this issue.
  • Loading branch information
ytmimi committed Oct 1, 2022
1 parent 243c881 commit 5e5c766
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 18 deletions.
6 changes: 3 additions & 3 deletions src/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1882,9 +1882,9 @@ impl<'ast> RhsAssignKind<'ast> {
matches!(
kind,
ast::ExprKind::Try(..)
| ast::ExprKind::Field(..)
| ast::ExprKind::MethodCall(..)
| ast::ExprKind::Await(_)
| ast::ExprKind::Field(..)
| ast::ExprKind::MethodCall(..)
| ast::ExprKind::Await(_)
)
}
_ => false,
Expand Down
5 changes: 1 addition & 4 deletions src/items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3324,10 +3324,7 @@ pub(crate) fn rewrite_extern_crate(

/// Returns `true` for `mod foo;`, false for `mod foo { .. }`.
pub(crate) fn is_mod_decl(item: &ast::Item) -> bool {
!matches!(
item.kind,
ast::ItemKind::Mod(_, ast::ModKind::Loaded(_, ast::Inline::Yes, _))
)
!matches!(item.kind, ast::ItemKind::Mod(_, ast::ModKind::Loaded(_, ast::Inline::Yes, _)))
}

pub(crate) fn is_use_item(item: &ast::Item) -> bool {
Expand Down
12 changes: 3 additions & 9 deletions src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -591,15 +591,12 @@ impl MacroArgKind {
matches!(
*self,
MacroArgKind::Repeat(Delimiter::Brace, _, _, _)
| MacroArgKind::Delimited(Delimiter::Brace, _)
| MacroArgKind::Delimited(Delimiter::Brace, _)
)
}

fn starts_with_dollar(&self) -> bool {
matches!(
*self,
MacroArgKind::Repeat(..) | MacroArgKind::MetaVariable(..)
)
matches!(*self, MacroArgKind::Repeat(..) | MacroArgKind::MetaVariable(..))
}

fn ends_with_space(&self) -> bool {
Expand Down Expand Up @@ -1052,10 +1049,7 @@ fn force_space_before(tok: &TokenKind) -> bool {
}

fn ident_like(tok: &Token) -> bool {
matches!(
tok.kind,
TokenKind::Ident(..) | TokenKind::Literal(..) | TokenKind::Lifetime(_)
)
matches!(tok.kind, TokenKind::Ident(..) | TokenKind::Literal(..) | TokenKind::Lifetime(_))
}

fn next_space(tok: &TokenKind) -> SpaceState {
Expand Down
4 changes: 2 additions & 2 deletions src/overflow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,8 @@ impl<'a> OverflowableItem<'a> {
matches!(
self,
OverflowableItem::Expr(..)
| OverflowableItem::MacroArg(MacroArg::Expr(..))
| OverflowableItem::MatchesMacroItem(MatchesMacroItem::Expr(..))
| OverflowableItem::MacroArg(MacroArg::Expr(..))
| OverflowableItem::MatchesMacroItem(MatchesMacroItem::Expr(..))
)
}

Expand Down

0 comments on commit 5e5c766

Please sign in to comment.