Use the expanded method lists
This commit is contained in:
parent
e51fcd03dc
commit
28f247e16c
@ -102,24 +102,20 @@ fn expr_sign(cx: &LateContext<'_>, expr: &Expr<'_>, ty: Ty<'_>) -> Sign {
|
|||||||
if let Some(val) = get_const_int_eval(cx, expr, ty) {
|
if let Some(val) = get_const_int_eval(cx, expr, ty) {
|
||||||
return if val >= 0 { Sign::ZeroOrPositive } else { Sign::Negative };
|
return if val >= 0 { Sign::ZeroOrPositive } else { Sign::Negative };
|
||||||
}
|
}
|
||||||
|
|
||||||
// Calling on methods that always return non-negative values.
|
// Calling on methods that always return non-negative values.
|
||||||
if let ExprKind::MethodCall(path, caller, args, ..) = expr.kind {
|
if let ExprKind::MethodCall(path, caller, args, ..) = expr.kind {
|
||||||
let mut method_name = path.ident.name.as_str();
|
let mut method_name = path.ident.name.as_str();
|
||||||
|
|
||||||
if method_name == "unwrap"
|
// Peel unwrap(), expect(), etc.
|
||||||
&& let Some(arglist) = method_chain_args(expr, &["unwrap"])
|
while let Some(&found_name) = METHODS_UNWRAP.iter().find(|&name| &method_name == name)
|
||||||
&& let ExprKind::MethodCall(inner_path, ..) = &arglist[0].0.kind
|
&& let Some(arglist) = method_chain_args(expr, &[found_name])
|
||||||
{
|
|
||||||
method_name = inner_path.ident.name.as_str();
|
|
||||||
}
|
|
||||||
if method_name == "expect"
|
|
||||||
&& let Some(arglist) = method_chain_args(expr, &["expect"])
|
|
||||||
&& let ExprKind::MethodCall(inner_path, ..) = &arglist[0].0.kind
|
&& let ExprKind::MethodCall(inner_path, ..) = &arglist[0].0.kind
|
||||||
{
|
{
|
||||||
method_name = inner_path.ident.name.as_str();
|
method_name = inner_path.ident.name.as_str();
|
||||||
}
|
}
|
||||||
|
|
||||||
if method_name == "pow"
|
if METHODS_POW.iter().any(|&name| method_name == name)
|
||||||
&& let [arg] = args
|
&& let [arg] = args
|
||||||
{
|
{
|
||||||
return pow_call_result_sign(cx, caller, arg);
|
return pow_call_result_sign(cx, caller, arg);
|
||||||
|
Loading…
Reference in New Issue
Block a user