Skip to content

Commit 72eccf1

Browse files
committed
Fix adjacent code
1 parent c7a116b commit 72eccf1

11 files changed

+14
-18
lines changed

Diff for: clippy_dev/src/update_lints.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,7 @@ impl Lint {
546546
/// Returns the lints in a `HashMap`, grouped by the different lint groups
547547
#[must_use]
548548
fn by_lint_group(lints: impl Iterator<Item = Self>) -> HashMap<String, Vec<Self>> {
549-
lints.map(|lint| (lint.group.to_string(), lint)).into_group_map()
549+
lints.map(|lint| (lint.group.clone(), lint)).into_group_map()
550550
}
551551
}
552552

Diff for: clippy_lints/src/blocks_in_conditions.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,7 @@ impl<'tcx> LateLintPass<'tcx> for BlocksInConditions {
9393
cond.span,
9494
BRACED_EXPR_MESSAGE,
9595
"try",
96-
snippet_block_with_applicability(cx, ex.span, "..", Some(expr.span), &mut applicability)
97-
.to_string(),
96+
snippet_block_with_applicability(cx, ex.span, "..", Some(expr.span), &mut applicability),
9897
applicability,
9998
);
10099
}

Diff for: clippy_lints/src/copies.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -250,9 +250,9 @@ fn lint_branches_sharing_code<'tcx>(
250250
let cond_snippet = reindent_multiline(&snippet(cx, cond_span, "_"), false, None);
251251
let cond_indent = indent_of(cx, cond_span);
252252
let moved_snippet = reindent_multiline(&snippet(cx, span, "_"), true, None);
253-
let suggestion = moved_snippet.to_string() + "\n" + &cond_snippet + "{";
253+
let suggestion = moved_snippet + "\n" + &cond_snippet + "{";
254254
let suggestion = reindent_multiline(&suggestion, true, cond_indent);
255-
(replace_span, suggestion.to_string())
255+
(replace_span, suggestion)
256256
});
257257
let end_suggestion = res.end_span(last_block, sm).map(|span| {
258258
let moved_snipped = reindent_multiline(&snippet(cx, span, "_"), true, None);
@@ -268,7 +268,7 @@ fn lint_branches_sharing_code<'tcx>(
268268
.then_some(range.start - 4..range.end)
269269
})
270270
.map_or(span, |range| range.with_ctxt(span.ctxt()));
271-
(span, suggestion.to_string())
271+
(span, suggestion.clone())
272272
});
273273

274274
let (span, msg, end_span) = match (&start_suggestion, &end_suggestion) {

Diff for: clippy_lints/src/if_not_else.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ impl LateLintPass<'_> for IfNotElse {
8989
e.span,
9090
msg,
9191
"try",
92-
make_sugg(cx, &cond.kind, cond_inner.span, els.span, "..", Some(e.span)).to_string(),
92+
make_sugg(cx, &cond.kind, cond_inner.span, els.span, "..", Some(e.span)),
9393
Applicability::MachineApplicable,
9494
),
9595
_ => span_lint_and_help(cx, IF_NOT_ELSE, e.span, msg, None, help),

Diff for: clippy_lints/src/manual_async_fn.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ impl<'tcx> LateLintPass<'tcx> for ManualAsyncFn {
8383
format!("{} async {}", vis_snip, &header_snip[vis_snip.len() + 1..ret_pos])
8484
};
8585

86-
let body_snip = snippet_block(cx, closure_body.value.span, "..", Some(block.span)).to_string();
86+
let body_snip = snippet_block(cx, closure_body.value.span, "..", Some(block.span));
8787

8888
diag.multipart_suggestion(
8989
"make the function `async` and return the output of the future directly",

Diff for: clippy_lints/src/matches/match_single_binding.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,7 @@ pub(crate) fn check<'a>(cx: &LateContext<'a>, ex: &Expr<'a>, arms: &[Arm<'_>], e
3232
Some(expr.span),
3333
&mut app,
3434
)
35-
.0
36-
.to_string();
35+
.0;
3736

3837
// Do we need to add ';' to suggestion ?
3938
if let Node::Stmt(stmt) = cx.tcx.parent_hir_node(expr.hir_id)

Diff for: clippy_lints/src/matches/single_match.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,7 @@ fn report_single_pattern(cx: &LateContext<'_>, ex: &Expr<'_>, arm: &Arm<'_>, exp
9595
let (sugg, help) = if is_unit_expr(arm.body) {
9696
(String::new(), "`match` expression can be removed")
9797
} else {
98-
let mut sugg = snippet_block_with_context(cx, arm.body.span, ctxt, "..", Some(expr.span), &mut app)
99-
.0
100-
.to_string();
98+
let mut sugg = snippet_block_with_context(cx, arm.body.span, ctxt, "..", Some(expr.span), &mut app).0;
10199
if let Node::Stmt(stmt) = cx.tcx.parent_hir_node(expr.hir_id)
102100
&& let StmtKind::Expr(_) = stmt.kind
103101
&& match arm.body.kind {
@@ -109,7 +107,7 @@ fn report_single_pattern(cx: &LateContext<'_>, ex: &Expr<'_>, arm: &Arm<'_>, exp
109107
}
110108
(sugg, "try")
111109
};
112-
span_lint_and_sugg(cx, lint, expr.span, msg, help, sugg.to_string(), app);
110+
span_lint_and_sugg(cx, lint, expr.span, msg, help, sugg, app);
113111
return;
114112
}
115113

Diff for: clippy_lints/src/methods/unnecessary_sort_by.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ pub(super) fn check<'tcx>(
216216
{
217217
format!("{}::cmp::Reverse({})", std_or_core, trigger.closure_body)
218218
} else {
219-
trigger.closure_body.to_string()
219+
trigger.closure_body
220220
},
221221
),
222222
if trigger.reverse {

Diff for: clippy_lints/src/redundant_else.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ impl EarlyLintPass for RedundantElse {
9797
els.span.with_lo(then.span.hi()),
9898
"redundant else block",
9999
"remove the `else` block and move the contents out",
100-
make_sugg(cx, els.span, "..", Some(expr.span)).to_string(),
100+
make_sugg(cx, els.span, "..", Some(expr.span)),
101101
app,
102102
);
103103
}

Diff for: lintcheck/src/input.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ pub fn read_crates(toml_path: &Path) -> (Vec<CrateWithSource>, RecursiveOptions)
117117
crate_sources.push(CrateWithSource {
118118
name: tk.name.clone(),
119119
source: CrateSource::CratesIo {
120-
version: version.to_string(),
120+
version: version.clone(),
121121
},
122122
file_link: tk.file_link(DEFAULT_DOCS_LINK),
123123
options: tk.options.clone(),

Diff for: lintcheck/src/output.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ fn print_stats(old_stats: HashMap<String, usize>, new_stats: HashMap<&String, us
220220
let same_in_both_hashmaps = old_stats
221221
.iter()
222222
.filter(|(old_key, old_val)| new_stats.get::<&String>(old_key) == Some(old_val))
223-
.map(|(k, v)| (k.to_string(), *v))
223+
.map(|(k, v)| (k.clone(), *v))
224224
.collect::<Vec<(String, usize)>>();
225225

226226
let mut old_stats_deduped = old_stats;

0 commit comments

Comments
 (0)