From 3a96d6b603b0a55fa14bb91d23c080725a257c04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Kr=C3=BCger?= Date: Sun, 27 Jan 2019 13:33:56 +0100 Subject: [PATCH] rustup https://github.com/rust-lang/rust/pull/57907/ for file in `fd \.rs$` ; do sed -i s/span_suggestion_with_applicability/span_suggestion/g $file ; done for file in `fd \.rs$` ; do sed -i s/span_suggestion_short_with_applicability/span_suggestion_short/g $file ; done for file in `fd \.rs$` ; do sed -i s/span_suggestions_with_applicability/span_suggestions/g $file ; done --- clippy_lints/src/assign_ops.rs | 6 +++--- clippy_lints/src/attrs.rs | 4 ++-- clippy_lints/src/bit_mask.rs | 2 +- clippy_lints/src/booleans.rs | 4 ++-- clippy_lints/src/collapsible_if.rs | 2 +- clippy_lints/src/const_static_lifetime.rs | 2 +- clippy_lints/src/copies.rs | 2 +- clippy_lints/src/entry.rs | 4 ++-- clippy_lints/src/eq_op.rs | 8 ++++---- clippy_lints/src/eta_reduction.rs | 2 +- clippy_lints/src/format.rs | 4 ++-- clippy_lints/src/identity_conversion.rs | 6 +++--- clippy_lints/src/implicit_return.rs | 2 +- clippy_lints/src/int_plus_one.rs | 2 +- clippy_lints/src/large_enum_variant.rs | 2 +- clippy_lints/src/let_if_seq.rs | 2 +- clippy_lints/src/loops.rs | 8 ++++---- clippy_lints/src/map_unit_fn.rs | 6 +++--- clippy_lints/src/matches.rs | 2 +- clippy_lints/src/mem_discriminant.rs | 2 +- clippy_lints/src/methods/mod.rs | 10 +++++----- clippy_lints/src/misc.rs | 8 ++++---- clippy_lints/src/misc_early.rs | 6 +++--- clippy_lints/src/needless_borrow.rs | 4 ++-- clippy_lints/src/needless_borrowed_ref.rs | 2 +- clippy_lints/src/needless_pass_by_value.rs | 8 ++++---- clippy_lints/src/non_copy_const.rs | 2 +- clippy_lints/src/ptr.rs | 10 +++++----- clippy_lints/src/question_mark.rs | 2 +- clippy_lints/src/ranges.rs | 6 +++--- clippy_lints/src/redundant_clone.rs | 2 +- clippy_lints/src/redundant_pattern_matching.rs | 4 ++-- clippy_lints/src/returns.rs | 8 ++++---- clippy_lints/src/slow_vector_initialization.rs | 2 +- clippy_lints/src/swap.rs | 4 ++-- clippy_lints/src/transmute.rs | 18 +++++++++--------- clippy_lints/src/utils/mod.rs | 2 +- clippy_lints/src/utils/sugg.rs | 6 +++--- 38 files changed, 88 insertions(+), 88 deletions(-) diff --git a/clippy_lints/src/assign_ops.rs b/clippy_lints/src/assign_ops.rs index 329bab5cf1c..cc44b514ea7 100644 --- a/clippy_lints/src/assign_ops.rs +++ b/clippy_lints/src/assign_ops.rs @@ -83,7 +83,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for AssignOps { let r = &sugg::Sugg::hir(cx, rhs, ".."); let long = format!("{} = {}", snip_a, sugg::make_binop(higher::binop(op.node), a, r)); - db.span_suggestion_with_applicability( + db.span_suggestion( expr.span, &format!( "Did you mean {} = {} {} {} or {}? Consider replacing it with", @@ -96,7 +96,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for AssignOps { format!("{} {}= {}", snip_a, op.node.as_str(), snip_r), Applicability::MachineApplicable, ); - db.span_suggestion_with_applicability( + db.span_suggestion( expr.span, "or", long, @@ -183,7 +183,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for AssignOps { if let (Some(snip_a), Some(snip_r)) = (snippet_opt(cx, assignee.span), snippet_opt(cx, rhs.span)) { - db.span_suggestion_with_applicability( + db.span_suggestion( expr.span, "replace it with", format!("{} {}= {}", snip_a, op.node.as_str(), snip_r), diff --git a/clippy_lints/src/attrs.rs b/clippy_lints/src/attrs.rs index 4a5eb378d5a..89dbba56130 100644 --- a/clippy_lints/src/attrs.rs +++ b/clippy_lints/src/attrs.rs @@ -273,7 +273,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for AttrPass { "useless lint attribute", |db| { sugg = sugg.replacen("#[", "#![", 1); - db.span_suggestion_with_applicability( + db.span_suggestion( line_span, "if you just forgot a `!`, use", sugg, @@ -336,7 +336,7 @@ fn check_clippy_lint_names(cx: &LateContext<'_, '_>, items: &[NestedMetaItem]) { // https://github.com/rust-lang/rust/pull/56992 CheckLintNameResult::NoLint(None) => (), _ => { - db.span_suggestion_with_applicability( + db.span_suggestion( lint.span, "lowercase the lint name", name_lower, diff --git a/clippy_lints/src/bit_mask.rs b/clippy_lints/src/bit_mask.rs index ef0943875d2..d4e30376199 100644 --- a/clippy_lints/src/bit_mask.rs +++ b/clippy_lints/src/bit_mask.rs @@ -142,7 +142,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for BitMask { "bit mask could be simplified with a call to `trailing_zeros`", |db| { let sugg = Sugg::hir(cx, left1, "...").maybe_par(); - db.span_suggestion_with_applicability( + db.span_suggestion( e.span, "try", format!("{}.trailing_zeros() >= {}", sugg, n.count_ones()), diff --git a/clippy_lints/src/booleans.rs b/clippy_lints/src/booleans.rs index 6b53dd908de..6433e0d640d 100644 --- a/clippy_lints/src/booleans.rs +++ b/clippy_lints/src/booleans.rs @@ -393,7 +393,7 @@ impl<'a, 'tcx> NonminimalBoolVisitor<'a, 'tcx> { "this expression can be optimized out by applying boolean operations to the \ outer expression", ); - db.span_suggestion_with_applicability( + db.span_suggestion( e.span, "it would look like the following", suggest(self.cx, suggestion, &h2q.terminals).0, @@ -423,7 +423,7 @@ impl<'a, 'tcx> NonminimalBoolVisitor<'a, 'tcx> { e.span, "this boolean expression can be simplified", |db| { - db.span_suggestions_with_applicability( + db.span_suggestions( e.span, "try", suggestions.into_iter(), diff --git a/clippy_lints/src/collapsible_if.rs b/clippy_lints/src/collapsible_if.rs index c236706f02f..9539b4d89f9 100644 --- a/clippy_lints/src/collapsible_if.rs +++ b/clippy_lints/src/collapsible_if.rs @@ -154,7 +154,7 @@ 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( + db.span_suggestion( expr.span, "try", format!( diff --git a/clippy_lints/src/const_static_lifetime.rs b/clippy_lints/src/const_static_lifetime.rs index 7315184c8bd..2684f45660e 100644 --- a/clippy_lints/src/const_static_lifetime.rs +++ b/clippy_lints/src/const_static_lifetime.rs @@ -66,7 +66,7 @@ impl StaticConst { lifetime.ident.span, "Constants have by default a `'static` lifetime", |db| { - db.span_suggestion_with_applicability( + db.span_suggestion( ty.span, "consider removing `'static`", sugg, diff --git a/clippy_lints/src/copies.rs b/clippy_lints/src/copies.rs index 6bb75cf8064..c704a635425 100644 --- a/clippy_lints/src/copies.rs +++ b/clippy_lints/src/copies.rs @@ -207,7 +207,7 @@ fn lint_match_arms(cx: &LateContext<'_, '_>, expr: &Expr) { |db| { db.span_note(i.body.span, "same as this"); - // Note: this does not use `span_suggestion_with_applicability` on purpose: + // Note: this does not use `span_suggestion` on purpose: // there is no clean way // to remove the other arm. Building a span and suggest to replace it to "" // makes an even more confusing error message. Also in order not to make up a diff --git a/clippy_lints/src/entry.rs b/clippy_lints/src/entry.rs index 8de881d0425..3e0a6e11be6 100644 --- a/clippy_lints/src/entry.rs +++ b/clippy_lints/src/entry.rs @@ -149,7 +149,7 @@ impl<'a, 'tcx, 'b> Visitor<'tcx> for InsertVisitor<'a, 'tcx, 'b> { snippet(self.cx, params[1].span, ".."), snippet(self.cx, params[2].span, "..")); - db.span_suggestion_with_applicability( + db.span_suggestion( self.span, "consider using", help, @@ -161,7 +161,7 @@ impl<'a, 'tcx, 'b> Visitor<'tcx> for InsertVisitor<'a, 'tcx, 'b> { snippet(self.cx, self.map.span, "map"), snippet(self.cx, params[1].span, "..")); - db.span_suggestion_with_applicability( + db.span_suggestion( self.span, "consider using", help, diff --git a/clippy_lints/src/eq_op.rs b/clippy_lints/src/eq_op.rs index 38c9a05b44c..57291dd24ee 100644 --- a/clippy_lints/src/eq_op.rs +++ b/clippy_lints/src/eq_op.rs @@ -126,7 +126,7 @@ 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( + db.span_suggestion( left.span, "use the left value directly", lsnip, @@ -144,7 +144,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for EqOp { "needlessly taken reference of right operand", |db| { let rsnip = snippet(cx, r.span, "...").to_string(); - db.span_suggestion_with_applicability( + db.span_suggestion( right.span, "use the right value directly", rsnip, @@ -163,7 +163,7 @@ 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( + db.span_suggestion( left.span, "use the left value directly", lsnip, @@ -181,7 +181,7 @@ 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( + db.span_suggestion( right.span, "use the right value directly", rsnip, diff --git a/clippy_lints/src/eta_reduction.rs b/clippy_lints/src/eta_reduction.rs index cc86aee7def..f0557154f90 100644 --- a/clippy_lints/src/eta_reduction.rs +++ b/clippy_lints/src/eta_reduction.rs @@ -101,7 +101,7 @@ 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( + db.span_suggestion( expr.span, "remove closure as shown", snippet, diff --git a/clippy_lints/src/format.rs b/clippy_lints/src/format.rs index f14c281fcc9..aaef5b39aeb 100644 --- a/clippy_lints/src/format.rs +++ b/clippy_lints/src/format.rs @@ -83,7 +83,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass { }; span_lint_and_then(cx, USELESS_FORMAT, span, "useless use of `format!`", |db| { - db.span_suggestion_with_applicability( + db.span_suggestion( expr.span, message, sugg, @@ -99,7 +99,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass { if tup.is_empty() { 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( + db.span_suggestion( span, "consider using .to_string()", sugg, diff --git a/clippy_lints/src/identity_conversion.rs b/clippy_lints/src/identity_conversion.rs index 2c0e389119f..abe8a9d6856 100644 --- a/clippy_lints/src/identity_conversion.rs +++ b/clippy_lints/src/identity_conversion.rs @@ -71,7 +71,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for IdentityConversion { let sugg = snippet_with_macro_callsite(cx, args[0].span, "").to_string(); span_lint_and_then(cx, IDENTITY_CONVERSION, e.span, "identical conversion", |db| { - db.span_suggestion_with_applicability( + db.span_suggestion( e.span, "consider removing `.into()`", sugg, @@ -86,7 +86,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for IdentityConversion { if same_tys(cx, a, b) { 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( + db.span_suggestion( e.span, "consider removing `.into_iter()`", sugg, @@ -108,7 +108,7 @@ 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( + db.span_suggestion( e.span, &sugg_msg, sugg, diff --git a/clippy_lints/src/implicit_return.rs b/clippy_lints/src/implicit_return.rs index b25b3bce652..72d95a0763a 100644 --- a/clippy_lints/src/implicit_return.rs +++ b/clippy_lints/src/implicit_return.rs @@ -39,7 +39,7 @@ impl Pass { fn lint(cx: &LateContext<'_, '_>, outer_span: syntax_pos::Span, inner_span: syntax_pos::Span, msg: &str) { span_lint_and_then(cx, IMPLICIT_RETURN, outer_span, "missing return statement", |db| { if let Some(snippet) = snippet_opt(cx, inner_span) { - db.span_suggestion_with_applicability( + db.span_suggestion( outer_span, msg, format!("return {}", snippet), diff --git a/clippy_lints/src/int_plus_one.rs b/clippy_lints/src/int_plus_one.rs index aee3b7cc542..9b5938baf5f 100644 --- a/clippy_lints/src/int_plus_one.rs +++ b/clippy_lints/src/int_plus_one.rs @@ -162,7 +162,7 @@ impl IntPlusOne { block.span, "Unnecessary `>= y + 1` or `x - 1 >=`", |db| { - db.span_suggestion_with_applicability( + db.span_suggestion( block.span, "change `>= y + 1` to `> y` as shown", recommendation, diff --git a/clippy_lints/src/large_enum_variant.rs b/clippy_lints/src/large_enum_variant.rs index 0b3cf07e50a..59e036c715e 100644 --- a/clippy_lints/src/large_enum_variant.rs +++ b/clippy_lints/src/large_enum_variant.rs @@ -100,7 +100,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for LargeEnumVariant { VariantData::Unit(_) => unreachable!(), }; if let Some(snip) = snippet_opt(cx, span) { - db.span_suggestion_with_applicability( + db.span_suggestion( span, "consider boxing the large fields to reduce the total size of the \ enum", diff --git a/clippy_lints/src/let_if_seq.rs b/clippy_lints/src/let_if_seq.rs index 3eb25cfb36a..f1aed79847f 100644 --- a/clippy_lints/src/let_if_seq.rs +++ b/clippy_lints/src/let_if_seq.rs @@ -124,7 +124,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for LetIfSeq { span, "`if _ { .. } else { .. }` is an expression", |db| { - db.span_suggestion_with_applicability( + db.span_suggestion( span, "it is more idiomatic to write", sug, diff --git a/clippy_lints/src/loops.rs b/clippy_lints/src/loops.rs index 64e76c09989..4d6cc75135e 100644 --- a/clippy_lints/src/loops.rs +++ b/clippy_lints/src/loops.rs @@ -1304,7 +1304,7 @@ fn check_for_loop_reverse_range<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, arg: &'tcx expr.span, "this range is empty so this for loop will never run", |db| { - db.span_suggestion_with_applicability( + db.span_suggestion( arg.span, "consider using the following if you are attempting to iterate over this \ range in reverse", @@ -2408,7 +2408,7 @@ fn check_needless_collect<'a, 'tcx>(expr: &'tcx Expr, cx: &LateContext<'a, 'tcx> if method.ident.name == "len" { let span = shorten_needless_collect_span(expr); span_lint_and_then(cx, NEEDLESS_COLLECT, span, NEEDLESS_COLLECT_MSG, |db| { - db.span_suggestion_with_applicability( + db.span_suggestion( span, "replace with", ".count()".to_string(), @@ -2419,7 +2419,7 @@ fn check_needless_collect<'a, 'tcx>(expr: &'tcx Expr, cx: &LateContext<'a, 'tcx> if method.ident.name == "is_empty" { let span = shorten_needless_collect_span(expr); span_lint_and_then(cx, NEEDLESS_COLLECT, span, NEEDLESS_COLLECT_MSG, |db| { - db.span_suggestion_with_applicability( + db.span_suggestion( span, "replace with", ".next().is_none()".to_string(), @@ -2431,7 +2431,7 @@ fn check_needless_collect<'a, 'tcx>(expr: &'tcx Expr, cx: &LateContext<'a, 'tcx> let contains_arg = snippet(cx, args[1].span, "??"); let span = shorten_needless_collect_span(expr); span_lint_and_then(cx, NEEDLESS_COLLECT, span, NEEDLESS_COLLECT_MSG, |db| { - db.span_suggestion_with_applicability( + db.span_suggestion( span, "replace with", format!( diff --git a/clippy_lints/src/map_unit_fn.rs b/clippy_lints/src/map_unit_fn.rs index bd4b4043824..75e12cd9fd3 100644 --- a/clippy_lints/src/map_unit_fn.rs +++ b/clippy_lints/src/map_unit_fn.rs @@ -216,7 +216,7 @@ fn lint_map_unit_fn(cx: &LateContext<'_, '_>, stmt: &hir::Stmt, expr: &hir::Expr ); span_lint_and_then(cx, lint, expr.span, &msg, |db| { - db.span_suggestion_with_applicability(stmt.span, "try this", suggestion, Applicability::Unspecified); + db.span_suggestion(stmt.span, "try this", suggestion, Applicability::Unspecified); }); } else if let Some((binding, closure_expr)) = unit_closure(cx, fn_arg) { let msg = suggestion_msg("closure", map_type); @@ -230,7 +230,7 @@ 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( + db.span_suggestion( stmt.span, "try this", suggestion, @@ -243,7 +243,7 @@ fn lint_map_unit_fn(cx: &LateContext<'_, '_>, stmt: &hir::Stmt, expr: &hir::Expr 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(stmt.span, "try this", suggestion, Applicability::Unspecified); } }); } diff --git a/clippy_lints/src/matches.rs b/clippy_lints/src/matches.rs index adb8dab5c42..b290980fc36 100644 --- a/clippy_lints/src/matches.rs +++ b/clippy_lints/src/matches.rs @@ -375,7 +375,7 @@ fn check_match_bool(cx: &LateContext<'_, '_>, ex: &Expr, arms: &[Arm], expr: &Ex }; if let Some(sugg) = sugg { - db.span_suggestion_with_applicability( + db.span_suggestion( expr.span, "consider using an if/else expression", sugg, diff --git a/clippy_lints/src/mem_discriminant.rs b/clippy_lints/src/mem_discriminant.rs index a40b1eab2c7..65e47369819 100644 --- a/clippy_lints/src/mem_discriminant.rs +++ b/clippy_lints/src/mem_discriminant.rs @@ -74,7 +74,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MemDiscriminant { } let derefs: String = iter::repeat('*').take(derefs_needed).collect(); - db.span_suggestion_with_applicability( + db.span_suggestion( param.span, "try dereferencing", format!("{}{}", derefs, snippet(cx, cur_expr.span, "")), diff --git a/clippy_lints/src/methods/mod.rs b/clippy_lints/src/methods/mod.rs index 16c3e1fb631..20ffc1fd406 100644 --- a/clippy_lints/src/methods/mod.rs +++ b/clippy_lints/src/methods/mod.rs @@ -1313,13 +1313,13 @@ fn lint_clone_on_copy(cx: &LateContext<'_, '_>, expr: &hir::Expr, arg: &hir::Exp let refs: String = iter::repeat('&').take(n + 1).collect(); let derefs: String = iter::repeat('*').take(n).collect(); let explicit = format!("{}{}::clone({})", refs, ty, snip); - db.span_suggestion_with_applicability( + db.span_suggestion( expr.span, "try dereferencing it", format!("{}({}{}).clone()", refs, derefs, snip.deref()), Applicability::MaybeIncorrect, ); - db.span_suggestion_with_applicability( + db.span_suggestion( expr.span, "or try being explicit about what type to clone", explicit, @@ -1379,7 +1379,7 @@ fn lint_clone_on_copy(cx: &LateContext<'_, '_>, expr: &hir::Expr, arg: &hir::Exp } span_lint_and_then(cx, CLONE_ON_COPY, expr.span, "using `clone` on a `Copy` type", |db| { if let Some((text, snip)) = snip { - db.span_suggestion_with_applicability(expr.span, text, snip, Applicability::Unspecified); + db.span_suggestion(expr.span, text, snip, Applicability::Unspecified); } }); } @@ -1810,7 +1810,7 @@ fn lint_map_flatten<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, expr: &'tcx hir::Expr, let func_snippet = snippet(cx, map_args[1].span, ".."); let hint = format!("{0}.flat_map({1})", self_snippet, func_snippet); span_lint_and_then(cx, MAP_FLATTEN, expr.span, msg, |db| { - db.span_suggestion_with_applicability( + db.span_suggestion( expr.span, "try using flat_map instead", hint, @@ -1897,7 +1897,7 @@ fn lint_map_or_none<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, expr: &'tcx hir::Expr, let map_or_func_snippet = snippet(cx, map_or_args[2].span, ".."); 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( + db.span_suggestion( expr.span, "try using and_then instead", hint, diff --git a/clippy_lints/src/misc.rs b/clippy_lints/src/misc.rs index 01f5a633387..c15fba76869 100644 --- a/clippy_lints/src/misc.rs +++ b/clippy_lints/src/misc.rs @@ -302,7 +302,7 @@ 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( + db.span_suggestion( s.span, "try", format!( @@ -330,7 +330,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass { "boolean short circuit operator in statement may be clearer using an explicit test", |db| { let sugg = if binop.node == BinOpKind::Or { !sugg } else { sugg }; - db.span_suggestion_with_applicability( + db.span_suggestion( s.span, "replace it with", format!( @@ -387,7 +387,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass { let lhs = Sugg::hir(cx, left, ".."); let rhs = Sugg::hir(cx, right, ".."); - db.span_suggestion_with_applicability( + db.span_suggestion( expr.span, "consider comparing them within some error", format!("({}).abs() < error", lhs - rhs), @@ -568,7 +568,7 @@ fn check_to_owned(cx: &LateContext<'_, '_>, expr: &Expr, other: &Expr) { snip.to_string() }; - db.span_suggestion_with_applicability( + db.span_suggestion( lint_span, "try", try_hint, diff --git a/clippy_lints/src/misc_early.rs b/clippy_lints/src/misc_early.rs index eb35da05908..88acdbb168a 100644 --- a/clippy_lints/src/misc_early.rs +++ b/clippy_lints/src/misc_early.rs @@ -343,7 +343,7 @@ impl EarlyLintPass for MiscEarly { |db| { if decl.inputs.is_empty() { let hint = snippet(cx, block.span, "..").into_owned(); - db.span_suggestion_with_applicability( + db.span_suggestion( expr.span, "Try doing something like: ", hint, @@ -438,13 +438,13 @@ impl MiscEarly { lit.span, "this is a decimal constant", |db| { - db.span_suggestion_with_applicability( + db.span_suggestion( lit.span, "if you mean to use a decimal constant, remove the `0` to remove confusion", src.trim_start_matches(|c| c == '_' || c == '0').to_string(), Applicability::MaybeIncorrect, ); - db.span_suggestion_with_applicability( + db.span_suggestion( lit.span, "if you mean to use an octal constant, use `0o`", format!("0o{}", src.trim_start_matches(|c| c == '_' || c == '0')), diff --git a/clippy_lints/src/needless_borrow.rs b/clippy_lints/src/needless_borrow.rs index a35f31a9803..206a1465a46 100644 --- a/clippy_lints/src/needless_borrow.rs +++ b/clippy_lints/src/needless_borrow.rs @@ -70,7 +70,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NeedlessBorrow { by the compiler", |db| { if let Some(snippet) = snippet_opt(cx, inner.span) { - db.span_suggestion_with_applicability( + db.span_suggestion( e.span, "change this to", snippet, @@ -103,7 +103,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NeedlessBorrow { "this pattern creates a reference to a reference", |db| { if let Some(snippet) = snippet_opt(cx, name.span) { - db.span_suggestion_with_applicability( + db.span_suggestion( pat.span, "change this to", snippet, diff --git a/clippy_lints/src/needless_borrowed_ref.rs b/clippy_lints/src/needless_borrowed_ref.rs index 6a0032f91b3..bf2857d9288 100644 --- a/clippy_lints/src/needless_borrowed_ref.rs +++ b/clippy_lints/src/needless_borrowed_ref.rs @@ -82,7 +82,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NeedlessBorrowedRef { "this pattern takes a reference on something that is being de-referenced", |db| { let hint = snippet(cx, spanned_name.span, "..").into_owned(); - db.span_suggestion_with_applicability( + db.span_suggestion( pat.span, "try removing the `&ref` part and just keep", hint, diff --git a/clippy_lints/src/needless_pass_by_value.rs b/clippy_lints/src/needless_pass_by_value.rs index 88eb36534b5..73c0ed72d3b 100644 --- a/clippy_lints/src/needless_pass_by_value.rs +++ b/clippy_lints/src/needless_pass_by_value.rs @@ -237,7 +237,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NeedlessPassByValue { }).unwrap()); then { let slice_ty = format!("&[{}]", snippet(cx, elem_ty.span, "_")); - db.span_suggestion_with_applicability( + db.span_suggestion( input.span, "consider changing the type to", slice_ty, @@ -245,7 +245,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NeedlessPassByValue { ); for (span, suggestion) in clone_spans { - db.span_suggestion_with_applicability( + db.span_suggestion( span, &snippet_opt(cx, span) .map_or( @@ -266,7 +266,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NeedlessPassByValue { if match_type(cx, ty, &paths::STRING) { if let Some(clone_spans) = get_spans(cx, Some(body.id()), idx, &[("clone", ".to_string()"), ("as_str", "")]) { - db.span_suggestion_with_applicability( + db.span_suggestion( input.span, "consider changing the type to", "&str".to_string(), @@ -274,7 +274,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NeedlessPassByValue { ); for (span, suggestion) in clone_spans { - db.span_suggestion_with_applicability( + db.span_suggestion( span, &snippet_opt(cx, span) .map_or( diff --git a/clippy_lints/src/non_copy_const.rs b/clippy_lints/src/non_copy_const.rs index cbf6099dd7d..50d8b69ffae 100644 --- a/clippy_lints/src/non_copy_const.rs +++ b/clippy_lints/src/non_copy_const.rs @@ -122,7 +122,7 @@ fn verify_ty_bound<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, ty: ty::Ty<'tcx>, sourc match source { Source::Item { .. } => { let const_kw_span = span.from_inner_byte_pos(0, 5); - db.span_suggestion_with_applicability( + db.span_suggestion( const_kw_span, "make this a static item", "static".to_string(), diff --git a/clippy_lints/src/ptr.rs b/clippy_lints/src/ptr.rs index 6b2528248b5..8f4ee74258a 100644 --- a/clippy_lints/src/ptr.rs +++ b/clippy_lints/src/ptr.rs @@ -182,7 +182,7 @@ fn check_fn(cx: &LateContext<'_, '_>, decl: &FnDecl, fn_id: NodeId, opt_body_id: with non-Vec-based slices.", |db| { if let Some(ref snippet) = ty_snippet { - db.span_suggestion_with_applicability( + db.span_suggestion( arg.span, "change this to", format!("&[{}]", snippet), @@ -190,7 +190,7 @@ fn check_fn(cx: &LateContext<'_, '_>, decl: &FnDecl, fn_id: NodeId, opt_body_id: ); } for (clonespan, suggestion) in spans { - db.span_suggestion_with_applicability( + db.span_suggestion( clonespan, &snippet_opt(cx, clonespan).map_or("change the call to".into(), |x| { Cow::Owned(format!("change `{}` to", x)) @@ -210,14 +210,14 @@ fn check_fn(cx: &LateContext<'_, '_>, decl: &FnDecl, fn_id: NodeId, opt_body_id: arg.span, "writing `&String` instead of `&str` involves a new object where a slice will do.", |db| { - db.span_suggestion_with_applicability( + db.span_suggestion( arg.span, "change this to", "&str".into(), Applicability::Unspecified, ); for (clonespan, suggestion) in spans { - db.span_suggestion_short_with_applicability( + db.span_suggestion_short( clonespan, &snippet_opt(cx, clonespan).map_or("change the call to".into(), |x| { Cow::Owned(format!("change `{}` to", x)) @@ -250,7 +250,7 @@ fn check_fn(cx: &LateContext<'_, '_>, decl: &FnDecl, fn_id: NodeId, opt_body_id: arg.span, "using a reference to `Cow` is not recommended.", |db| { - db.span_suggestion_with_applicability( + db.span_suggestion( arg.span, "change this to", "&".to_owned() + &r, diff --git a/clippy_lints/src/question_mark.rs b/clippy_lints/src/question_mark.rs index b30cbe4ce9a..cab133943a3 100644 --- a/clippy_lints/src/question_mark.rs +++ b/clippy_lints/src/question_mark.rs @@ -92,7 +92,7 @@ impl Pass { expr.span, "this block may be rewritten with the `?` operator", |db| { - db.span_suggestion_with_applicability( + db.span_suggestion( expr.span, "replace_it_with", replacement_str, diff --git a/clippy_lints/src/ranges.rs b/clippy_lints/src/ranges.rs index ef600184ebe..acd2a3ebc65 100644 --- a/clippy_lints/src/ranges.rs +++ b/clippy_lints/src/ranges.rs @@ -166,14 +166,14 @@ 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( + db.span_suggestion( expr.span, "use", format!("({}..={})", start, end), Applicability::MaybeIncorrect, ); } else { - db.span_suggestion_with_applicability( + db.span_suggestion( expr.span, "use", format!("{}..={}", start, end), @@ -199,7 +199,7 @@ 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( + db.span_suggestion( expr.span, "use", format!("{}..{}", start, end), diff --git a/clippy_lints/src/redundant_clone.rs b/clippy_lints/src/redundant_clone.rs index 59d1a4297a5..7ac147c8ac1 100644 --- a/clippy_lints/src/redundant_clone.rs +++ b/clippy_lints/src/redundant_clone.rs @@ -202,7 +202,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for RedundantClone { ); span_lint_node_and_then(cx, REDUNDANT_CLONE, node, sugg_span, "redundant clone", |db| { - db.span_suggestion_with_applicability( + db.span_suggestion( sugg_span, "remove this", String::new(), diff --git a/clippy_lints/src/redundant_pattern_matching.rs b/clippy_lints/src/redundant_pattern_matching.rs index 1cf0838415f..8f833a893df 100644 --- a/clippy_lints/src/redundant_pattern_matching.rs +++ b/clippy_lints/src/redundant_pattern_matching.rs @@ -98,7 +98,7 @@ fn find_sugg_for_if_let<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr, &format!("redundant pattern matching, consider using `{}`", good_method), |db| { let span = expr.span.to(op.span); - db.span_suggestion_with_applicability( + db.span_suggestion( span, "try this", format!("if {}.{}", snippet(cx, op.span, "_"), good_method), @@ -163,7 +163,7 @@ fn find_sugg_for_match<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr, o &format!("redundant pattern matching, consider using `{}`", good_method), |db| { let span = expr.span.to(op.span); - db.span_suggestion_with_applicability( + db.span_suggestion( span, "try this", format!("{}.{}", snippet(cx, op.span, "_"), good_method), diff --git a/clippy_lints/src/returns.rs b/clippy_lints/src/returns.rs index 83b4d7f9112..71ef3e4bfa0 100644 --- a/clippy_lints/src/returns.rs +++ b/clippy_lints/src/returns.rs @@ -135,7 +135,7 @@ 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( + db.span_suggestion( ret_span, "remove `return` as shown", snippet, @@ -211,7 +211,7 @@ impl EarlyLintPass for ReturnPass { (ty.span, Applicability::MaybeIncorrect) }; span_lint_and_then(cx, UNUSED_UNIT, rspan, "unneeded unit return type", |db| { - db.span_suggestion_with_applicability( + db.span_suggestion( rspan, "remove the `-> ()`", String::new(), @@ -231,7 +231,7 @@ impl EarlyLintPass for ReturnPass { then { let sp = expr.span; span_lint_and_then(cx, UNUSED_UNIT, sp, "unneeded unit expression", |db| { - db.span_suggestion_with_applicability( + db.span_suggestion( sp, "remove the final `()`", String::new(), @@ -247,7 +247,7 @@ impl EarlyLintPass for ReturnPass { ast::ExprKind::Ret(Some(ref expr)) | ast::ExprKind::Break(_, Some(ref expr)) => { if is_unit_expr(expr) && !in_macro(expr.span) { span_lint_and_then(cx, UNUSED_UNIT, expr.span, "unneeded `()`", |db| { - db.span_suggestion_with_applicability( + db.span_suggestion( expr.span, "remove the `()`", String::new(), diff --git a/clippy_lints/src/slow_vector_initialization.rs b/clippy_lints/src/slow_vector_initialization.rs index 0765e4e11be..4ce9ce3e2ff 100644 --- a/clippy_lints/src/slow_vector_initialization.rs +++ b/clippy_lints/src/slow_vector_initialization.rs @@ -179,7 +179,7 @@ impl Pass { let len_expr = Sugg::hir(cx, vec_alloc.len_expr, "len"); span_lint_and_then(cx, lint, slow_fill.span, msg, |db| { - db.span_suggestion_with_applicability( + db.span_suggestion( vec_alloc.allocation_expr.span, "consider replace allocation with", format!("vec![0; {}]", len_expr), diff --git a/clippy_lints/src/swap.rs b/clippy_lints/src/swap.rs index 860707c8239..af7fd11c6e5 100644 --- a/clippy_lints/src/swap.rs +++ b/clippy_lints/src/swap.rs @@ -142,7 +142,7 @@ fn check_manual_swap(cx: &LateContext<'_, '_>, block: &Block) { &format!("this looks like you are swapping{} manually", what), |db| { if !sugg.is_empty() { - db.span_suggestion_with_applicability( + db.span_suggestion( span, "try", sugg, @@ -191,7 +191,7 @@ fn check_suspicious_swap(cx: &LateContext<'_, '_>, block: &Block) { &format!("this looks like you are trying to swap{}", what), |db| { if !what.is_empty() { - db.span_suggestion_with_applicability( + db.span_suggestion( span, "try", format!( diff --git a/clippy_lints/src/transmute.rs b/clippy_lints/src/transmute.rs index 88371df0dca..80bc29a3553 100644 --- a/clippy_lints/src/transmute.rs +++ b/clippy_lints/src/transmute.rs @@ -260,7 +260,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Transmute { arg.as_ty(cx.tcx.mk_ptr(rty_and_mut)).as_ty(to_ty) }; - db.span_suggestion_with_applicability( + db.span_suggestion( e.span, "try", sugg.to_string(), @@ -276,7 +276,7 @@ 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( + db.span_suggestion( e.span, "try", arg.as_ty(&to_ty.to_string()).to_string(), @@ -335,7 +335,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Transmute { arg.as_ty(&format!("{} {}", cast, get_type_snippet(cx, qpath, to_ref_ty))) }; - db.span_suggestion_with_applicability( + db.span_suggestion( e.span, "try", sugg::make_unop(deref, arg).to_string(), @@ -356,7 +356,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Transmute { } else { arg }; - db.span_suggestion_with_applicability( + db.span_suggestion( e.span, "consider using", format!("std::char::from_u32({}).unwrap()", arg.to_string()), @@ -383,7 +383,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Transmute { e.span, &format!("transmute from a `{}` to a `{}`", from_ty, to_ty), |db| { - db.span_suggestion_with_applicability( + db.span_suggestion( e.span, "consider using", format!( @@ -416,7 +416,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Transmute { } else { sugg_paren.addr_deref() }; - db.span_suggestion_with_applicability( + db.span_suggestion( e.span, "try", sugg.to_string(), @@ -436,7 +436,7 @@ 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( + db.span_suggestion( e.span, "try", sugg.to_string(), @@ -454,7 +454,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Transmute { |db| { let arg = sugg::Sugg::hir(cx, &args[0], ".."); let zero = sugg::Sugg::NonParen(Cow::from("0")); - db.span_suggestion_with_applicability( + db.span_suggestion( e.span, "consider using", sugg::make_binop(ast::BinOpKind::Ne, &arg, &zero).to_string(), @@ -478,7 +478,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Transmute { } else { arg }; - db.span_suggestion_with_applicability( + db.span_suggestion( e.span, "consider using", format!("{}::from_bits({})", to_ty, arg.to_string()), diff --git a/clippy_lints/src/utils/mod.rs b/clippy_lints/src/utils/mod.rs index c83b0f155fc..af9b1599649 100644 --- a/clippy_lints/src/utils/mod.rs +++ b/clippy_lints/src/utils/mod.rs @@ -693,7 +693,7 @@ pub fn span_lint_and_sugg<'a, 'tcx: 'a, T: LintContext<'tcx>>( applicability: Applicability, ) { span_lint_and_then(cx, lint, sp, msg, |db| { - db.span_suggestion_with_applicability(sp, help, sugg, applicability); + db.span_suggestion(sp, help, sugg, applicability); }); } diff --git a/clippy_lints/src/utils/sugg.rs b/clippy_lints/src/utils/sugg.rs index b95ce17ed93..166470876c9 100644 --- a/clippy_lints/src/utils/sugg.rs +++ b/clippy_lints/src/utils/sugg.rs @@ -547,7 +547,7 @@ impl<'a, 'b, 'c, T: LintContext<'c>> DiagnosticBuilderExt<'c, T> for rustc_error if let Some(indent) = indentation(cx, item) { let span = item.with_hi(item.lo()); - self.span_suggestion_with_applicability(span, msg, format!("{}\n{}", attr, indent), applicability); + self.span_suggestion(span, msg, format!("{}\n{}", attr, indent), applicability); } } @@ -568,7 +568,7 @@ impl<'a, 'b, 'c, T: LintContext<'c>> DiagnosticBuilderExt<'c, T> for rustc_error }) .collect::(); - self.span_suggestion_with_applicability(span, msg, format!("{}\n{}", new_item, indent), applicability); + self.span_suggestion(span, msg, format!("{}\n{}", new_item, indent), applicability); } } @@ -586,7 +586,7 @@ impl<'a, 'b, 'c, T: LintContext<'c>> DiagnosticBuilderExt<'c, T> for rustc_error } } - self.span_suggestion_with_applicability(remove_span, msg, String::new(), applicability); + self.span_suggestion(remove_span, msg, String::new(), applicability); } }