From cd6748749a454e07a3f7f72c79bc62c2f5d6b9e4 Mon Sep 17 00:00:00 2001 From: Bastian Kersting Date: Sat, 6 Feb 2021 16:44:57 +0100 Subject: [PATCH] Revert "Fixed for loop problem, corrected all occurences that got linted" This reverts commit 6626295fbc747d04f1a8d14f19ee48c789b90e50. --- clippy_lints/src/assertions_on_constants.rs | 2 +- clippy_lints/src/attrs.rs | 6 ++-- clippy_lints/src/bit_mask.rs | 6 ++-- clippy_lints/src/booleans.rs | 6 ++-- clippy_lints/src/collapsible_if.rs | 2 +- clippy_lints/src/comparison_chain.rs | 2 +- clippy_lints/src/eq_op.rs | 10 +++--- clippy_lints/src/eta_reduction.rs | 2 +- clippy_lints/src/eval_order_dependence.rs | 2 +- clippy_lints/src/functions.rs | 6 ++-- clippy_lints/src/future_not_send.rs | 2 +- clippy_lints/src/infinite_iter.rs | 2 +- clippy_lints/src/inherent_impl.rs | 4 +-- clippy_lints/src/len_zero.rs | 4 +-- clippy_lints/src/let_underscore.rs | 8 ++--- clippy_lints/src/lifetimes.rs | 4 +-- clippy_lints/src/literal_representation.rs | 8 ++--- clippy_lints/src/loops.rs | 22 ++++++------- clippy_lints/src/macro_use.rs | 6 ++-- clippy_lints/src/manual_strip.rs | 2 +- clippy_lints/src/map_clone.rs | 6 ++-- clippy_lints/src/matches.rs | 6 ++-- .../src/methods/bind_instead_of_map.rs | 2 +- clippy_lints/src/methods/mod.rs | 20 ++++++------ clippy_lints/src/mut_reference.rs | 2 +- clippy_lints/src/mutable_debug_assertion.rs | 2 +- .../src/needless_arbitrary_self_type.rs | 2 +- clippy_lints/src/needless_bool.rs | 18 +++++------ clippy_lints/src/neg_cmp_op_on_partial_ord.rs | 2 +- clippy_lints/src/open_options.rs | 10 +++--- clippy_lints/src/question_mark.rs | 2 +- clippy_lints/src/redundant_closure_call.rs | 2 +- clippy_lints/src/redundant_pub_crate.rs | 2 +- clippy_lints/src/returns.rs | 4 +-- .../src/semicolon_if_nothing_returned.rs | 32 +++++++++++-------- clippy_lints/src/shadow.rs | 10 +++--- .../src/slow_vector_initialization.rs | 2 +- .../src/suspicious_operation_groupings.rs | 6 ++-- clippy_lints/src/transmute.rs | 6 ++-- clippy_lints/src/types.rs | 6 ++-- clippy_lints/src/unicode.rs | 4 +-- clippy_lints/src/unused_self.rs | 2 +- clippy_lints/src/upper_case_acronyms.rs | 2 +- clippy_lints/src/use_self.rs | 2 +- clippy_lints/src/utils/attrs.rs | 2 +- clippy_lints/src/utils/author.rs | 2 +- clippy_lints/src/utils/diagnostics.rs | 2 +- clippy_lints/src/utils/mod.rs | 2 +- clippy_lints/src/utils/sugg.rs | 2 +- clippy_lints/src/utils/usage.rs | 6 ++-- clippy_lints/src/utils/visitors.rs | 2 +- clippy_lints/src/verbose_file_reads.rs | 2 +- clippy_lints/src/write.rs | 2 +- tests/ui/semicolon_if_nothing_returned.rs | 7 ---- tests/ui/semicolon_if_nothing_returned.stderr | 10 +++--- 55 files changed, 148 insertions(+), 149 deletions(-) diff --git a/clippy_lints/src/assertions_on_constants.rs b/clippy_lints/src/assertions_on_constants.rs index b9de4780173..aa431f0596c 100644 --- a/clippy_lints/src/assertions_on_constants.rs +++ b/clippy_lints/src/assertions_on_constants.rs @@ -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") { diff --git a/clippy_lints/src/attrs.rs b/clippy_lints/src/attrs.rs index 90463d7f026..652d1fa16b6 100644 --- a/clippy_lints/src/attrs.rs +++ b/clippy_lints/src/attrs.rs @@ -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(..) => { @@ -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) } } } diff --git a/clippy_lints/src/bit_mask.rs b/clippy_lints/src/bit_mask.rs index 8d9fbcf4fd1..a4ee54076ee 100644 --- a/clippy_lints/src/bit_mask.rs +++ b/clippy_lints/src/bit_mask.rs @@ -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) } } } @@ -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)) } } diff --git a/clippy_lints/src/booleans.rs b/clippy_lints/src/booleans.rs index 75f011a7fa0..90bb0bd555f 100644 --- a/clippy_lints/src/booleans.rs +++ b/clippy_lints/src/booleans.rs @@ -66,7 +66,7 @@ impl<'tcx> LateLintPass<'tcx> for NonminimalBool { _: Span, _: HirId, ) { - NonminimalBoolVisitor { cx }.visit_body(body); + NonminimalBoolVisitor { cx }.visit_body(body) } } @@ -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)?; @@ -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() { diff --git a/clippy_lints/src/collapsible_if.rs b/clippy_lints/src/collapsible_if.rs index 4e7a6250add..93ccc76d0c9 100644 --- a/clippy_lints/src/collapsible_if.rs +++ b/clippy_lints/src/collapsible_if.rs @@ -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) } } } diff --git a/clippy_lints/src/comparison_chain.rs b/clippy_lints/src/comparison_chain.rs index 59b1c806e23..90d31dece13 100644 --- a/clippy_lints/src/comparison_chain.rs +++ b/clippy_lints/src/comparison_chain.rs @@ -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`.", - ); + ) } } diff --git a/clippy_lints/src/eq_op.rs b/clippy_lints/src/eq_op.rs index e2881315b56..6308f6e2e7e 100644 --- a/clippy_lints/src/eq_op.rs +++ b/clippy_lints/src/eq_op.rs @@ -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()]) @@ -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()]) @@ -194,7 +194,7 @@ impl<'tcx> LateLintPass<'tcx> for EqOp { Applicability::MaybeIncorrect, // FIXME #2597 ); }, - ); + ) } }, // &foo == bar @@ -218,7 +218,7 @@ impl<'tcx> LateLintPass<'tcx> for EqOp { Applicability::MaybeIncorrect, // FIXME #2597 ); }, - ); + ) } }, // foo == &bar @@ -236,7 +236,7 @@ impl<'tcx> LateLintPass<'tcx> for EqOp { rsnip, Applicability::MaybeIncorrect, // FIXME #2597 ); - }); + }) } }, _ => {}, diff --git a/clippy_lints/src/eta_reduction.rs b/clippy_lints/src/eta_reduction.rs index 91f9df4649b..1a722d39f73 100644 --- a/clippy_lints/src/eta_reduction.rs +++ b/clippy_lints/src/eta_reduction.rs @@ -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) } }, _ => (), diff --git a/clippy_lints/src/eval_order_dependence.rs b/clippy_lints/src/eval_order_dependence.rs index 8df14d80026..bc2b2904698 100644 --- a/clippy_lints/src/eval_order_dependence.rs +++ b/clippy_lints/src/eval_order_dependence.rs @@ -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); diff --git a/clippy_lints/src/functions.rs b/clippy_lints/src/functions.rs index 45973c8b0f7..87954254610 100644 --- a/clippy_lints/src/functions.rs +++ b/clippy_lints/src/functions.rs @@ -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())) }, _ => {}, } @@ -434,7 +434,7 @@ impl<'tcx> Functions { TOO_MANY_LINES, span, &format!("this function has too many lines ({}/{})", line_count, self.max_lines), - ); + ) } } @@ -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) }, _ => {}, } diff --git a/clippy_lints/src/future_not_send.rs b/clippy_lints/src/future_not_send.rs index 55bdda7138e..7208e66ff7b 100644 --- a/clippy_lints/src/future_not_send.rs +++ b/clippy_lints/src/future_not_send.rs @@ -101,7 +101,7 @@ impl<'tcx> LateLintPass<'tcx> for FutureNotSend { )); } } - }); + }) }, ); } diff --git a/clippy_lints/src/infinite_iter.rs b/clippy_lints/src/infinite_iter.rs index dd0a3d1610b..129abd7d897 100644 --- a/clippy_lints/src/infinite_iter.rs +++ b/clippy_lints/src/infinite_iter.rs @@ -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) } } diff --git a/clippy_lints/src/inherent_impl.rs b/clippy_lints/src/inherent_impl.rs index 2c5e6f11216..ea26c84cde1 100644 --- a/clippy_lints/src/inherent_impl.rs +++ b/clippy_lints/src/inherent_impl.rs @@ -85,8 +85,8 @@ impl<'tcx> LateLintPass<'tcx> for MultipleInherentImpl { |diag| { diag.span_note(*initial_span, "first implementation here"); }, - ); - }); + ) + }) } } } diff --git a/clippy_lints/src/len_zero.rs b/clippy_lints/src/len_zero.rs index 599602c4a0b..e95caf6a35f 100644 --- a/clippy_lints/src/len_zero.rs +++ b/clippy_lints/src/len_zero.rs @@ -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) } } diff --git a/clippy_lints/src/let_underscore.rs b/clippy_lints/src/let_underscore.rs index 33621775742..6a5a77f8690 100644 --- a/clippy_lints/src/let_underscore.rs +++ b/clippy_lints/src/let_underscore.rs @@ -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, @@ -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, @@ -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, @@ -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" - ); + ) } } } diff --git a/clippy_lints/src/lifetimes.rs b/clippy_lints/src/lifetimes.rs index 740f207b214..e84c8b4e5b3 100644 --- a/clippy_lints/src/lifetimes.rs +++ b/clippy_lints/src/lifetimes.rs @@ -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() { @@ -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 { diff --git a/clippy_lints/src/literal_representation.rs b/clippy_lints/src/literal_representation.rs index 7b75ab89bb8..87a957a9bd2 100644 --- a/clippy_lints/src/literal_representation.rs +++ b/clippy_lints/src/literal_representation.rs @@ -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) } } } @@ -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) } } } @@ -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) } } } @@ -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) }); } } diff --git a/clippy_lints/src/loops.rs b/clippy_lints/src/loops.rs index c7e0d32ca27..663c2df23e2 100644 --- a/clippy_lints/src/loops.rs +++ b/clippy_lints/src/loops.rs @@ -1426,7 +1426,7 @@ fn detect_same_item_push<'tcx>( "try using vec![{};SIZE] or {}.resize(NEW_SIZE, {})", item_str, vec_str, item_str ), - ); + ) } if !matches!(pat.kind, PatKind::Wild) { @@ -1714,7 +1714,7 @@ fn lint_iter_method(cx: &LateContext<'_>, args: &[Expr<'_>], arg: &Expr<'_>, met "to write this more concisely, try", format!("&{}{}", muta, object), applicability, - ); + ) } fn check_for_loop_arg(cx: &LateContext<'_>, pat: &Pat<'_>, arg: &Expr<'_>, expr: &Expr<'_>) { @@ -1753,7 +1753,7 @@ fn check_for_loop_arg(cx: &LateContext<'_>, pat: &Pat<'_>, arg: &Expr<'_>, expr: }, ); if TyS::same_type(receiver_ty_adjusted, ref_receiver_ty) { - lint_iter_method(cx, args, arg, method_name); + lint_iter_method(cx, args, arg, method_name) } } } else if method_name == "next" && match_trait_method(cx, arg, &paths::ITERATOR) { @@ -2075,10 +2075,10 @@ impl<'tcx> Delegate<'tcx> for MutatePairDelegate<'_, 'tcx> { if let ty::BorrowKind::MutBorrow = bk { if let PlaceBase::Local(id) = cmt.place.base { if Some(id) == self.hir_id_low { - self.span_low = Some(self.cx.tcx.hir().span(diag_expr_id)); + self.span_low = Some(self.cx.tcx.hir().span(diag_expr_id)) } if Some(id) == self.hir_id_high { - self.span_high = Some(self.cx.tcx.hir().span(diag_expr_id)); + self.span_high = Some(self.cx.tcx.hir().span(diag_expr_id)) } } } @@ -2087,10 +2087,10 @@ impl<'tcx> Delegate<'tcx> for MutatePairDelegate<'_, 'tcx> { fn mutate(&mut self, cmt: &PlaceWithHirId<'tcx>, diag_expr_id: HirId) { if let PlaceBase::Local(id) = cmt.place.base { if Some(id) == self.hir_id_low { - self.span_low = Some(self.cx.tcx.hir().span(diag_expr_id)); + self.span_low = Some(self.cx.tcx.hir().span(diag_expr_id)) } if Some(id) == self.hir_id_high { - self.span_high = Some(self.cx.tcx.hir().span(diag_expr_id)); + self.span_high = Some(self.cx.tcx.hir().span(diag_expr_id)) } } } @@ -2543,10 +2543,10 @@ impl<'a, 'tcx> Visitor<'tcx> for IncrementVisitor<'a, 'tcx> { } }, ExprKind::Assign(ref lhs, _, _) if lhs.hir_id == expr.hir_id => { - *state = IncrementVisitorVarState::DontWarn; + *state = IncrementVisitorVarState::DontWarn }, ExprKind::AddrOf(BorrowKind::Ref, mutability, _) if mutability == Mutability::Mut => { - *state = IncrementVisitorVarState::DontWarn; + *state = IncrementVisitorVarState::DontWarn }, _ => (), } @@ -2670,7 +2670,7 @@ impl<'a, 'tcx> Visitor<'tcx> for InitializeVisitor<'a, 'tcx> { } }, ExprKind::AddrOf(BorrowKind::Ref, mutability, _) if mutability == Mutability::Mut => { - self.state = InitializeVisitorState::DontWarn; + self.state = InitializeVisitorState::DontWarn }, _ => (), } @@ -2815,7 +2815,7 @@ impl<'tcx> Visitor<'tcx> for LoopNestVisitor { return; } } - walk_pat(self, pat); + walk_pat(self, pat) } fn nested_visit_map(&mut self) -> NestedVisitorMap { diff --git a/clippy_lints/src/macro_use.rs b/clippy_lints/src/macro_use.rs index f4ffe189940..bb52888883a 100644 --- a/clippy_lints/src/macro_use.rs +++ b/clippy_lints/src/macro_use.rs @@ -206,9 +206,9 @@ impl<'tcx> LateLintPass<'tcx> for MacroUseImports { let mut suggestions = vec![]; for ((root, span), path) in used { if path.len() == 1 { - suggestions.push((span, format!("{}::{}", root, path[0]))); + suggestions.push((span, format!("{}::{}", root, path[0]))) } else { - suggestions.push((span, format!("{}::{{{}}}", root, path.join(", ")))); + suggestions.push((span, format!("{}::{{{}}}", root, path.join(", ")))) } } @@ -225,7 +225,7 @@ impl<'tcx> LateLintPass<'tcx> for MacroUseImports { "remove the attribute and import the macro directly, try", help, Applicability::MaybeIncorrect, - ); + ) } } } diff --git a/clippy_lints/src/manual_strip.rs b/clippy_lints/src/manual_strip.rs index 11d101c5025..42a92104a49 100644 --- a/clippy_lints/src/manual_strip.rs +++ b/clippy_lints/src/manual_strip.rs @@ -126,7 +126,7 @@ impl<'tcx> LateLintPass<'tcx> for ManualStrip { kind_word, snippet(cx, pattern.span, "..")))] .into_iter().chain(strippings.into_iter().map(|span| (span, "".into()))), - ); + ) }); } } diff --git a/clippy_lints/src/map_clone.rs b/clippy_lints/src/map_clone.rs index b3be755d488..1818836d5d5 100644 --- a/clippy_lints/src/map_clone.rs +++ b/clippy_lints/src/map_clone.rs @@ -122,7 +122,7 @@ fn lint_needless_cloning(cx: &LateContext<'_>, root: Span, receiver: Span) { "remove the `map` call", String::new(), Applicability::MachineApplicable, - ); + ) } fn lint(cx: &LateContext<'_>, replace: Span, root: Span, copied: bool) { @@ -139,7 +139,7 @@ fn lint(cx: &LateContext<'_>, replace: Span, root: Span, copied: bool) { snippet_with_applicability(cx, root, "..", &mut applicability) ), applicability, - ); + ) } else { span_lint_and_sugg( cx, @@ -152,6 +152,6 @@ fn lint(cx: &LateContext<'_>, replace: Span, root: Span, copied: bool) { snippet_with_applicability(cx, root, "..", &mut applicability) ), applicability, - ); + ) } } diff --git a/clippy_lints/src/matches.rs b/clippy_lints/src/matches.rs index 74d36777779..ba7b9bd0424 100644 --- a/clippy_lints/src/matches.rs +++ b/clippy_lints/src/matches.rs @@ -1046,7 +1046,7 @@ fn check_wild_enum_match(cx: &LateContext<'_>, ex: &Expr<'_>, arms: &[Arm<'_>]) "try this", suggestion[0].clone(), Applicability::MaybeIncorrect, - ); + ) }; span_lint_and_sugg( @@ -1057,7 +1057,7 @@ fn check_wild_enum_match(cx: &LateContext<'_>, ex: &Expr<'_>, arms: &[Arm<'_>]) "try this", suggestion.join(" | "), Applicability::MaybeIncorrect, - ); + ) } } @@ -1156,7 +1156,7 @@ fn check_match_as_ref(cx: &LateContext<'_>, ex: &Expr<'_>, arms: &[Arm<'_>], exp cast, ), applicability, - ); + ) } } } diff --git a/clippy_lints/src/methods/bind_instead_of_map.rs b/clippy_lints/src/methods/bind_instead_of_map.rs index 897a3194ca1..540a1484a85 100644 --- a/clippy_lints/src/methods/bind_instead_of_map.rs +++ b/clippy_lints/src/methods/bind_instead_of_map.rs @@ -151,7 +151,7 @@ pub(crate) trait BindInsteadOfMap { .into_iter() .map(|(span1, span2)| (span1, snippet(cx, span2, "_").into())), ), - ); + ) }); } can_sugg diff --git a/clippy_lints/src/methods/mod.rs b/clippy_lints/src/methods/mod.rs index e02b6403819..a17c5996293 100644 --- a/clippy_lints/src/methods/mod.rs +++ b/clippy_lints/src/methods/mod.rs @@ -1582,10 +1582,10 @@ impl<'tcx> LateLintPass<'tcx> for Methods { ["flatten", "map"] => lint_map_flatten(cx, expr, arg_lists[1]), ["is_some", "find"] => lint_search_is_some(cx, expr, "find", arg_lists[1], arg_lists[0], method_spans[1]), ["is_some", "position"] => { - lint_search_is_some(cx, expr, "position", arg_lists[1], arg_lists[0], method_spans[1]); + lint_search_is_some(cx, expr, "position", arg_lists[1], arg_lists[0], method_spans[1]) }, ["is_some", "rposition"] => { - lint_search_is_some(cx, expr, "rposition", arg_lists[1], arg_lists[0], method_spans[1]); + lint_search_is_some(cx, expr, "rposition", arg_lists[1], arg_lists[0], method_spans[1]) }, ["extend", ..] => lint_extend(cx, expr, arg_lists[0]), ["nth", "iter"] => lint_iter_nth(cx, expr, &arg_lists, false), @@ -1601,17 +1601,17 @@ impl<'tcx> LateLintPass<'tcx> for Methods { ["count", "map"] => lint_suspicious_map(cx, expr), ["assume_init"] => lint_maybe_uninit(cx, &arg_lists[0][0], expr), ["unwrap_or", arith @ ("checked_add" | "checked_sub" | "checked_mul")] => { - manual_saturating_arithmetic::lint(cx, expr, &arg_lists, &arith["checked_".len()..]); + manual_saturating_arithmetic::lint(cx, expr, &arg_lists, &arith["checked_".len()..]) }, ["add" | "offset" | "sub" | "wrapping_offset" | "wrapping_add" | "wrapping_sub"] => { - check_pointer_offset(cx, expr, arg_lists[0]); + check_pointer_offset(cx, expr, arg_lists[0]) }, ["is_file", ..] => lint_filetype_is_file(cx, expr, arg_lists[0]), ["map", "as_ref"] => { - lint_option_as_ref_deref(cx, expr, arg_lists[1], arg_lists[0], false, self.msrv.as_ref()); + lint_option_as_ref_deref(cx, expr, arg_lists[1], arg_lists[0], false, self.msrv.as_ref()) }, ["map", "as_mut"] => { - lint_option_as_ref_deref(cx, expr, arg_lists[1], arg_lists[0], true, self.msrv.as_ref()); + lint_option_as_ref_deref(cx, expr, arg_lists[1], arg_lists[0], true, self.msrv.as_ref()) }, ["unwrap_or_else", ..] => unnecessary_lazy_eval::lint(cx, expr, arg_lists[0], "unwrap_or"), ["get_or_insert_with", ..] => unnecessary_lazy_eval::lint(cx, expr, arg_lists[0], "get_or_insert"), @@ -2446,16 +2446,16 @@ fn lint_unnecessary_fold(cx: &LateContext<'_>, expr: &hir::Expr<'_>, fold_args: if let hir::ExprKind::Lit(ref lit) = fold_args[1].kind { match lit.node { ast::LitKind::Bool(false) => { - check_fold_with_op(cx, expr, fold_args, fold_span, hir::BinOpKind::Or, "any", true); + check_fold_with_op(cx, expr, fold_args, fold_span, hir::BinOpKind::Or, "any", true) }, ast::LitKind::Bool(true) => { - check_fold_with_op(cx, expr, fold_args, fold_span, hir::BinOpKind::And, "all", true); + check_fold_with_op(cx, expr, fold_args, fold_span, hir::BinOpKind::And, "all", true) }, ast::LitKind::Int(0, _) => { - check_fold_with_op(cx, expr, fold_args, fold_span, hir::BinOpKind::Add, "sum", false); + check_fold_with_op(cx, expr, fold_args, fold_span, hir::BinOpKind::Add, "sum", false) }, ast::LitKind::Int(1, _) => { - check_fold_with_op(cx, expr, fold_args, fold_span, hir::BinOpKind::Mul, "product", false); + check_fold_with_op(cx, expr, fold_args, fold_span, hir::BinOpKind::Mul, "product", false) }, _ => (), } diff --git a/clippy_lints/src/mut_reference.rs b/clippy_lints/src/mut_reference.rs index 7c21632c9d5..3f0b765df15 100644 --- a/clippy_lints/src/mut_reference.rs +++ b/clippy_lints/src/mut_reference.rs @@ -47,7 +47,7 @@ impl<'tcx> LateLintPass<'tcx> for UnnecessaryMutPassed { let def_id = cx.typeck_results().type_dependent_def_id(e.hir_id).unwrap(); let substs = cx.typeck_results().node_substs(e.hir_id); let method_type = cx.tcx.type_of(def_id).subst(cx.tcx, substs); - check_arguments(cx, arguments, method_type, &path.ident.as_str(), "method"); + check_arguments(cx, arguments, method_type, &path.ident.as_str(), "method") }, _ => (), } diff --git a/clippy_lints/src/mutable_debug_assertion.rs b/clippy_lints/src/mutable_debug_assertion.rs index b99e9576f5e..76417aa7ed0 100644 --- a/clippy_lints/src/mutable_debug_assertion.rs +++ b/clippy_lints/src/mutable_debug_assertion.rs @@ -106,7 +106,7 @@ impl<'a, 'tcx> Visitor<'tcx> for MutArgVisitor<'a, 'tcx> { _ if !self.found => self.expr_span = Some(expr.span), _ => return, } - walk_expr(self, expr); + walk_expr(self, expr) } fn nested_visit_map(&mut self) -> NestedVisitorMap { diff --git a/clippy_lints/src/needless_arbitrary_self_type.rs b/clippy_lints/src/needless_arbitrary_self_type.rs index 107d6a57966..7687962bdd9 100644 --- a/clippy_lints/src/needless_arbitrary_self_type.rs +++ b/clippy_lints/src/needless_arbitrary_self_type.rs @@ -120,7 +120,7 @@ impl EarlyLintPass for NeedlessArbitrarySelfType { match &p.ty.kind { TyKind::Path(None, path) => { if let PatKind::Ident(BindingMode::ByValue(mutbl), _, _) = p.pat.kind { - check_param_inner(cx, path, p.span.to(p.ty.span), &Mode::Value, mutbl); + check_param_inner(cx, path, p.span.to(p.ty.span), &Mode::Value, mutbl) } }, TyKind::Rptr(lifetime, mut_ty) => { diff --git a/clippy_lints/src/needless_bool.rs b/clippy_lints/src/needless_bool.rs index 614a1e8980c..d795f126457 100644 --- a/clippy_lints/src/needless_bool.rs +++ b/clippy_lints/src/needless_bool.rs @@ -80,7 +80,7 @@ impl<'tcx> LateLintPass<'tcx> for NeedlessBool { } if parent_node_is_if_expr(&e, &cx) { - snip = snip.blockify(); + snip = snip.blockify() } span_lint_and_sugg( @@ -142,7 +142,7 @@ impl<'tcx> LateLintPass<'tcx> for BoolComparison { |h: Sugg<'_>| !h, "equality checks against false can be replaced by a negation", )); - check_comparison(cx, e, true_case, false_case, true_case, false_case, ignore_no_literal); + check_comparison(cx, e, true_case, false_case, true_case, false_case, ignore_no_literal) }, BinOpKind::Ne => { let true_case = Some(( @@ -150,7 +150,7 @@ impl<'tcx> LateLintPass<'tcx> for BoolComparison { "inequality checks against true can be replaced by a negation", )); let false_case = Some((|h| h, "inequality checks against false are unnecessary")); - check_comparison(cx, e, true_case, false_case, true_case, false_case, ignore_no_literal); + check_comparison(cx, e, true_case, false_case, true_case, false_case, ignore_no_literal) }, BinOpKind::Lt => check_comparison( cx, @@ -249,22 +249,22 @@ fn check_comparison<'a, 'tcx>( snippet_with_applicability(cx, expression_info.right_span, "..", &mut applicability) ), applicability, - ); + ) } } match (fetch_bool_expr(left_side), fetch_bool_expr(right_side)) { (Bool(true), Other) => left_true.map_or((), |(h, m)| { - suggest_bool_comparison(cx, e, right_side, applicability, m, h); + suggest_bool_comparison(cx, e, right_side, applicability, m, h) }), (Other, Bool(true)) => right_true.map_or((), |(h, m)| { - suggest_bool_comparison(cx, e, left_side, applicability, m, h); + suggest_bool_comparison(cx, e, left_side, applicability, m, h) }), (Bool(false), Other) => left_false.map_or((), |(h, m)| { - suggest_bool_comparison(cx, e, right_side, applicability, m, h); + suggest_bool_comparison(cx, e, right_side, applicability, m, h) }), (Other, Bool(false)) => right_false.map_or((), |(h, m)| { - suggest_bool_comparison(cx, e, left_side, applicability, m, h); + suggest_bool_comparison(cx, e, left_side, applicability, m, h) }), (Other, Other) => no_literal.map_or((), |(h, m)| { let left_side = Sugg::hir_with_applicability(cx, left_side, "..", &mut applicability); @@ -277,7 +277,7 @@ fn check_comparison<'a, 'tcx>( "try simplifying it as shown", h(left_side, right_side).to_string(), applicability, - ); + ) }), _ => (), } diff --git a/clippy_lints/src/neg_cmp_op_on_partial_ord.rs b/clippy_lints/src/neg_cmp_op_on_partial_ord.rs index 6a20d5f139a..4fb899125e8 100644 --- a/clippy_lints/src/neg_cmp_op_on_partial_ord.rs +++ b/clippy_lints/src/neg_cmp_op_on_partial_ord.rs @@ -83,7 +83,7 @@ impl<'tcx> LateLintPass<'tcx> for NoNegCompOpForPartialOrd { types produces code that is hard to read and refactor, please \ consider using the `partial_cmp` method instead, to make it \ clear that the two values could be incomparable" - ); + ) } } } diff --git a/clippy_lints/src/open_options.rs b/clippy_lints/src/open_options.rs index 82143f7a288..73a99a3a2f8 100644 --- a/clippy_lints/src/open_options.rs +++ b/clippy_lints/src/open_options.rs @@ -125,7 +125,7 @@ fn check_open_options(cx: &LateContext<'_>, options: &[(OpenOption, Argument)], "the method `create` is called more than once", ); } else { - create = true; + create = true } create_arg = create_arg || (arg == Argument::True); }, @@ -138,7 +138,7 @@ fn check_open_options(cx: &LateContext<'_>, options: &[(OpenOption, Argument)], "the method `append` is called more than once", ); } else { - append = true; + append = true } append_arg = append_arg || (arg == Argument::True); }, @@ -151,7 +151,7 @@ fn check_open_options(cx: &LateContext<'_>, options: &[(OpenOption, Argument)], "the method `truncate` is called more than once", ); } else { - truncate = true; + truncate = true } truncate_arg = truncate_arg || (arg == Argument::True); }, @@ -164,7 +164,7 @@ fn check_open_options(cx: &LateContext<'_>, options: &[(OpenOption, Argument)], "the method `read` is called more than once", ); } else { - read = true; + read = true } read_arg = read_arg || (arg == Argument::True); }, @@ -177,7 +177,7 @@ fn check_open_options(cx: &LateContext<'_>, options: &[(OpenOption, Argument)], "the method `write` is called more than once", ); } else { - write = true; + write = true } write_arg = write_arg || (arg == Argument::True); }, diff --git a/clippy_lints/src/question_mark.rs b/clippy_lints/src/question_mark.rs index 63c904b7fb4..6c480d48c75 100644 --- a/clippy_lints/src/question_mark.rs +++ b/clippy_lints/src/question_mark.rs @@ -88,7 +88,7 @@ impl QuestionMark { "replace it with", replacement_str, applicability, - ); + ) } } } diff --git a/clippy_lints/src/redundant_closure_call.rs b/clippy_lints/src/redundant_closure_call.rs index daea1592018..f398b3fff25 100644 --- a/clippy_lints/src/redundant_closure_call.rs +++ b/clippy_lints/src/redundant_closure_call.rs @@ -56,7 +56,7 @@ impl<'ast> ast_visit::Visitor<'ast> for ReturnVisitor { self.found_return = true; } - ast_visit::walk_expr(self, ex); + ast_visit::walk_expr(self, ex) } } diff --git a/clippy_lints/src/redundant_pub_crate.rs b/clippy_lints/src/redundant_pub_crate.rs index 127f6078dab..acd9047ace6 100644 --- a/clippy_lints/src/redundant_pub_crate.rs +++ b/clippy_lints/src/redundant_pub_crate.rs @@ -60,7 +60,7 @@ impl<'tcx> LateLintPass<'tcx> for RedundantPubCrate { Applicability::MachineApplicable, ); }, - ); + ) } } } diff --git a/clippy_lints/src/returns.rs b/clippy_lints/src/returns.rs index e7b66c5ebcf..e438f92b136 100644 --- a/clippy_lints/src/returns.rs +++ b/clippy_lints/src/returns.rs @@ -139,7 +139,7 @@ impl<'tcx> LateLintPass<'tcx> for Return { } else { RetReplacement::Empty }; - check_final_expr(cx, &body.value, Some(body.value.span), replacement); + check_final_expr(cx, &body.value, Some(body.value.span), replacement) }, FnKind::ItemFn(..) | FnKind::Method(..) => { if let ExprKind::Block(ref block, _) = body.value.kind { @@ -239,7 +239,7 @@ fn emit_return_lint(cx: &LateContext<'_>, ret_span: Span, inner_span: Option match replacement { RetReplacement::Empty => { diff --git a/clippy_lints/src/semicolon_if_nothing_returned.rs b/clippy_lints/src/semicolon_if_nothing_returned.rs index f47ca1b69b1..22cd10ced18 100644 --- a/clippy_lints/src/semicolon_if_nothing_returned.rs +++ b/clippy_lints/src/semicolon_if_nothing_returned.rs @@ -1,7 +1,7 @@ -use crate::utils::{in_macro, span_lint_and_sugg, sugg}; +use crate::utils::{in_macro, span_lint_and_then, sugg}; use if_chain::if_chain; use rustc_errors::Applicability; -use rustc_hir::{Block, ExprKind}; +use rustc_hir::*; use rustc_lint::{LateContext, LateLintPass}; use rustc_session::{declare_lint_pass, declare_tool_lint}; @@ -42,25 +42,31 @@ impl LateLintPass<'_> for SemicolonIfNothingReturned { if let Some(expr) = block.expr; let t_expr = cx.typeck_results().expr_ty(expr); if t_expr.is_unit(); - if let Ok(snippet) = cx.tcx.sess.source_map().span_to_snippet(expr.span.source_callsite()); - if !snippet.ends_with('}'); then { - // filter out the desugared `for` loop - if let ExprKind::DropTemps(..) = &expr.kind { - return; + match expr.kind { + ExprKind::Loop(..) | + ExprKind::Match(..) | + ExprKind::Block(..) | + ExprKind::If(..) if !in_macro(expr.span) => return, + _ => (), } let sugg = sugg::Sugg::hir(cx, &expr, ".."); let suggestion = format!("{0};", sugg); - span_lint_and_sugg( + span_lint_and_then( cx, SEMICOLON_IF_NOTHING_RETURNED, expr.span, - "Consider adding a `;` to the last statement for consistent formatting", - "add a `;` here", - suggestion, - Applicability::MaybeIncorrect, - ); + "add `;` to terminate block", + | diag | { + diag.span_suggestion( + expr.span, + "add `;`", + suggestion, + Applicability::MaybeIncorrect, + ); + } + ) } } } diff --git a/clippy_lints/src/shadow.rs b/clippy_lints/src/shadow.rs index 3af98632712..d5b1767e945 100644 --- a/clippy_lints/src/shadow.rs +++ b/clippy_lints/src/shadow.rs @@ -118,7 +118,7 @@ fn check_fn<'tcx>(cx: &LateContext<'tcx>, decl: &'tcx FnDecl<'_>, body: &'tcx Bo let mut bindings = Vec::with_capacity(decl.inputs.len()); for arg in iter_input_pats(decl, body) { if let PatKind::Binding(.., ident, _) = arg.pat.kind { - bindings.push((ident.name, ident.span)); + bindings.push((ident.name, ident.span)) } } check_expr(cx, &body.value, &mut bindings); @@ -154,7 +154,7 @@ fn check_local<'tcx>(cx: &LateContext<'tcx>, local: &'tcx Local<'_>, bindings: & .. } = *local; if let Some(ref t) = *ty { - check_ty(cx, t, bindings); + check_ty(cx, t, bindings) } if let Some(ref o) = *init { check_expr(cx, o, bindings); @@ -330,7 +330,7 @@ fn check_expr<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>, bindings: &mut // ExprKind::MethodCall ExprKind::Array(v) | ExprKind::Tup(v) => { for e in v { - check_expr(cx, e, bindings); + check_expr(cx, e, bindings) } }, ExprKind::If(ref cond, ref then, ref otherwise) => { @@ -371,11 +371,11 @@ fn check_ty<'tcx>(cx: &LateContext<'tcx>, ty: &'tcx Ty<'_>, bindings: &mut Vec<( check_expr(cx, &cx.tcx.hir().body(anon_const.body).value, bindings); }, TyKind::Ptr(MutTy { ty: ref mty, .. }) | TyKind::Rptr(_, MutTy { ty: ref mty, .. }) => { - check_ty(cx, mty, bindings); + check_ty(cx, mty, bindings) }, TyKind::Tup(tup) => { for t in tup { - check_ty(cx, t, bindings); + check_ty(cx, t, bindings) } }, TyKind::Typeof(ref anon_const) => check_expr(cx, &cx.tcx.hir().body(anon_const.body).value, bindings), diff --git a/clippy_lints/src/slow_vector_initialization.rs b/clippy_lints/src/slow_vector_initialization.rs index 9ba9b4187d2..96f6881556c 100644 --- a/clippy_lints/src/slow_vector_initialization.rs +++ b/clippy_lints/src/slow_vector_initialization.rs @@ -306,7 +306,7 @@ impl<'a, 'tcx> Visitor<'tcx> for VectorInitializationVisitor<'a, 'tcx> { fn visit_block(&mut self, block: &'tcx Block<'_>) { if self.initialization_found { if let Some(ref s) = block.stmts.get(0) { - self.visit_stmt(s); + self.visit_stmt(s) } self.initialization_found = false; diff --git a/clippy_lints/src/suspicious_operation_groupings.rs b/clippy_lints/src/suspicious_operation_groupings.rs index f245789d75d..cccd24ccf94 100644 --- a/clippy_lints/src/suspicious_operation_groupings.rs +++ b/clippy_lints/src/suspicious_operation_groupings.rs @@ -265,7 +265,7 @@ fn emit_suggestion(cx: &EarlyContext<'_>, span: Span, sugg: String, applicabilit "I think you meant", sugg, applicability, - ); + ) } fn ident_swap_sugg( @@ -476,7 +476,7 @@ impl Add for IdentLocation { impl AddAssign for IdentLocation { fn add_assign(&mut self, other: Self) { - *self = *self + other; + *self = *self + other } } @@ -507,7 +507,7 @@ impl Add for IdentDifference { impl AddAssign for IdentDifference { fn add_assign(&mut self, other: Self) { - *self = *self + other; + *self = *self + other } } diff --git a/clippy_lints/src/transmute.rs b/clippy_lints/src/transmute.rs index e619a1a698a..d977cea4da5 100644 --- a/clippy_lints/src/transmute.rs +++ b/clippy_lints/src/transmute.rs @@ -463,7 +463,7 @@ impl<'tcx> LateLintPass<'tcx> for Transmute { Applicability::Unspecified, ); }, - ); + ) }, (ty::Ref(_, ty_from, from_mutbl), ty::Ref(_, ty_to, to_mutbl)) => { if_chain! { @@ -519,7 +519,7 @@ impl<'tcx> LateLintPass<'tcx> for Transmute { Applicability::Unspecified, ); }, - ); + ) } } } @@ -552,7 +552,7 @@ impl<'tcx> LateLintPass<'tcx> for Transmute { Applicability::Unspecified, ); }, - ); + ) }, (ty::Int(_) | ty::Uint(_), ty::Float(_)) if !const_context => span_lint_and_then( cx, diff --git a/clippy_lints/src/types.rs b/clippy_lints/src/types.rs index dd3e934889a..1b0f1e309aa 100644 --- a/clippy_lints/src/types.rs +++ b/clippy_lints/src/types.rs @@ -630,7 +630,7 @@ impl Types { TyKind::Rptr(ref lt, ref mut_ty) => self.check_ty_rptr(cx, hir_ty, is_local, lt, mut_ty), // recurse TyKind::Slice(ref ty) | TyKind::Array(ref ty, _) | TyKind::Ptr(MutTy { ref ty, .. }) => { - self.check_ty(cx, ty, is_local); + self.check_ty(cx, ty, is_local) }, TyKind::Tup(tys) => { for ty in tys { @@ -2436,7 +2436,7 @@ fn upcast_comparison_bounds_err<'tcx>( }, Rel::Eq | Rel::Ne => unreachable!(), } { - err_upcast_comparison(cx, span, lhs, true); + err_upcast_comparison(cx, span, lhs, true) } else if match rel { Rel::Lt => { if invert { @@ -2454,7 +2454,7 @@ fn upcast_comparison_bounds_err<'tcx>( }, Rel::Eq | Rel::Ne => unreachable!(), } { - err_upcast_comparison(cx, span, lhs, false); + err_upcast_comparison(cx, span, lhs, false) } } } diff --git a/clippy_lints/src/unicode.rs b/clippy_lints/src/unicode.rs index 9346e3c1d3b..93d59cc7fcd 100644 --- a/clippy_lints/src/unicode.rs +++ b/clippy_lints/src/unicode.rs @@ -69,7 +69,7 @@ impl LateLintPass<'_> for Unicode { fn check_expr(&mut self, cx: &LateContext<'_>, expr: &'_ Expr<'_>) { if let ExprKind::Lit(ref lit) = expr.kind { if let LitKind::Str(_, _) = lit.node { - check_str(cx, lit.span, expr.hir_id); + check_str(cx, lit.span, expr.hir_id) } } } @@ -80,7 +80,7 @@ fn escape>(s: T) -> String { for c in s { if c as u32 > 0x7F { for d in c.escape_unicode() { - result.push(d); + result.push(d) } } else { result.push(c); diff --git a/clippy_lints/src/unused_self.rs b/clippy_lints/src/unused_self.rs index 83ba9c897e0..5349c4f7eb8 100644 --- a/clippy_lints/src/unused_self.rs +++ b/clippy_lints/src/unused_self.rs @@ -94,7 +94,7 @@ impl<'a, 'tcx> Visitor<'tcx> for UnusedSelfVisitor<'a, 'tcx> { return; } if let Res::Local(hir_id) = &path.res { - self.uses_self = self.self_hir_id == hir_id; + self.uses_self = self.self_hir_id == hir_id } walk_path(self, path); } diff --git a/clippy_lints/src/upper_case_acronyms.rs b/clippy_lints/src/upper_case_acronyms.rs index 0f04a4a62ce..61e7031716a 100644 --- a/clippy_lints/src/upper_case_acronyms.rs +++ b/clippy_lints/src/upper_case_acronyms.rs @@ -69,7 +69,7 @@ fn check_ident(cx: &EarlyContext<'_>, ident: &Ident) { "consider making the acronym lowercase, except the initial letter", corrected, Applicability::MaybeIncorrect, - ); + ) } } diff --git a/clippy_lints/src/use_self.rs b/clippy_lints/src/use_self.rs index 4bbfb3fbeb1..72d1ca73929 100644 --- a/clippy_lints/src/use_self.rs +++ b/clippy_lints/src/use_self.rs @@ -103,7 +103,7 @@ impl<'a, 'tcx> Visitor<'tcx> for SemanticUseSelfVisitor<'a, 'tcx> { } } - walk_ty(self, hir_ty); + walk_ty(self, hir_ty) } fn nested_visit_map(&mut self) -> NestedVisitorMap { diff --git a/clippy_lints/src/utils/attrs.rs b/clippy_lints/src/utils/attrs.rs index 588c31ea40f..8d28421d70d 100644 --- a/clippy_lints/src/utils/attrs.rs +++ b/clippy_lints/src/utils/attrs.rs @@ -115,7 +115,7 @@ fn parse_attrs(sess: &Session, attrs: &[ast::Attribute], name: &' for attr in get_attr(sess, attrs, name) { if let Some(ref value) = attr.value_str() { if let Ok(value) = FromStr::from_str(&value.as_str()) { - f(value); + f(value) } else { sess.span_err(attr.span, "not a number"); } diff --git a/clippy_lints/src/utils/author.rs b/clippy_lints/src/utils/author.rs index b8c50112497..ca60d335262 100644 --- a/clippy_lints/src/utils/author.rs +++ b/clippy_lints/src/utils/author.rs @@ -293,7 +293,7 @@ impl<'tcx> Visitor<'tcx> for PrintVisitor { LitKind::Str(ref text, _) => { let str_pat = self.next("s"); println!(" if let LitKind::Str(ref {}, _) = {}.node;", str_pat, lit_pat); - println!(" if {}.as_str() == {:?}", str_pat, &*text.as_str()); + println!(" if {}.as_str() == {:?}", str_pat, &*text.as_str()) }, } }, diff --git a/clippy_lints/src/utils/diagnostics.rs b/clippy_lints/src/utils/diagnostics.rs index f74ce999b5c..269be217c2d 100644 --- a/clippy_lints/src/utils/diagnostics.rs +++ b/clippy_lints/src/utils/diagnostics.rs @@ -211,7 +211,7 @@ pub fn multispan_sugg(diag: &mut DiagnosticBuilder<'_>, help_msg: &str, sugg: where I: IntoIterator, { - multispan_sugg_with_applicability(diag, help_msg, Applicability::Unspecified, sugg); + multispan_sugg_with_applicability(diag, help_msg, Applicability::Unspecified, sugg) } pub fn multispan_sugg_with_applicability( diff --git a/clippy_lints/src/utils/mod.rs b/clippy_lints/src/utils/mod.rs index a519dce66d4..cf93ee0a7a5 100644 --- a/clippy_lints/src/utils/mod.rs +++ b/clippy_lints/src/utils/mod.rs @@ -464,7 +464,7 @@ pub fn method_chain_args<'a>(expr: &'a Expr<'_>, methods: &[&str]) -> Option DiagnosticBuilderExt for rustc_errors::DiagnosticBuilder if let Some(non_whitespace_offset) = non_whitespace_offset { remove_span = remove_span - .with_hi(remove_span.hi() + BytePos(non_whitespace_offset.try_into().expect("offset too large"))); + .with_hi(remove_span.hi() + BytePos(non_whitespace_offset.try_into().expect("offset too large"))) } } diff --git a/clippy_lints/src/utils/usage.rs b/clippy_lints/src/utils/usage.rs index 8bf169c0d06..fc0db7f64ec 100644 --- a/clippy_lints/src/utils/usage.rs +++ b/clippy_lints/src/utils/usage.rs @@ -60,7 +60,7 @@ impl<'tcx> MutVarsDelegate { //FIXME: This causes false negatives. We can't get the `NodeId` from //`Categorization::Upvar(_)`. So we search for any `Upvar`s in the //`while`-body, not just the ones in the condition. - self.skip = true; + self.skip = true }, _ => {}, } @@ -72,12 +72,12 @@ impl<'tcx> Delegate<'tcx> for MutVarsDelegate { fn borrow(&mut self, cmt: &PlaceWithHirId<'tcx>, _: HirId, bk: ty::BorrowKind) { if let ty::BorrowKind::MutBorrow = bk { - self.update(&cmt); + self.update(&cmt) } } fn mutate(&mut self, cmt: &PlaceWithHirId<'tcx>, _: HirId) { - self.update(&cmt); + self.update(&cmt) } } diff --git a/clippy_lints/src/utils/visitors.rs b/clippy_lints/src/utils/visitors.rs index caaf636c897..ebf69df31ca 100644 --- a/clippy_lints/src/utils/visitors.rs +++ b/clippy_lints/src/utils/visitors.rs @@ -87,7 +87,7 @@ where } fn visit_stmt(&mut self, stmt: &'hir hir::Stmt<'_>) { - intravisit::walk_stmt(&mut *self.inside_stmt(true), stmt); + intravisit::walk_stmt(&mut *self.inside_stmt(true), stmt) } fn visit_expr(&mut self, expr: &'hir hir::Expr<'_>) { diff --git a/clippy_lints/src/verbose_file_reads.rs b/clippy_lints/src/verbose_file_reads.rs index 92965e95cda..32574d9d6c9 100644 --- a/clippy_lints/src/verbose_file_reads.rs +++ b/clippy_lints/src/verbose_file_reads.rs @@ -52,7 +52,7 @@ impl<'tcx> LateLintPass<'tcx> for VerboseFileReads { "use of `File::read_to_string`", None, "consider using `fs::read_to_string` instead", - ); + ) } } } diff --git a/clippy_lints/src/write.rs b/clippy_lints/src/write.rs index f9ccf322dda..e40fdca6a99 100644 --- a/clippy_lints/src/write.rs +++ b/clippy_lints/src/write.rs @@ -298,7 +298,7 @@ impl EarlyLintPass for Write { Applicability::MachineApplicable, ); }, - ); + ) } } } else if mac.path == sym!(writeln) { diff --git a/tests/ui/semicolon_if_nothing_returned.rs b/tests/ui/semicolon_if_nothing_returned.rs index 0abe2cca267..2c07cc9df40 100644 --- a/tests/ui/semicolon_if_nothing_returned.rs +++ b/tests/ui/semicolon_if_nothing_returned.rs @@ -46,10 +46,3 @@ fn foobar(x: i32) { y = x + 1; } } - -fn loop_test(x: i32) { - let y: i32; - for &ext in &["stdout", "stderr", "fixed"] { - println!("{}", ext); - } -} diff --git a/tests/ui/semicolon_if_nothing_returned.stderr b/tests/ui/semicolon_if_nothing_returned.stderr index 2bc73342467..6026320f4b4 100644 --- a/tests/ui/semicolon_if_nothing_returned.stderr +++ b/tests/ui/semicolon_if_nothing_returned.stderr @@ -1,4 +1,4 @@ -error: Consider adding a `;` to the last statement for consistent formatting +error: add `;` to terminate block --> $DIR/semicolon_if_nothing_returned.rs:8:5 | LL | println!("Hello") @@ -7,17 +7,17 @@ LL | println!("Hello") = note: `-D clippy::semicolon-if-nothing-returned` implied by `-D warnings` = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) -error: Consider adding a `;` to the last statement for consistent formatting +error: add `;` to terminate block --> $DIR/semicolon_if_nothing_returned.rs:12:5 | LL | get_unit() - | ^^^^^^^^^^ help: add a `;` here: `get_unit();` + | ^^^^^^^^^^ help: add `;`: `get_unit();` -error: Consider adding a `;` to the last statement for consistent formatting +error: add `;` to terminate block --> $DIR/semicolon_if_nothing_returned.rs:17:5 | LL | y = x + 1 - | ^^^^^^^^^ help: add a `;` here: `y = x + 1;` + | ^^^^^^^^^ help: add `;`: `y = x + 1;` error: aborting due to 3 previous errors