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
This commit is contained in:
Matthias Krüger 2019-01-27 13:33:56 +01:00
parent e9e0a7e3bd
commit 3a96d6b603
38 changed files with 88 additions and 88 deletions

View File

@ -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),

View File

@ -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,

View File

@ -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()),

View File

@ -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(),

View File

@ -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!(

View File

@ -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,

View File

@ -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

View File

@ -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,

View File

@ -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,

View File

@ -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,

View File

@ -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, "<expr>").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,

View File

@ -71,7 +71,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for IdentityConversion {
let sugg = snippet_with_macro_callsite(cx, args[0].span, "<expr>").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, "<expr>").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,

View File

@ -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),

View File

@ -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,

View File

@ -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",

View File

@ -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,

View File

@ -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!(

View File

@ -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);
}
});
}

View File

@ -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,

View File

@ -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, "<param>")),

View File

@ -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,

View File

@ -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,

View File

@ -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')),

View File

@ -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,

View File

@ -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,

View File

@ -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(

View File

@ -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(),

View File

@ -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,

View File

@ -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,

View File

@ -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),

View File

@ -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(),

View File

@ -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),

View File

@ -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(),

View File

@ -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),

View File

@ -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!(

View File

@ -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()),

View File

@ -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);
});
}

View File

@ -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::<String>();
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);
}
}