Skip to content

Commit c3b0ece

Browse files
author
chansuke
committed
Deduplicate if_chain method
1 parent a2875a0 commit c3b0ece

File tree

1 file changed

+2
-11
lines changed

1 file changed

+2
-11
lines changed

clippy_lints/src/types.rs

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1020,21 +1020,12 @@ fn check_loss_of_sign(cx: &LateContext<'_, '_>, expr: &Expr, op: &Expr, cast_fro
10201020
}
10211021
}
10221022

1023-
// don't lint for the result of `abs`
1023+
// don't lint for the result of `abs` & `checked_abs`
10241024
// `abs` is an inherent impl of `i{N}`, so a method call with ident `abs` will always
10251025
// resolve to that spesific method
10261026
if_chain! {
10271027
if let ExprKind::MethodCall(ref path, _, _) = op.kind;
1028-
if path.ident.name.as_str() == "abs";
1029-
then {
1030-
return
1031-
}
1032-
}
1033-
1034-
// don't lint for the result of `checked_abs`
1035-
if_chain! {
1036-
if let ExprKind::MethodCall(ref path, _, _) = op.kind;
1037-
if path.ident.name.as_str() == "checked_abs";
1028+
if ["abs", "checked_abs"].contains(path.ident.name);
10381029
then {
10391030
return
10401031
}

0 commit comments

Comments
 (0)