Skip to content

Commit f2d9acf

Browse files
committed
remove unnecessary to_string and String::new
1 parent e34621c commit f2d9acf

16 files changed

+19
-19
lines changed

clippy_lints/src/almost_complete_letter_range.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ fn check_range(cx: &EarlyContext<'_>, span: Span, start: &Expr, end: &Expr, sugg
9090
diag.span_suggestion(
9191
span,
9292
"use an inclusive range",
93-
sugg.to_owned(),
93+
sugg,
9494
Applicability::MaybeIncorrect,
9595
);
9696
}

clippy_lints/src/as_underscore.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ impl<'tcx> LateLintPass<'tcx> for AsUnderscore {
6363
diag.span_suggestion(
6464
ty.span,
6565
"consider giving the type explicitly",
66-
format!("{}", ty_resolved),
66+
ty_resolved,
6767
Applicability::MachineApplicable,
6868
);
6969
}

clippy_lints/src/empty_structs_with_brackets.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ impl EarlyLintPass for EmptyStructsWithBrackets {
4444
diagnostic.span_suggestion_hidden(
4545
span_after_ident,
4646
"remove the brackets",
47-
";".to_string(),
47+
";",
4848
Applicability::MachineApplicable);
4949
},
5050
);

clippy_lints/src/large_const_arrays.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ impl<'tcx> LateLintPass<'tcx> for LargeConstArrays {
7575
diag.span_suggestion(
7676
sugg_span,
7777
"make this a static item",
78-
"static".to_string(),
78+
"static",
7979
Applicability::MachineApplicable,
8080
);
8181
}

clippy_lints/src/manual_async_fn.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ impl<'tcx> LateLintPass<'tcx> for ManualAsyncFn {
8686
diag.span_suggestion(
8787
block.span,
8888
"move the body of the async block to the enclosing function",
89-
body_snip.to_string(),
89+
body_snip,
9090
Applicability::MachineApplicable
9191
);
9292
}

clippy_lints/src/matches/match_same_arms.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, arms: &'tcx [Arm<'_>]) {
113113
diag.span_suggestion(
114114
arm1.span,
115115
"try removing the arm",
116-
String::new(),
116+
"",
117117
Applicability::MaybeIncorrect,
118118
)
119119
.help("or try changing either arm body")

clippy_lints/src/methods/str_splitn.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,13 +176,13 @@ fn check_manual_split_once_indirect(
176176
diag.span_suggestion(
177177
first.span,
178178
&remove_msg,
179-
String::new(),
179+
"",
180180
app,
181181
);
182182
diag.span_suggestion(
183183
second.span,
184184
&remove_msg,
185-
String::new(),
185+
"",
186186
app,
187187
);
188188
});

clippy_lints/src/methods/unnecessary_iter_cloned.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ pub fn check_for_loop_iter(
8585
match addr_of_expr.kind {
8686
ExprKind::AddrOf(_, _, referent) => {
8787
let span = addr_of_expr.span.with_hi(referent.span.lo());
88-
diag.span_suggestion(span, "remove this `&`", String::new(), applicability);
88+
diag.span_suggestion(span, "remove this `&`", "", applicability);
8989
}
9090
_ => unreachable!(),
9191
}

clippy_lints/src/needless_late_init.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ fn check<'tcx>(
318318
diag.span_suggestion(
319319
usage.stmt.span.shrink_to_hi(),
320320
"add a semicolon after the `if` expression",
321-
";".to_string(),
321+
";",
322322
applicability,
323323
);
324324
}
@@ -353,7 +353,7 @@ fn check<'tcx>(
353353
diag.span_suggestion(
354354
usage.stmt.span.shrink_to_hi(),
355355
"add a semicolon after the `match` expression",
356-
";".to_string(),
356+
";",
357357
applicability,
358358
);
359359
}

clippy_lints/src/needless_pass_by_value.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ impl<'tcx> LateLintPass<'tcx> for NeedlessPassByValue {
258258
diag.span_suggestion(
259259
input.span,
260260
"consider changing the type to",
261-
"&str".to_string(),
261+
"&str",
262262
Applicability::Unspecified,
263263
);
264264

0 commit comments

Comments
 (0)