Skip to content

Commit

Permalink
Use match ergonomics compatible with editions 2021 and 2024
Browse files Browse the repository at this point in the history
  • Loading branch information
samueltardieu authored and flip1995 committed Nov 3, 2024
1 parent 7c5d752 commit 4415411
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions clippy_lints/src/trait_bounds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ impl<'tcx> LateLintPass<'tcx> for TraitBounds {
let mut self_bounds_map = FxHashMap::default();

for predicate in item.generics.predicates {
if let WherePredicate::BoundPredicate(ref bound_predicate) = predicate
if let WherePredicate::BoundPredicate(bound_predicate) = predicate
&& bound_predicate.origin != PredicateOrigin::ImplTrait
&& !bound_predicate.span.from_expansion()
&& let TyKind::Path(QPath::Resolved(_, Path { segments, .. })) = bound_predicate.bounded_ty.kind
Expand Down Expand Up @@ -268,7 +268,7 @@ impl TraitBounds {
let mut map: UnhashMap<SpanlessTy<'_, '_>, Vec<&GenericBound<'_>>> = UnhashMap::default();
let mut applicability = Applicability::MaybeIncorrect;
for bound in generics.predicates {
if let WherePredicate::BoundPredicate(ref p) = bound
if let WherePredicate::BoundPredicate(p) = bound
&& p.origin != PredicateOrigin::ImplTrait
&& p.bounds.len() as u64 <= self.max_trait_bounds
&& !p.span.from_expansion()
Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/unused_io_amount.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ fn unpack_call_chain<'a>(mut expr: &'a hir::Expr<'a>) -> &'a hir::Expr<'a> {
}

fn unpack_try<'a>(mut expr: &'a hir::Expr<'a>) -> &'a hir::Expr<'a> {
while let ExprKind::Call(func, [ref arg_0]) = expr.kind
while let ExprKind::Call(func, [arg_0]) = expr.kind
&& matches!(
func.kind,
ExprKind::Path(hir::QPath::LangItem(hir::LangItem::TryTraitBranch, ..))
Expand All @@ -266,7 +266,7 @@ fn unpack_match<'a>(mut expr: &'a hir::Expr<'a>) -> &'a hir::Expr<'a> {
/// waited on. Otherwise return None.
fn unpack_await<'a>(expr: &'a hir::Expr<'a>) -> &'a hir::Expr<'a> {
if let ExprKind::Match(expr, _, hir::MatchSource::AwaitDesugar) = expr.kind {
if let ExprKind::Call(func, [ref arg_0]) = expr.kind {
if let ExprKind::Call(func, [arg_0]) = expr.kind {
if matches!(
func.kind,
ExprKind::Path(hir::QPath::LangItem(hir::LangItem::IntoFutureIntoFuture, ..))
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/utils/internal_lints/collapsible_calls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ impl<'tcx> LateLintPass<'tcx> for CollapsibleCalls {

if let ExprKind::Call(func, [call_cx, call_lint, call_sp, call_msg, call_f]) = expr.kind
&& is_expr_path_def_path(cx, func, &["clippy_utils", "diagnostics", "span_lint_and_then"])
&& let ExprKind::Closure(&Closure { body, .. }) = &call_f.kind
&& let ExprKind::Closure(&Closure { body, .. }) = call_f.kind
&& let body = cx.tcx.hir().body(body)
&& let only_expr = peel_blocks_with_stmt(body.value)
&& let ExprKind::MethodCall(ps, recv, span_call_args, _) = &only_expr.kind
Expand Down
6 changes: 3 additions & 3 deletions clippy_utils/src/hir_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1201,11 +1201,11 @@ impl<'a, 'tcx> SpanlessHash<'a, 'tcx> {
self.hash_ty(ty);
self.hash_pat(pat);
},
TyKind::Ptr(ref mut_ty) => {
TyKind::Ptr(mut_ty) => {
self.hash_ty(mut_ty.ty);
mut_ty.mutbl.hash(&mut self.s);
},
TyKind::Ref(lifetime, ref mut_ty) => {
TyKind::Ref(lifetime, mut_ty) => {
self.hash_lifetime(lifetime);
self.hash_ty(mut_ty.ty);
mut_ty.mutbl.hash(&mut self.s);
Expand All @@ -1230,7 +1230,7 @@ impl<'a, 'tcx> SpanlessHash<'a, 'tcx> {
self.hash_ty(ty);
}
},
TyKind::Path(ref qpath) => self.hash_qpath(qpath),
TyKind::Path(qpath) => self.hash_qpath(qpath),
TyKind::TraitObject(_, lifetime, _) => {
self.hash_lifetime(lifetime);
},
Expand Down

0 comments on commit 4415411

Please sign in to comment.