fmt clippy
This commit is contained in:
parent
839ad09689
commit
c9342d0121
41 changed files with 2187 additions and 1488 deletions
|
|
@ -37,18 +37,15 @@ impl LintPass for StepByZero {
|
|||
|
||||
impl LateLintPass for StepByZero {
|
||||
fn check_expr(&mut self, cx: &LateContext, expr: &Expr) {
|
||||
if let ExprMethodCall(Spanned { node: ref name, .. }, _,
|
||||
ref args) = expr.node {
|
||||
if let ExprMethodCall(Spanned { node: ref name, .. }, _, ref args) = expr.node {
|
||||
// Range with step_by(0).
|
||||
if name.as_str() == "step_by" && args.len() == 2 &&
|
||||
is_range(cx, &args[0]) && is_integer_literal(&args[1], 0) {
|
||||
cx.span_lint(RANGE_STEP_BY_ZERO, expr.span,
|
||||
"Range::step_by(0) produces an infinite iterator. \
|
||||
Consider using `std::iter::repeat()` instead")
|
||||
}
|
||||
|
||||
// x.iter().zip(0..x.len())
|
||||
else if name.as_str() == "zip" && args.len() == 2 {
|
||||
if name.as_str() == "step_by" && args.len() == 2 && is_range(cx, &args[0]) &&
|
||||
is_integer_literal(&args[1], 0) {
|
||||
cx.span_lint(RANGE_STEP_BY_ZERO,
|
||||
expr.span,
|
||||
"Range::step_by(0) produces an infinite iterator. Consider using `std::iter::repeat()` \
|
||||
instead")
|
||||
} else if name.as_str() == "zip" && args.len() == 2 {
|
||||
let iter = &args[0].node;
|
||||
let zip_arg = &args[1].node;
|
||||
if_let_chain! {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue