Skip to content

Commit

Permalink
Fixed for loop problem, corrected all occurences that got linted
Browse files Browse the repository at this point in the history
  • Loading branch information
1c3t3a committed Feb 6, 2021
1 parent 55bfaa1 commit 6626295
Show file tree
Hide file tree
Showing 55 changed files with 149 additions and 148 deletions.
2 changes: 1 addition & 1 deletion clippy_lints/src/assertions_on_constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ impl<'tcx> LateLintPass<'tcx> for AssertionsOnConstants {
&format!("`assert!(false, {})` should probably be replaced", panic_message),
None,
&format!("use `panic!({})` or `unreachable!({})`", panic_message, panic_message),
)
);
};

if let Some(debug_assert_span) = is_expn_of(e.span, "debug_assert") {
Expand Down
6 changes: 3 additions & 3 deletions clippy_lints/src/attrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ impl<'tcx> LateLintPass<'tcx> for Attributes {

fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx Item<'_>) {
if is_relevant_item(cx, item) {
check_attrs(cx, item.span, item.ident.name, &item.attrs)
check_attrs(cx, item.span, item.ident.name, &item.attrs);
}
match item.kind {
ItemKind::ExternCrate(..) | ItemKind::Use(..) => {
Expand Down Expand Up @@ -353,13 +353,13 @@ impl<'tcx> LateLintPass<'tcx> for Attributes {

fn check_impl_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx ImplItem<'_>) {
if is_relevant_impl(cx, item) {
check_attrs(cx, item.span, item.ident.name, &item.attrs)
check_attrs(cx, item.span, item.ident.name, &item.attrs);
}
}

fn check_trait_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx TraitItem<'_>) {
if is_relevant_trait(cx, item) {
check_attrs(cx, item.span, item.ident.name, &item.attrs)
check_attrs(cx, item.span, item.ident.name, &item.attrs);
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions clippy_lints/src/bit_mask.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,9 @@ impl<'tcx> LateLintPass<'tcx> for BitMask {
if let ExprKind::Binary(cmp, left, right) = &e.kind {
if cmp.node.is_comparison() {
if let Some(cmp_opt) = fetch_int_literal(cx, right) {
check_compare(cx, left, cmp.node, cmp_opt, e.span)
check_compare(cx, left, cmp.node, cmp_opt, e.span);
} else if let Some(cmp_val) = fetch_int_literal(cx, left) {
check_compare(cx, right, invert_cmp(cmp.node), cmp_val, e.span)
check_compare(cx, right, invert_cmp(cmp.node), cmp_val, e.span);
}
}
}
Expand Down Expand Up @@ -171,7 +171,7 @@ fn check_compare(cx: &LateContext<'_>, bit_op: &Expr<'_>, cmp_op: BinOpKind, cmp
}
fetch_int_literal(cx, right)
.or_else(|| fetch_int_literal(cx, left))
.map_or((), |mask| check_bit_mask(cx, op.node, cmp_op, mask, cmp_value, span))
.map_or((), |mask| check_bit_mask(cx, op.node, cmp_op, mask, cmp_value, span));
}
}

Expand Down
6 changes: 3 additions & 3 deletions clippy_lints/src/booleans.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ impl<'tcx> LateLintPass<'tcx> for NonminimalBool {
_: Span,
_: HirId,
) {
NonminimalBoolVisitor { cx }.visit_body(body)
NonminimalBoolVisitor { cx }.visit_body(body);
}
}

Expand Down Expand Up @@ -184,7 +184,7 @@ impl<'a, 'tcx, 'v> SuggestContext<'a, 'tcx, 'v> {
Term(n) => {
let terminal = self.terminals[n as usize];
if let Some(str) = simplify_not(self.cx, terminal) {
self.output.push_str(&str)
self.output.push_str(&str);
} else {
self.output.push('!');
let snip = snippet_opt(self.cx, terminal.span)?;
Expand Down Expand Up @@ -452,7 +452,7 @@ impl<'a, 'tcx> Visitor<'tcx> for NonminimalBoolVisitor<'a, 'tcx> {
}
match &e.kind {
ExprKind::Binary(binop, _, _) if binop.node == BinOpKind::Or || binop.node == BinOpKind::And => {
self.bool_expr(e)
self.bool_expr(e);
},
ExprKind::Unary(UnOp::UnNot, inner) => {
if self.cx.typeck_results().node_types()[inner.hir_id].is_bool() {
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/collapsible_if.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ declare_lint_pass!(CollapsibleIf => [COLLAPSIBLE_IF, COLLAPSIBLE_ELSE_IF]);
impl EarlyLintPass for CollapsibleIf {
fn check_expr(&mut self, cx: &EarlyContext<'_>, expr: &ast::Expr) {
if !expr.span.from_expansion() {
check_if(cx, expr)
check_if(cx, expr);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/comparison_chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ impl<'tcx> LateLintPass<'tcx> for ComparisonChain {
"`if` chain can be rewritten with `match`",
None,
"Consider rewriting the `if` chain to use `cmp` and `match`.",
)
);
}
}

Expand Down
10 changes: 5 additions & 5 deletions clippy_lints/src/eq_op.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ impl<'tcx> LateLintPass<'tcx> for EqOp {
vec![(left.span, lsnip), (right.span, rsnip)],
);
},
)
);
} else if lcpy
&& !rcpy
&& implements_trait(cx, lty, trait_id, &[cx.typeck_results().expr_ty(right).into()])
Expand All @@ -175,7 +175,7 @@ impl<'tcx> LateLintPass<'tcx> for EqOp {
Applicability::MaybeIncorrect, // FIXME #2597
);
},
)
);
} else if !lcpy
&& rcpy
&& implements_trait(cx, cx.typeck_results().expr_ty(left), trait_id, &[rty.into()])
Expand All @@ -194,7 +194,7 @@ impl<'tcx> LateLintPass<'tcx> for EqOp {
Applicability::MaybeIncorrect, // FIXME #2597
);
},
)
);
}
},
// &foo == bar
Expand All @@ -218,7 +218,7 @@ impl<'tcx> LateLintPass<'tcx> for EqOp {
Applicability::MaybeIncorrect, // FIXME #2597
);
},
)
);
}
},
// foo == &bar
Expand All @@ -236,7 +236,7 @@ impl<'tcx> LateLintPass<'tcx> for EqOp {
rsnip,
Applicability::MaybeIncorrect, // FIXME #2597
);
})
});
}
},
_ => {},
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/eta_reduction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ impl<'tcx> LateLintPass<'tcx> for EtaReduction {
match expr.kind {
ExprKind::Call(_, args) | ExprKind::MethodCall(_, _, args, _) => {
for arg in args {
check_closure(cx, arg)
check_closure(cx, arg);
}
},
_ => (),
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/eval_order_dependence.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ impl<'a, 'tcx> DivergenceVisitor<'a, 'tcx> {
self.visit_expr(e);
for arm in arms {
if let Some(Guard::If(if_expr)) = arm.guard {
self.visit_expr(if_expr)
self.visit_expr(if_expr);
}
// make sure top level arm expressions aren't linted
self.maybe_walk_expr(&*arm.body);
Expand Down
6 changes: 3 additions & 3 deletions clippy_lints/src/functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ impl<'tcx> LateLintPass<'tcx> for Functions {
_,
)
| intravisit::FnKind::ItemFn(_, _, hir::FnHeader { abi: Abi::Rust, .. }, _, _) => {
self.check_arg_number(cx, decl, span.with_hi(decl.output.span().hi()))
self.check_arg_number(cx, decl, span.with_hi(decl.output.span().hi()));
},
_ => {},
}
Expand Down Expand Up @@ -434,7 +434,7 @@ impl<'tcx> Functions {
TOO_MANY_LINES,
span,
&format!("this function has too many lines ({}/{})", line_count, self.max_lines),
)
);
}
}

Expand Down Expand Up @@ -707,7 +707,7 @@ impl<'a, 'tcx> intravisit::Visitor<'tcx> for StaticMutVisitor<'a, 'tcx> {
}
},
Assign(ref target, ..) | AssignOp(_, ref target, _) | AddrOf(_, hir::Mutability::Mut, ref target) => {
self.mutates_static |= is_mutated_static(self.cx, target)
self.mutates_static |= is_mutated_static(self.cx, target);
},
_ => {},
}
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/future_not_send.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ impl<'tcx> LateLintPass<'tcx> for FutureNotSend {
));
}
}
})
});
},
);
}
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/infinite_iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ impl<'tcx> LateLintPass<'tcx> for InfiniteIter {
return;
},
};
span_lint(cx, lint, expr.span, msg)
span_lint(cx, lint, expr.span, msg);
}
}

Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/inherent_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ impl<'tcx> LateLintPass<'tcx> for MultipleInherentImpl {
|diag| {
diag.span_note(*initial_span, "first implementation here");
},
)
})
);
});
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/len_zero.rs
Original file line number Diff line number Diff line change
Expand Up @@ -256,9 +256,9 @@ fn check_cmp(cx: &LateContext<'_>, span: Span, method: &Expr<'_>, lit: &Expr<'_>
}
}

check_len(cx, span, method_path.ident.name, args, &lit.node, op, compare_to)
check_len(cx, span, method_path.ident.name, args, &lit.node, op, compare_to);
} else {
check_empty_expr(cx, span, method, lit, op)
check_empty_expr(cx, span, method, lit, op);
}
}

Expand Down
8 changes: 4 additions & 4 deletions clippy_lints/src/let_underscore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ impl<'tcx> LateLintPass<'tcx> for LetUnderscore {
None,
"consider using an underscore-prefixed named \
binding or dropping explicitly with `std::mem::drop`"
)
);
} else if implements_drop {
span_lint_and_help(
cx,
Expand All @@ -153,7 +153,7 @@ impl<'tcx> LateLintPass<'tcx> for LetUnderscore {
None,
"consider using an underscore-prefixed named \
binding or dropping explicitly with `std::mem::drop`"
)
);
} else if is_must_use_ty(cx, cx.typeck_results().expr_ty(init)) {
span_lint_and_help(
cx,
Expand All @@ -162,7 +162,7 @@ impl<'tcx> LateLintPass<'tcx> for LetUnderscore {
"non-binding let on an expression with `#[must_use]` type",
None,
"consider explicitly using expression value"
)
);
} else if is_must_use_func_call(cx, init) {
span_lint_and_help(
cx,
Expand All @@ -171,7 +171,7 @@ impl<'tcx> LateLintPass<'tcx> for LetUnderscore {
"non-binding let on a result of a `#[must_use]` function",
None,
"consider explicitly using function result"
)
);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/lifetimes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ fn could_use_elision<'tcx>(
output_visitor.visit_ty(ty);
}
for lt in named_generics {
input_visitor.visit_generic_param(lt)
input_visitor.visit_generic_param(lt);
}

if input_visitor.abort() || output_visitor.abort() {
Expand Down Expand Up @@ -460,7 +460,7 @@ impl<'tcx> Visitor<'tcx> for LifetimeChecker {
// `'b` in `'a: 'b` is useless unless used elsewhere in
// a non-lifetime bound
if let GenericParamKind::Type { .. } = param.kind {
walk_generic_param(self, param)
walk_generic_param(self, param);
}
}
fn nested_visit_map(&mut self) -> NestedVisitorMap<Self::Map> {
Expand Down
8 changes: 4 additions & 4 deletions clippy_lints/src/literal_representation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ impl EarlyLintPass for LiteralDigitGrouping {
}

if let ExprKind::Lit(ref lit) = expr.kind {
self.check_lit(cx, lit)
self.check_lit(cx, lit);
}
}
}
Expand Down Expand Up @@ -292,7 +292,7 @@ impl LiteralDigitGrouping {
}
};
if should_warn {
warning_type.display(num_lit.format(), cx, lit.span)
warning_type.display(num_lit.format(), cx, lit.span);
}
}
}
Expand Down Expand Up @@ -422,7 +422,7 @@ impl EarlyLintPass for DecimalLiteralRepresentation {
}

if let ExprKind::Lit(ref lit) = expr.kind {
self.check_lit(cx, lit)
self.check_lit(cx, lit);
}
}
}
Expand All @@ -444,7 +444,7 @@ impl DecimalLiteralRepresentation {
let hex = format!("{:#X}", val);
let num_lit = NumericLiteral::new(&hex, num_lit.suffix, false);
let _ = Self::do_lint(num_lit.integer).map_err(|warning_type| {
warning_type.display(num_lit.format(), cx, lit.span)
warning_type.display(num_lit.format(), cx, lit.span);
});
}
}
Expand Down
Loading

0 comments on commit 6626295

Please sign in to comment.