From 0c5552d613b45a993f81574c7e6fa8209299cc0b Mon Sep 17 00:00:00 2001 From: Yacin Tmimi Date: Sat, 1 Oct 2022 12:48:17 -0400 Subject: [PATCH] Apply updated `matches!` formatting to rustfmt 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. --- src/expr.rs | 6 +++--- src/items.rs | 5 +---- src/macros.rs | 12 +++--------- src/overflow.rs | 4 ++-- 4 files changed, 9 insertions(+), 18 deletions(-) diff --git a/src/expr.rs b/src/expr.rs index 76e47ac97eb..31419a1b228 100644 --- a/src/expr.rs +++ b/src/expr.rs @@ -1891,9 +1891,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, diff --git a/src/items.rs b/src/items.rs index 3c5293b6bf5..70fa86a33aa 100644 --- a/src/items.rs +++ b/src/items.rs @@ -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 { diff --git a/src/macros.rs b/src/macros.rs index fa7ff9da182..f224d842f4d 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -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 { @@ -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 { diff --git a/src/overflow.rs b/src/overflow.rs index b23248dfe0b..bce1d54a4ef 100644 --- a/src/overflow.rs +++ b/src/overflow.rs @@ -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(..)) ) }