Skip to content

Commit ebe3563

Browse files
authored
Rollup merge of #105873 - matthiaskrgr:clippy_fmt, r=Nilstrieb
use &str / String literals instead of format!()
2 parents 221e71e + 3af7df9 commit ebe3563

File tree

19 files changed

+37
-55
lines changed

19 files changed

+37
-55
lines changed

compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -649,7 +649,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
649649
if !assign_value.is_empty() {
650650
err.span_suggestion_verbose(
651651
sugg_span.shrink_to_hi(),
652-
format!("consider assigning a value"),
652+
"consider assigning a value",
653653
format!(" = {}", assign_value),
654654
Applicability::MaybeIncorrect,
655655
);

compiler/rustc_borrowck/src/diagnostics/explain_borrow.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ impl<'tcx> BorrowExplanation<'tcx> {
270270
for extra in extra_info {
271271
match extra {
272272
ExtraConstraintInfo::PlaceholderFromPredicate(span) => {
273-
err.span_note(*span, format!("due to current limitations in the borrow checker, this implies a `'static` lifetime"));
273+
err.span_note(*span, "due to current limitations in the borrow checker, this implies a `'static` lifetime");
274274
}
275275
}
276276
}

compiler/rustc_borrowck/src/diagnostics/region_errors.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
472472
for extra in extra_info {
473473
match extra {
474474
ExtraConstraintInfo::PlaceholderFromPredicate(span) => {
475-
diag.span_note(span, format!("due to current limitations in the borrow checker, this implies a `'static` lifetime"));
475+
diag.span_note(span, "due to current limitations in the borrow checker, this implies a `'static` lifetime");
476476
}
477477
}
478478
}

compiler/rustc_codegen_llvm/src/asm.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ impl<'ll, 'tcx> AsmBuilderMethods<'tcx> for Builder<'_, 'll, 'tcx> {
144144
// We prefer the latter because it matches the behavior of
145145
// Clang.
146146
if late && matches!(reg, InlineAsmRegOrRegClass::Reg(_)) {
147-
constraints.push(format!("{}", reg_to_llvm(reg, Some(&in_value.layout))));
147+
constraints.push(reg_to_llvm(reg, Some(&in_value.layout)).to_string());
148148
} else {
149149
constraints.push(format!("{}", op_idx[&idx]));
150150
}

compiler/rustc_hir_analysis/src/astconv/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2240,7 +2240,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
22402240
),
22412241
"s",
22422242
),
2243-
[only] => (format!("{only}"), ""),
2243+
[only] => (only.to_string(), ""),
22442244
[] => unreachable!(),
22452245
};
22462246
let last_span = *arg_spans.last().unwrap();

compiler/rustc_hir_typeck/src/demand.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
406406
}
407407

408408
let note_about_variant_field_privacy = (field_is_local && !field_is_accessible)
409-
.then(|| format!(" (its field is private, but it's local to this crate and its privacy can be changed)"));
409+
.then(|| " (its field is private, but it's local to this crate and its privacy can be changed)".to_string());
410410

411411
let sole_field_ty = sole_field.ty(self.tcx, substs);
412412
if self.can_coerce(expr_ty, sole_field_ty) {

compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1013,7 +1013,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
10131013
} else {
10141014
args_span
10151015
};
1016-
labels.push((span, format!("multiple arguments are missing")));
1016+
labels.push((span, "multiple arguments are missing".to_string()));
10171017
suggestion_text = match suggestion_text {
10181018
SuggestionText::None | SuggestionText::Provide(_) => {
10191019
SuggestionText::Provide(true)

compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -319,11 +319,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
319319
}
320320
}
321321

322-
err.multipart_suggestion_verbose(
323-
format!("use parentheses to call these"),
324-
sugg,
325-
applicability,
326-
);
322+
err.multipart_suggestion_verbose("use parentheses to call these", sugg, applicability);
327323

328324
true
329325
} else {

compiler/rustc_hir_typeck/src/method/suggest.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1007,7 +1007,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
10071007
if def_kind == DefKind::AssocFn && lev_candidate.fn_has_self_parameter {
10081008
err.span_suggestion(
10091009
span,
1010-
&format!("there is a method with a similar name",),
1010+
"there is a method with a similar name",
10111011
lev_candidate.name,
10121012
Applicability::MaybeIncorrect,
10131013
);

compiler/rustc_infer/src/infer/error_reporting/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ fn msg_span_from_early_bound_and_free_regions<'tcx>(
184184
let text = if br.has_name() {
185185
format!("the lifetime `{}` as defined here", br.name)
186186
} else {
187-
format!("the anonymous lifetime as defined here")
187+
"the anonymous lifetime as defined here".to_string()
188188
};
189189
(text, sp)
190190
}
@@ -203,7 +203,7 @@ fn msg_span_from_early_bound_and_free_regions<'tcx>(
203203
sp = param.span;
204204
}
205205
let text = if name == kw::UnderscoreLifetime {
206-
format!("the anonymous lifetime as defined here")
206+
"the anonymous lifetime as defined here".to_string()
207207
} else {
208208
format!("the lifetime `{}` as defined here", name)
209209
};

0 commit comments

Comments
 (0)