diff --git a/clippy_lints/src/bit_mask.rs b/clippy_lints/src/bit_mask.rs index 52c6d4c71dcf..d33bf670f6f5 100644 --- a/clippy_lints/src/bit_mask.rs +++ b/clippy_lints/src/bit_mask.rs @@ -144,7 +144,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for BitMask { "try", format!("{}.trailing_zeros() >= {}", sugg, n.count_ones()), Applicability::Unspecified, - ); + ); }); } } diff --git a/clippy_lints/src/booleans.rs b/clippy_lints/src/booleans.rs index c00256842b6c..604e27f56ee4 100644 --- a/clippy_lints/src/booleans.rs +++ b/clippy_lints/src/booleans.rs @@ -418,12 +418,14 @@ impl<'a, 'tcx> NonminimalBoolVisitor<'a, 'tcx> { NONMINIMAL_BOOL, e.span, "this boolean expression can be simplified", - |db| { db.span_suggestions_with_applicability( + |db| { + db.span_suggestions_with_applicability( e.span, "try", suggestions, Applicability::Unspecified, - ); }, + ); + }, ); }; if improvements.is_empty() { diff --git a/clippy_lints/src/collapsible_if.rs b/clippy_lints/src/collapsible_if.rs index c139b0f0c1f1..dcc0f65e3fc6 100644 --- a/clippy_lints/src/collapsible_if.rs +++ b/clippy_lints/src/collapsible_if.rs @@ -134,13 +134,16 @@ fn check_collapsible_no_if_let(cx: &EarlyContext<'_>, expr: &ast::Expr, check: & span_lint_and_then(cx, COLLAPSIBLE_IF, expr.span, "this if statement can be collapsed", |db| { let lhs = Sugg::ast(cx, check, ".."); let rhs = Sugg::ast(cx, check_inner, ".."); - db.span_suggestion_with_applicability(expr.span, - "try", - format!("if {} {}", - lhs.and(&rhs), - snippet_block(cx, content.span, "..")), - Applicability::Unspecified, - ); + db.span_suggestion_with_applicability( + expr.span, + "try", + format!( + "if {} {}", + lhs.and(&rhs), + snippet_block(cx, content.span, ".."), + ), + Applicability::Unspecified, + ); }); } } diff --git a/clippy_lints/src/const_static_lifetime.rs b/clippy_lints/src/const_static_lifetime.rs index 92c609d9858d..4edc84c9d092 100644 --- a/clippy_lints/src/const_static_lifetime.rs +++ b/clippy_lints/src/const_static_lifetime.rs @@ -66,7 +66,7 @@ impl StaticConst { "consider removing `'static`", sugg, Applicability::Unspecified, - ); + ); }, ); } diff --git a/clippy_lints/src/entry.rs b/clippy_lints/src/entry.rs index be9af18c9112..71203a247bfe 100644 --- a/clippy_lints/src/entry.rs +++ b/clippy_lints/src/entry.rs @@ -141,11 +141,11 @@ impl<'a, 'tcx, 'b> Visitor<'tcx> for InsertVisitor<'a, 'tcx, 'b> { snippet(self.cx, params[2].span, "..")); db.span_suggestion_with_applicability( - self.span, - "consider using", - help, - Applicability::Unspecified, - ); + self.span, + "consider using", + help, + Applicability::Unspecified, + ); } else { let help = format!("{}.entry({})", @@ -153,11 +153,11 @@ impl<'a, 'tcx, 'b> Visitor<'tcx> for InsertVisitor<'a, 'tcx, 'b> { snippet(self.cx, params[1].span, "..")); db.span_suggestion_with_applicability( - self.span, - "consider using", - help, - Applicability::Unspecified, - ); + self.span, + "consider using", + help, + Applicability::Unspecified, + ); } }); } diff --git a/clippy_lints/src/eq_op.rs b/clippy_lints/src/eq_op.rs index 2ad04cd6fbe2..f71472653bfa 100644 --- a/clippy_lints/src/eq_op.rs +++ b/clippy_lints/src/eq_op.rs @@ -115,11 +115,11 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for EqOp { span_lint_and_then(cx, OP_REF, e.span, "needlessly taken reference of left operand", |db| { let lsnip = snippet(cx, l.span, "...").to_string(); db.span_suggestion_with_applicability( - left.span, - "use the left value directly", - lsnip, - Applicability::Unspecified, - ); + left.span, + "use the left value directly", + lsnip, + Applicability::Unspecified, + ); }) } else if !lcpy && rcpy && implements_trait(cx, cx.tables.expr_ty(left), trait_id, &[rty.into()]) { span_lint_and_then( @@ -133,7 +133,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for EqOp { right.span, "use the right value directly", rsnip, - Applicability::Unspecified,); + Applicability::Unspecified, + ); }, ) } @@ -146,11 +147,11 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for EqOp { span_lint_and_then(cx, OP_REF, e.span, "needlessly taken reference of left operand", |db| { let lsnip = snippet(cx, l.span, "...").to_string(); db.span_suggestion_with_applicability( - left.span, - "use the left value directly", - lsnip, - Applicability::Unspecified, - ); + left.span, + "use the left value directly", + lsnip, + Applicability::Unspecified, + ); }) } }, @@ -162,11 +163,11 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for EqOp { span_lint_and_then(cx, OP_REF, e.span, "taken reference of right operand", |db| { let rsnip = snippet(cx, r.span, "...").to_string(); db.span_suggestion_with_applicability( - right.span, - "use the right value directly", - rsnip, - Applicability::Unspecified, - ); + right.span, + "use the right value directly", + rsnip, + Applicability::Unspecified, + ); }) } }, diff --git a/clippy_lints/src/eta_reduction.rs b/clippy_lints/src/eta_reduction.rs index b40ff8b51cd1..f18358121d65 100644 --- a/clippy_lints/src/eta_reduction.rs +++ b/clippy_lints/src/eta_reduction.rs @@ -98,11 +98,11 @@ fn check_closure(cx: &LateContext<'_, '_>, expr: &Expr) { span_lint_and_then(cx, REDUNDANT_CLOSURE, expr.span, "redundant closure found", |db| { if let Some(snippet) = snippet_opt(cx, caller.span) { db.span_suggestion_with_applicability( - expr.span, - "remove closure as shown", - snippet, - Applicability::Unspecified, - ); + expr.span, + "remove closure as shown", + snippet, + Applicability::Unspecified, + ); } }); } diff --git a/clippy_lints/src/format.rs b/clippy_lints/src/format.rs index 868b7c19cef1..29dca4556a5d 100644 --- a/clippy_lints/src/format.rs +++ b/clippy_lints/src/format.rs @@ -62,11 +62,11 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass { let sugg = format!("{}.to_string()", snippet(cx, format_arg, "").into_owned()); span_lint_and_then(cx, USELESS_FORMAT, span, "useless use of `format!`", |db| { db.span_suggestion_with_applicability( - expr.span, - "consider using .to_string()", - sugg, - Applicability::Unspecified, - ); + expr.span, + "consider using .to_string()", + sugg, + Applicability::Unspecified, + ); }); } } @@ -77,11 +77,11 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass { let sugg = format!("{}.to_string()", snippet(cx, expr.span, "").into_owned()); span_lint_and_then(cx, USELESS_FORMAT, span, "useless use of `format!`", |db| { db.span_suggestion_with_applicability( - span, - "consider using .to_string()", - sugg, - Applicability::Unspecified, - ); + span, + "consider using .to_string()", + sugg, + Applicability::Unspecified, + ); }); } }, diff --git a/clippy_lints/src/identity_conversion.rs b/clippy_lints/src/identity_conversion.rs index 2a764ad73d47..411d7511d882 100644 --- a/clippy_lints/src/identity_conversion.rs +++ b/clippy_lints/src/identity_conversion.rs @@ -65,11 +65,11 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for IdentityConversion { let sugg = snippet(cx, args[0].span, "").into_owned(); span_lint_and_then(cx, IDENTITY_CONVERSION, e.span, "identical conversion", |db| { db.span_suggestion_with_applicability( - e.span, - "consider removing `.into()`", - sugg, - Applicability::Unspecified, - ); + e.span, + "consider removing `.into()`", + sugg, + Applicability::Unspecified, + ); }); } } @@ -80,11 +80,11 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for IdentityConversion { let sugg = snippet(cx, args[0].span, "").into_owned(); span_lint_and_then(cx, IDENTITY_CONVERSION, e.span, "identical conversion", |db| { db.span_suggestion_with_applicability( - e.span, - "consider removing `.into_iter()`", - sugg, - Applicability::Unspecified, - ); + e.span, + "consider removing `.into_iter()`", + sugg, + Applicability::Unspecified, + ); }); } } @@ -100,11 +100,11 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for IdentityConversion { let sugg_msg = format!("consider removing `{}()`", snippet(cx, path.span, "From::from")); span_lint_and_then(cx, IDENTITY_CONVERSION, e.span, "identical conversion", |db| { db.span_suggestion_with_applicability( - e.span, - &sugg_msg, - sugg, - Applicability::Unspecified, - ); + e.span, + &sugg_msg, + sugg, + Applicability::Unspecified, + ); }); } } diff --git a/clippy_lints/src/int_plus_one.rs b/clippy_lints/src/int_plus_one.rs index 4608ca696e1e..14566c4f02db 100644 --- a/clippy_lints/src/int_plus_one.rs +++ b/clippy_lints/src/int_plus_one.rs @@ -154,11 +154,11 @@ impl IntPlusOne { fn emit_warning(&self, cx: &EarlyContext<'_>, block: &Expr, recommendation: String) { span_lint_and_then(cx, INT_PLUS_ONE, block.span, "Unnecessary `>= y + 1` or `x - 1 >=`", |db| { db.span_suggestion_with_applicability( - block.span, - "change `>= y + 1` to `> y` as shown", - recommendation, - Applicability::Unspecified, - ); + block.span, + "change `>= y + 1` to `> y` as shown", + recommendation, + Applicability::Unspecified, + ); }); } } diff --git a/clippy_lints/src/let_if_seq.rs b/clippy_lints/src/let_if_seq.rs index 4947715e293d..bdeaeda7bc5d 100644 --- a/clippy_lints/src/let_if_seq.rs +++ b/clippy_lints/src/let_if_seq.rs @@ -122,11 +122,11 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for LetIfSeq { "`if _ { .. } else { .. }` is an expression", |db| { db.span_suggestion_with_applicability( - span, - "it is more idiomatic to write", - sug, - Applicability::Unspecified, - ); + span, + "it is more idiomatic to write", + sug, + Applicability::Unspecified, + ); if !mutability.is_empty() { db.note("you might not need `mut` at all"); } diff --git a/clippy_lints/src/map_unit_fn.rs b/clippy_lints/src/map_unit_fn.rs index 5f592a722d1d..f4d48e3ad9ad 100644 --- a/clippy_lints/src/map_unit_fn.rs +++ b/clippy_lints/src/map_unit_fn.rs @@ -229,20 +229,22 @@ fn lint_map_unit_fn(cx: &LateContext<'_, '_>, stmt: &hir::Stmt, expr: &hir::Expr snippet(cx, var_arg.span, "_"), snippet(cx, reduced_expr_span, "_")); db.span_suggestion_with_applicability( - stmt.span, - "try this", - suggestion, - Applicability::Unspecified, - ); + stmt.span, + "try this", + suggestion, + Applicability::Unspecified, + ); } else { let suggestion = format!("if let {0}({1}) = {2} {{ ... }}", variant, snippet(cx, binding.pat.span, "_"), snippet(cx, var_arg.span, "_")); - db.span_suggestion_with_applicability(stmt.span, - "try this", - suggestion, - Applicability::Unspecified); + db.span_suggestion_with_applicability( + stmt.span, + "try this", + suggestion, + Applicability::Unspecified, + ); } }); } diff --git a/clippy_lints/src/matches.rs b/clippy_lints/src/matches.rs index 7cc70cb0834b..d8e11d684795 100644 --- a/clippy_lints/src/matches.rs +++ b/clippy_lints/src/matches.rs @@ -341,11 +341,11 @@ fn check_match_bool(cx: &LateContext<'_, '_>, ex: &Expr, arms: &[Arm], expr: &Ex if let Some(sugg) = sugg { db.span_suggestion_with_applicability( - expr.span, - "consider using an if/else expression", - sugg, - Applicability::Unspecified, - ); + expr.span, + "consider using an if/else expression", + sugg, + Applicability::Unspecified, + ); } } } diff --git a/clippy_lints/src/methods.rs b/clippy_lints/src/methods.rs index f61995cf2650..5f8dc63ea573 100644 --- a/clippy_lints/src/methods.rs +++ b/clippy_lints/src/methods.rs @@ -1129,17 +1129,17 @@ fn lint_clone_on_copy(cx: &LateContext<'_, '_>, expr: &hir::Expr, arg: &hir::Exp let derefs: String = iter::repeat('*').take(n).collect(); let explicit = format!("{}{}::clone({})", refs, ty, snip); db.span_suggestion_with_applicability( - expr.span, - "try dereferencing it", - format!("{}({}{}).clone()", refs, derefs, snip.deref()), - Applicability::Unspecified, - ); + expr.span, + "try dereferencing it", + format!("{}({}{}).clone()", refs, derefs, snip.deref()), + Applicability::Unspecified, + ); db.span_suggestion_with_applicability( - expr.span, - "or try being explicit about what type to clone", - explicit, - Applicability::Unspecified, - ); + expr.span, + "or try being explicit about what type to clone", + explicit, + Applicability::Unspecified, + ); }, ); return; // don't report clone_on_copy @@ -1185,7 +1185,7 @@ fn lint_clone_on_copy(cx: &LateContext<'_, '_>, expr: &hir::Expr, arg: &hir::Exp text, snip, Applicability::Unspecified, - ); + ); } }); } @@ -1656,11 +1656,11 @@ fn lint_map_or_none<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, expr: &'tcx hir::Expr, let hint = format!("{0}.and_then({1})", map_or_self_snippet, map_or_func_snippet); span_lint_and_then(cx, OPTION_MAP_OR_NONE, expr.span, msg, |db| { db.span_suggestion_with_applicability( - expr.span, - "try using and_then instead", - hint, - Applicability::Unspecified, - ); + expr.span, + "try using and_then instead", + hint, + Applicability::Unspecified, + ); }); } } diff --git a/clippy_lints/src/misc.rs b/clippy_lints/src/misc.rs index ac4e93f633a2..0f0c86bfeb26 100644 --- a/clippy_lints/src/misc.rs +++ b/clippy_lints/src/misc.rs @@ -295,14 +295,17 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass { l.pat.span, "`ref` on an entire `let` pattern is discouraged, take a reference with `&` instead", |db| { - db.span_suggestion_with_applicability(s.span, - "try", - format!("let {name}{tyopt} = {initref};", - name=snippet(cx, i.span, "_"), - tyopt=tyopt, - initref=initref), - Applicability::Unspecified, - ); + db.span_suggestion_with_applicability( + s.span, + "try", + format!( + "let {name}{tyopt} = {initref};", + name=snippet(cx, i.span, "_"), + tyopt=tyopt, + initref=initref, + ), + Applicability::Unspecified, + ); } ); } @@ -321,13 +324,15 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass { |db| { let sugg = if binop.node == BinOpKind::Or { !sugg } else { sugg }; db.span_suggestion_with_applicability( - s.span, - "replace it with", - format!("if {} {{ {}; }}", - sugg, - &snippet(cx, b.span, "..")), - Applicability::Unspecified, - ); + s.span, + "replace it with", + format!( + "if {} {{ {}; }}", + sugg, + &snippet(cx, b.span, ".."), + ), + Applicability::Unspecified, + ); }); } }; @@ -545,11 +550,11 @@ fn check_to_owned(cx: &LateContext<'_, '_>, expr: &Expr, other: &Expr) { } } db.span_suggestion_with_applicability( - expr.span, - "try", - snip.to_string(), - Applicability::Unspecified, - ); + expr.span, + "try", + snip.to_string(), + Applicability::Unspecified, + ); }, ); } diff --git a/clippy_lints/src/misc_early.rs b/clippy_lints/src/misc_early.rs index c66fb5d6e47f..07c363d6f246 100644 --- a/clippy_lints/src/misc_early.rs +++ b/clippy_lints/src/misc_early.rs @@ -309,11 +309,11 @@ impl EarlyLintPass for MiscEarly { |db| if decl.inputs.is_empty() { let hint = snippet(cx, block.span, "..").into_owned(); db.span_suggestion_with_applicability( - expr.span, - "Try doing something like: ", - hint, - Applicability::Unspecified, - ); + expr.span, + "Try doing something like: ", + hint, + Applicability::Unspecified, + ); }, ); } diff --git a/clippy_lints/src/needless_borrow.rs b/clippy_lints/src/needless_borrow.rs index 11e1a99fd7fc..1e0db1a0f9ae 100644 --- a/clippy_lints/src/needless_borrow.rs +++ b/clippy_lints/src/needless_borrow.rs @@ -77,11 +77,11 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NeedlessBorrow { |db| { if let Some(snippet) = snippet_opt(cx, inner.span) { db.span_suggestion_with_applicability( - e.span, - "change this to", - snippet, - Applicability::Unspecified, - ); + e.span, + "change this to", + snippet, + Applicability::Unspecified, + ); } }, ); @@ -110,11 +110,11 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NeedlessBorrow { |db| { if let Some(snippet) = snippet_opt(cx, name.span) { db.span_suggestion_with_applicability( - pat.span, - "change this to", - snippet, - Applicability::Unspecified, - ); + pat.span, + "change this to", + snippet, + Applicability::Unspecified, + ); } } ) diff --git a/clippy_lints/src/needless_borrowed_ref.rs b/clippy_lints/src/needless_borrowed_ref.rs index 08ce0de21c6f..fd275752506c 100644 --- a/clippy_lints/src/needless_borrowed_ref.rs +++ b/clippy_lints/src/needless_borrowed_ref.rs @@ -79,11 +79,11 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NeedlessBorrowedRef { |db| { let hint = snippet(cx, spanned_name.span, "..").into_owned(); db.span_suggestion_with_applicability( - pat.span, - "try removing the `&ref` part and just keep", - hint, - Applicability::Unspecified, - ); + pat.span, + "try removing the `&ref` part and just keep", + hint, + Applicability::Unspecified, + ); }); } } diff --git a/clippy_lints/src/needless_pass_by_value.rs b/clippy_lints/src/needless_pass_by_value.rs index aa644e4c3398..980e2c28a348 100644 --- a/clippy_lints/src/needless_pass_by_value.rs +++ b/clippy_lints/src/needless_pass_by_value.rs @@ -229,11 +229,11 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NeedlessPassByValue { then { let slice_ty = format!("&[{}]", snippet(cx, elem_ty.span, "_")); db.span_suggestion_with_applicability( - input.span, - "consider changing the type to", - slice_ty, - Applicability::Unspecified, - ); + input.span, + "consider changing the type to", + slice_ty, + Applicability::Unspecified, + ); for (span, suggestion) in clone_spans { db.span_suggestion_with_applicability( @@ -258,11 +258,11 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NeedlessPassByValue { if let Some(clone_spans) = get_spans(cx, Some(body.id()), idx, &[("clone", ".to_string()"), ("as_str", "")]) { db.span_suggestion_with_applicability( - input.span, - "consider changing the type to", - "&str".to_string(), - Applicability::Unspecified, - ); + input.span, + "consider changing the type to", + "&str".to_string(), + Applicability::Unspecified, + ); for (span, suggestion) in clone_spans { db.span_suggestion_with_applicability( diff --git a/clippy_lints/src/new_without_default.rs b/clippy_lints/src/new_without_default.rs index 0163849dd229..bf5fbb8a7f5b 100644 --- a/clippy_lints/src/new_without_default.rs +++ b/clippy_lints/src/new_without_default.rs @@ -131,12 +131,12 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NewWithoutDefault { &format!("you should consider deriving a `Default` implementation for `{}`", self_ty), |db| { db.suggest_item_with_attr( - cx, - sp, - "try this", - "#[derive(Default)]", - Applicability::Unspecified, - ); + cx, + sp, + "try this", + "#[derive(Default)]", + Applicability::Unspecified, + ); }); } else { span_lint_and_then( diff --git a/clippy_lints/src/ptr.rs b/clippy_lints/src/ptr.rs index f8d872cb4e6d..86cb89f2de12 100644 --- a/clippy_lints/src/ptr.rs +++ b/clippy_lints/src/ptr.rs @@ -212,11 +212,11 @@ fn check_fn(cx: &LateContext<'_, '_>, decl: &FnDecl, fn_id: NodeId, opt_body_id: "writing `&String` instead of `&str` involves a new object where a slice will do.", |db| { db.span_suggestion_with_applicability( - arg.span, - "change this to", - "&str".into(), - Applicability::Unspecified, - ); + arg.span, + "change this to", + "&str".into(), + Applicability::Unspecified, + ); for (clonespan, suggestion) in spans { db.span_suggestion_short_with_applicability( clonespan, @@ -253,11 +253,11 @@ fn check_fn(cx: &LateContext<'_, '_>, decl: &FnDecl, fn_id: NodeId, opt_body_id: "using a reference to `Cow` is not recommended.", |db| { db.span_suggestion_with_applicability( - arg.span, - "change this to", - "&".to_owned() + &r, - Applicability::Unspecified, - ); + arg.span, + "change this to", + "&".to_owned() + &r, + Applicability::Unspecified, + ); }, ); } diff --git a/clippy_lints/src/ranges.rs b/clippy_lints/src/ranges.rs index 8ca0750684e1..71b68d97e401 100644 --- a/clippy_lints/src/ranges.rs +++ b/clippy_lints/src/ranges.rs @@ -151,17 +151,19 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass { let end = Sugg::hir(cx, y, "y"); if let Some(is_wrapped) = &snippet_opt(cx, expr.span) { if is_wrapped.starts_with('(') && is_wrapped.ends_with(')') { - db.span_suggestion_with_applicability(expr.span, - "use", - format!("({}..={})", start, end), - Applicability::Unspecified, - ); + db.span_suggestion_with_applicability( + expr.span, + "use", + format!("({}..={})", start, end), + Applicability::Unspecified, + ); } else { - db.span_suggestion_with_applicability(expr.span, - "use", - format!("{}..={}", start, end), - Applicability::Unspecified, - ); + db.span_suggestion_with_applicability( + expr.span, + "use", + format!("{}..={}", start, end), + Applicability::Unspecified, + ); } } }, @@ -182,11 +184,12 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass { |db| { let start = start.map_or(String::new(), |x| Sugg::hir(cx, x, "x").to_string()); let end = Sugg::hir(cx, y, "y"); - db.span_suggestion_with_applicability(expr.span, - "use", - format!("{}..{}", start, end), - Applicability::Unspecified, - ); + db.span_suggestion_with_applicability( + expr.span, + "use", + format!("{}..{}", start, end), + Applicability::Unspecified, + ); }, ); } diff --git a/clippy_lints/src/returns.rs b/clippy_lints/src/returns.rs index 34b7614e4396..f90d8659dbe8 100644 --- a/clippy_lints/src/returns.rs +++ b/clippy_lints/src/returns.rs @@ -110,11 +110,11 @@ impl ReturnPass { span_lint_and_then(cx, NEEDLESS_RETURN, ret_span, "unneeded return statement", |db| { if let Some(snippet) = snippet_opt(cx, inner_span) { db.span_suggestion_with_applicability( - ret_span, - "remove `return` as shown", - snippet, - Applicability::Unspecified, - ); + ret_span, + "remove `return` as shown", + snippet, + Applicability::Unspecified, + ); } }); } diff --git a/clippy_lints/src/swap.rs b/clippy_lints/src/swap.rs index 8859d5451946..5ca78957f08e 100644 --- a/clippy_lints/src/swap.rs +++ b/clippy_lints/src/swap.rs @@ -138,11 +138,11 @@ fn check_manual_swap(cx: &LateContext<'_, '_>, block: &Block) { |db| { if !sugg.is_empty() { db.span_suggestion_with_applicability( - span, - "try", - sugg, - Applicability::Unspecified, - ); + span, + "try", + sugg, + Applicability::Unspecified, + ); if replace { db.note("or maybe you should use `std::mem::replace`?"); @@ -187,13 +187,15 @@ fn check_suspicious_swap(cx: &LateContext<'_, '_>, block: &Block) { |db| { if !what.is_empty() { db.span_suggestion_with_applicability( - span, - "try", - format!("std::mem::swap({}, {})", - lhs, - rhs), - Applicability::Unspecified, - ); + span, + "try", + format!( + "std::mem::swap({}, {})", + lhs, + rhs, + ), + Applicability::Unspecified, + ); db.note("or maybe you should use `std::mem::replace`?"); } }); diff --git a/clippy_lints/src/transmute.rs b/clippy_lints/src/transmute.rs index cdd0260b4fee..69422056df5e 100644 --- a/clippy_lints/src/transmute.rs +++ b/clippy_lints/src/transmute.rs @@ -247,11 +247,11 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Transmute { }; db.span_suggestion_with_applicability( - e.span, - "try", - sugg.to_string(), - Applicability::Unspecified, - ); + e.span, + "try", + sugg.to_string(), + Applicability::Unspecified, + ); }, ), (&ty::Int(_), &ty::RawPtr(_)) | (&ty::Uint(_), &ty::RawPtr(_)) => { @@ -262,11 +262,11 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Transmute { "transmute from an integer to a pointer", |db| if let Some(arg) = sugg::Sugg::hir_opt(cx, &args[0]) { db.span_suggestion_with_applicability( - e.span, - "try", - arg.as_ty(&to_ty.to_string()).to_string(), - Applicability::Unspecified, - ); + e.span, + "try", + arg.as_ty(&to_ty.to_string()).to_string(), + Applicability::Unspecified, + ); }, ) }, @@ -324,11 +324,11 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Transmute { }; db.span_suggestion_with_applicability( - e.span, - "try", - sugg::make_unop(deref, arg).to_string(), - Applicability::Unspecified, - ); + e.span, + "try", + sugg::make_unop(deref, arg).to_string(), + Applicability::Unspecified, + ); }, ), (&ty::Int(ast::IntTy::I32), &ty::Char) | @@ -399,11 +399,11 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Transmute { sugg_paren.addr_deref() }; db.span_suggestion_with_applicability( - e.span, - "try", - sugg.to_string(), - Applicability::Unspecified, - ); + e.span, + "try", + sugg.to_string(), + Applicability::Unspecified, + ); }, ) } @@ -418,11 +418,11 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Transmute { |db| if let Some(arg) = sugg::Sugg::hir_opt(cx, &args[0]) { let sugg = arg.as_ty(cx.tcx.mk_ptr(to_ty)); db.span_suggestion_with_applicability( - e.span, - "try", - sugg.to_string(), - Applicability::Unspecified, - ); + e.span, + "try", + sugg.to_string(), + Applicability::Unspecified, + ); }, ), (&ty::Int(ast::IntTy::I8), &ty::Bool) | (&ty::Uint(ast::UintTy::U8), &ty::Bool) => { diff --git a/clippy_lints/src/utils/sugg.rs b/clippy_lints/src/utils/sugg.rs index 0cdfd623f45e..076907e49452 100644 --- a/clippy_lints/src/utils/sugg.rs +++ b/clippy_lints/src/utils/sugg.rs @@ -546,10 +546,10 @@ impl<'a, 'b, 'c, T: LintContext<'c>> DiagnosticBuilderExt<'c, T> for rustc_error } self.span_suggestion_with_applicability( - remove_span, - msg, - String::new(), - applicability, - ); + remove_span, + msg, + String::new(), + applicability, + ); } }