From 35aade76ee9093785022811a991d7b4cdff55093 Mon Sep 17 00:00:00 2001 From: Jonathan Gruner Date: Mon, 21 Apr 2025 14:32:27 +0200 Subject: [PATCH 1/2] cleanup of redundant patterns --- src/sort.rs | 4 ++-- src/types.rs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/sort.rs b/src/sort.rs index 0cdd937b4f5..f13251e6f40 100644 --- a/src/sort.rs +++ b/src/sort.rs @@ -155,7 +155,7 @@ pub(crate) fn version_sort(a: &str, b: &str) -> std::cmp::Ordering { std::cmp::Ordering::Equal => { continue; } - order @ _ => return order, + order => return order, } } ( @@ -182,7 +182,7 @@ pub(crate) fn version_sort(a: &str, b: &str) -> std::cmp::Ordering { } continue; } - order @ _ => return order, + order => return order, }, }, } diff --git a/src/types.rs b/src/types.rs index 76f176c97c4..274e41bb192 100644 --- a/src/types.rs +++ b/src/types.rs @@ -1297,7 +1297,7 @@ fn join_bounds_inner( // or the single item is of type `Trait`, // and any of the internal arrays contains more than one item; let retry_with_force_newline = match context.config.style_edition() { - style_edition @ _ if style_edition <= StyleEdition::Edition2021 => { + style_edition if style_edition <= StyleEdition::Edition2021 => { !force_newline && items.len() > 1 && (result.0.contains('\n') || result.0.len() > shape.width) From 8791a38746d7b468aaa2db382d956d7e5742956c Mon Sep 17 00:00:00 2001 From: Jonathan Gruner Date: Wed, 23 Apr 2025 18:17:20 +0200 Subject: [PATCH 2/2] replaced if guard with explicit pattern matching --- src/types.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/types.rs b/src/types.rs index 274e41bb192..0d6d5ecfb51 100644 --- a/src/types.rs +++ b/src/types.rs @@ -7,7 +7,7 @@ use tracing::debug; use crate::comment::{combine_strs_with_missing_comments, contains_comment}; use crate::config::lists::*; -use crate::config::{IndentStyle, StyleEdition, TypeDensity}; +use crate::config::{IndentStyle, StyleEdition, StyleEdition::*, TypeDensity}; use crate::expr::{ ExprType, RhsAssignKind, format_expr, rewrite_assign_rhs, rewrite_call, rewrite_tuple, rewrite_unary_prefix, @@ -1297,7 +1297,7 @@ fn join_bounds_inner( // or the single item is of type `Trait`, // and any of the internal arrays contains more than one item; let retry_with_force_newline = match context.config.style_edition() { - style_edition if style_edition <= StyleEdition::Edition2021 => { + Edition2015 | Edition2018 | Edition2021 => { !force_newline && items.len() > 1 && (result.0.contains('\n') || result.0.len() > shape.width)