Skip to content

Commit 5800532

Browse files
apply useless_borrows_in_formatting fixes (#16872)
minor code cleanup getting ready for the `useless_borrows_in_formatting` lint See #16523 r? @samueltardieu --- changelog: none
2 parents 2e1628a + 8dcf8e6 commit 5800532

File tree

8 files changed

+10
-15
lines changed

8 files changed

+10
-15
lines changed

clippy_dev/src/new_lint.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,7 @@ fn setup_mod_file(path: &Path, lint: &LintData<'_>) -> io::Result<&'static str>
502502
file_contents.replace_range(arr_start + 1..arr_end, &new_arr_content);
503503

504504
// Just add the mod declaration at the top, it'll be fixed by rustfmt
505-
file_contents.insert_str(0, &format!("mod {};\n", &lint.name));
505+
file_contents.insert_str(0, &format!("mod {};\n", lint.name));
506506

507507
let mut file = OpenOptions::new()
508508
.write(true)

clippy_lints/src/booleans.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ impl SuggestContext<'_, '_, '_> {
360360
if app != Applicability::MachineApplicable {
361361
return None;
362362
}
363-
let _cannot_fail = write!(&mut self.output, "{}", &(!snip));
363+
let _cannot_fail = write!(&mut self.output, "{}", !snip);
364364
}
365365
},
366366
True | False | Not(_) => {

clippy_lints/src/methods/wrong_self_convention.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ pub(super) fn check<'tcx>(
121121

122122
format!("methods with the following characteristics: ({s})")
123123
} else {
124-
format!("methods called {}", &conventions[0])
124+
format!("methods called {}", conventions[0])
125125
}
126126
};
127127

clippy_lints/src/operators/manual_div_ceil.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -177,11 +177,7 @@ fn build_suggestion(
177177
// suggestion message, we want to make a suggestion string before `div_ceil` like
178178
// `(-2048_{type_suffix})`.
179179
let suggestion_before_div_ceil = if has_enclosing_paren(&dividend_sugg_str) {
180-
format!(
181-
"{}{})",
182-
&dividend_sugg_str[..dividend_sugg_str.len() - 1].to_string(),
183-
type_suffix
184-
)
180+
format!("{}{type_suffix})", &dividend_sugg_str[..dividend_sugg_str.len() - 1])
185181
} else {
186182
format!("{dividend_sugg_str}{type_suffix}")
187183
};

clippy_lints/src/ref_option_ref.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ impl<'tcx> LateLintPass<'tcx> for RefOptionRef {
5858
ty.span,
5959
"since `&` implements the `Copy` trait, `&Option<&T>` can be simplified to `Option<&T>`",
6060
"try",
61-
format!("Option<{}>", &snippet(cx, inner_ty.span, "..")),
61+
format!("Option<{}>", snippet(cx, inner_ty.span, "..")),
6262
Applicability::MaybeIncorrect,
6363
);
6464
}

clippy_lints/src/unit_types/unit_arg.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,9 +231,8 @@ fn fmt_stmts_and_call(
231231
let block_indent = call_expr_indent + 4;
232232
stmts_and_call_snippet = reindent_multiline(&stmts_and_call_snippet, true, Some(block_indent));
233233
stmts_and_call_snippet = format!(
234-
"{{\n{}{}\n{}}}",
234+
"{{\n{}{stmts_and_call_snippet}\n{}}}",
235235
" ".repeat(block_indent),
236-
&stmts_and_call_snippet,
237236
" ".repeat(call_expr_indent)
238237
);
239238
}

clippy_lints_internal/src/collapsible_span_lint_calls.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,8 +232,8 @@ fn suggest_help(
232232
"this call is collapsible",
233233
"collapse into",
234234
format!(
235-
"span_lint_and_help({}, {}, {}, {}, {}, {help})",
236-
and_then_snippets.cx, and_then_snippets.lint, and_then_snippets.span, and_then_snippets.msg, &option_span,
235+
"span_lint_and_help({}, {}, {}, {}, {option_span}, {help})",
236+
and_then_snippets.cx, and_then_snippets.lint, and_then_snippets.span, and_then_snippets.msg
237237
),
238238
app,
239239
);

lintcheck/src/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,12 +85,12 @@ impl Crate {
8585
if config.max_jobs == 1 {
8686
println!(
8787
"{index}/{total_crates_to_lint} {perc}% Linting {} {}",
88-
&self.name, &self.version
88+
self.name, self.version
8989
);
9090
} else {
9191
println!(
9292
"{index}/{total_crates_to_lint} {perc}% Linting {} {} in target dir {thread_index:?}",
93-
&self.name, &self.version
93+
self.name, self.version
9494
);
9595
}
9696

0 commit comments

Comments
 (0)