Skip to content

Commit

Permalink
Deduplicate if_chain method
Browse files Browse the repository at this point in the history
  • Loading branch information
chansuke committed Nov 13, 2019
1 parent a2875a0 commit c3b0ece
Showing 1 changed file with 2 additions and 11 deletions.
13 changes: 2 additions & 11 deletions clippy_lints/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1020,21 +1020,12 @@ fn check_loss_of_sign(cx: &LateContext<'_, '_>, expr: &Expr, op: &Expr, cast_fro
}
}

// don't lint for the result of `abs`
// don't lint for the result of `abs` & `checked_abs`
// `abs` is an inherent impl of `i{N}`, so a method call with ident `abs` will always
// resolve to that spesific method
if_chain! {
if let ExprKind::MethodCall(ref path, _, _) = op.kind;
if path.ident.name.as_str() == "abs";
then {
return
}
}

// don't lint for the result of `checked_abs`
if_chain! {
if let ExprKind::MethodCall(ref path, _, _) = op.kind;
if path.ident.name.as_str() == "checked_abs";
if ["abs", "checked_abs"].contains(path.ident.name);
then {
return
}
Expand Down

0 comments on commit c3b0ece

Please sign in to comment.