Skip to content

Commit 5bd7020

Browse files
committed
Simplify is_in_method_chain by using matches! for method call checks
1 parent ad68303 commit 5bd7020

File tree

1 file changed

+2
-10
lines changed

1 file changed

+2
-10
lines changed

clippy_lints/src/dereference.rs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -729,16 +729,8 @@ fn deref_method_same_type<'tcx>(result_ty: Ty<'tcx>, arg_ty: Ty<'tcx>) -> bool {
729729
}
730730

731731
fn is_in_method_chain<'tcx>(cx: &LateContext<'tcx>, e: &'tcx Expr<'tcx>) -> bool {
732-
if let ExprKind::MethodCall(_, recv, _, _) = e.kind {
733-
match recv.kind {
734-
ExprKind::MethodCall(..)
735-
| ExprKind::Index(..)
736-
| ExprKind::Match(.., MatchSource::TryDesugar(..) | MatchSource::AwaitDesugar)
737-
| ExprKind::Field(..) => {
738-
return true;
739-
},
740-
_ => {},
741-
}
732+
if matches!(e.kind, ExprKind::MethodCall(_, recv, _, _) if matches!(recv.kind, ExprKind::MethodCall(..))) {
733+
return true;
742734
}
743735

744736
if let Some(parent) = get_parent_expr(cx, e)

0 commit comments

Comments
 (0)