mirror of
https://github.com/rust-lang/rust.git
synced 2025-06-04 19:29:07 +00:00
remove unnecessary to_string
and String::new
This commit is contained in:
parent
e34621c24e
commit
f2d9acfc01
@ -90,7 +90,7 @@ fn check_range(cx: &EarlyContext<'_>, span: Span, start: &Expr, end: &Expr, sugg
|
|||||||
diag.span_suggestion(
|
diag.span_suggestion(
|
||||||
span,
|
span,
|
||||||
"use an inclusive range",
|
"use an inclusive range",
|
||||||
sugg.to_owned(),
|
sugg,
|
||||||
Applicability::MaybeIncorrect,
|
Applicability::MaybeIncorrect,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -63,7 +63,7 @@ impl<'tcx> LateLintPass<'tcx> for AsUnderscore {
|
|||||||
diag.span_suggestion(
|
diag.span_suggestion(
|
||||||
ty.span,
|
ty.span,
|
||||||
"consider giving the type explicitly",
|
"consider giving the type explicitly",
|
||||||
format!("{}", ty_resolved),
|
ty_resolved,
|
||||||
Applicability::MachineApplicable,
|
Applicability::MachineApplicable,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -44,7 +44,7 @@ impl EarlyLintPass for EmptyStructsWithBrackets {
|
|||||||
diagnostic.span_suggestion_hidden(
|
diagnostic.span_suggestion_hidden(
|
||||||
span_after_ident,
|
span_after_ident,
|
||||||
"remove the brackets",
|
"remove the brackets",
|
||||||
";".to_string(),
|
";",
|
||||||
Applicability::MachineApplicable);
|
Applicability::MachineApplicable);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
@ -75,7 +75,7 @@ impl<'tcx> LateLintPass<'tcx> for LargeConstArrays {
|
|||||||
diag.span_suggestion(
|
diag.span_suggestion(
|
||||||
sugg_span,
|
sugg_span,
|
||||||
"make this a static item",
|
"make this a static item",
|
||||||
"static".to_string(),
|
"static",
|
||||||
Applicability::MachineApplicable,
|
Applicability::MachineApplicable,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -86,7 +86,7 @@ impl<'tcx> LateLintPass<'tcx> for ManualAsyncFn {
|
|||||||
diag.span_suggestion(
|
diag.span_suggestion(
|
||||||
block.span,
|
block.span,
|
||||||
"move the body of the async block to the enclosing function",
|
"move the body of the async block to the enclosing function",
|
||||||
body_snip.to_string(),
|
body_snip,
|
||||||
Applicability::MachineApplicable
|
Applicability::MachineApplicable
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -113,7 +113,7 @@ pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, arms: &'tcx [Arm<'_>]) {
|
|||||||
diag.span_suggestion(
|
diag.span_suggestion(
|
||||||
arm1.span,
|
arm1.span,
|
||||||
"try removing the arm",
|
"try removing the arm",
|
||||||
String::new(),
|
"",
|
||||||
Applicability::MaybeIncorrect,
|
Applicability::MaybeIncorrect,
|
||||||
)
|
)
|
||||||
.help("or try changing either arm body")
|
.help("or try changing either arm body")
|
||||||
|
@ -176,13 +176,13 @@ fn check_manual_split_once_indirect(
|
|||||||
diag.span_suggestion(
|
diag.span_suggestion(
|
||||||
first.span,
|
first.span,
|
||||||
&remove_msg,
|
&remove_msg,
|
||||||
String::new(),
|
"",
|
||||||
app,
|
app,
|
||||||
);
|
);
|
||||||
diag.span_suggestion(
|
diag.span_suggestion(
|
||||||
second.span,
|
second.span,
|
||||||
&remove_msg,
|
&remove_msg,
|
||||||
String::new(),
|
"",
|
||||||
app,
|
app,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
@ -85,7 +85,7 @@ pub fn check_for_loop_iter(
|
|||||||
match addr_of_expr.kind {
|
match addr_of_expr.kind {
|
||||||
ExprKind::AddrOf(_, _, referent) => {
|
ExprKind::AddrOf(_, _, referent) => {
|
||||||
let span = addr_of_expr.span.with_hi(referent.span.lo());
|
let span = addr_of_expr.span.with_hi(referent.span.lo());
|
||||||
diag.span_suggestion(span, "remove this `&`", String::new(), applicability);
|
diag.span_suggestion(span, "remove this `&`", "", applicability);
|
||||||
}
|
}
|
||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
}
|
}
|
||||||
|
@ -318,7 +318,7 @@ fn check<'tcx>(
|
|||||||
diag.span_suggestion(
|
diag.span_suggestion(
|
||||||
usage.stmt.span.shrink_to_hi(),
|
usage.stmt.span.shrink_to_hi(),
|
||||||
"add a semicolon after the `if` expression",
|
"add a semicolon after the `if` expression",
|
||||||
";".to_string(),
|
";",
|
||||||
applicability,
|
applicability,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -353,7 +353,7 @@ fn check<'tcx>(
|
|||||||
diag.span_suggestion(
|
diag.span_suggestion(
|
||||||
usage.stmt.span.shrink_to_hi(),
|
usage.stmt.span.shrink_to_hi(),
|
||||||
"add a semicolon after the `match` expression",
|
"add a semicolon after the `match` expression",
|
||||||
";".to_string(),
|
";",
|
||||||
applicability,
|
applicability,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -258,7 +258,7 @@ impl<'tcx> LateLintPass<'tcx> for NeedlessPassByValue {
|
|||||||
diag.span_suggestion(
|
diag.span_suggestion(
|
||||||
input.span,
|
input.span,
|
||||||
"consider changing the type to",
|
"consider changing the type to",
|
||||||
"&str".to_string(),
|
"&str",
|
||||||
Applicability::Unspecified,
|
Applicability::Unspecified,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -255,7 +255,7 @@ impl<'tcx> LateLintPass<'tcx> for RedundantClone {
|
|||||||
diag.span_suggestion(
|
diag.span_suggestion(
|
||||||
sugg_span,
|
sugg_span,
|
||||||
"remove this",
|
"remove this",
|
||||||
String::new(),
|
"",
|
||||||
app,
|
app,
|
||||||
);
|
);
|
||||||
if clone_usage.cloned_used {
|
if clone_usage.cloned_used {
|
||||||
|
@ -55,7 +55,7 @@ pub(super) fn check<'tcx>(
|
|||||||
sugg
|
sugg
|
||||||
};
|
};
|
||||||
|
|
||||||
diag.span_suggestion(e.span, "consider using", sugg.to_string(), Applicability::Unspecified);
|
diag.span_suggestion(e.span, "consider using", sugg, Applicability::Unspecified);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
true
|
true
|
||||||
|
@ -25,7 +25,7 @@ pub(super) fn check<'tcx>(
|
|||||||
|diag| {
|
|diag| {
|
||||||
if let Some(arg) = sugg::Sugg::hir_opt(cx, arg) {
|
if let Some(arg) = sugg::Sugg::hir_opt(cx, arg) {
|
||||||
let sugg = arg.as_ty(cx.tcx.mk_ptr(*to_ty));
|
let sugg = arg.as_ty(cx.tcx.mk_ptr(*to_ty));
|
||||||
diag.span_suggestion(e.span, "try", sugg.to_string(), Applicability::Unspecified);
|
diag.span_suggestion(e.span, "try", sugg, Applicability::Unspecified);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
@ -73,7 +73,7 @@ pub(super) fn check<'tcx>(
|
|||||||
diag.span_suggestion(
|
diag.span_suggestion(
|
||||||
e.span,
|
e.span,
|
||||||
"try",
|
"try",
|
||||||
sugg.to_string(),
|
sugg,
|
||||||
Applicability::Unspecified,
|
Applicability::Unspecified,
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
@ -46,7 +46,7 @@ pub(super) fn check<'tcx>(
|
|||||||
arg.as_ty(cx.tcx.mk_ptr(rty_and_mut)).as_ty(to_ty)
|
arg.as_ty(cx.tcx.mk_ptr(rty_and_mut)).as_ty(to_ty)
|
||||||
};
|
};
|
||||||
|
|
||||||
diag.span_suggestion(e.span, "try", sugg.to_string(), Applicability::Unspecified);
|
diag.span_suggestion(e.span, "try", sugg, Applicability::Unspecified);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
@ -64,7 +64,7 @@ pub(super) fn check<'tcx>(
|
|||||||
diag.span_suggestion(
|
diag.span_suggestion(
|
||||||
e.span,
|
e.span,
|
||||||
"try",
|
"try",
|
||||||
arg.as_ty(&to_ty.to_string()).to_string(),
|
arg.as_ty(&to_ty.to_string()),
|
||||||
Applicability::Unspecified,
|
Applicability::Unspecified,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -92,7 +92,7 @@ pub fn get_attr<'a>(
|
|||||||
diag.span_suggestion(
|
diag.span_suggestion(
|
||||||
attr_segments[1].ident.span,
|
attr_segments[1].ident.span,
|
||||||
"consider using",
|
"consider using",
|
||||||
new_name.to_string(),
|
new_name,
|
||||||
Applicability::MachineApplicable,
|
Applicability::MachineApplicable,
|
||||||
);
|
);
|
||||||
diag.emit();
|
diag.emit();
|
||||||
|
Loading…
Reference in New Issue
Block a user