Skip to content

Commit 3fd8cbb

Browse files
committed
clippy::useless_format
1 parent d0a8a12 commit 3fd8cbb

File tree

14 files changed

+17
-17
lines changed

14 files changed

+17
-17
lines changed

compiler/rustc_lint/src/types.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -906,7 +906,7 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> {
906906
} else {
907907
return FfiUnsafe {
908908
ty,
909-
reason: format!("box cannot be represented as a single pointer"),
909+
reason: "box cannot be represented as a single pointer".to_string(),
910910
help: None,
911911
};
912912
}

compiler/rustc_macros/src/symbols.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ fn symbols_with_errors(input: TokenStream) -> (TokenStream, Vec<syn::Error>) {
135135
let mut check_dup = |span: Span, str: &str, errors: &mut Errors| {
136136
if let Some(prev_span) = keys.get(str) {
137137
errors.error(span, format!("Symbol `{}` is duplicated", str));
138-
errors.error(*prev_span, format!("location of previous definition"));
138+
errors.error(*prev_span, "location of previous definition".to_string());
139139
} else {
140140
keys.insert(str.to_string(), span);
141141
}

compiler/rustc_mir/src/borrow_check/diagnostics/conflict_errors.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
320320
.map(|n| format!("`{}`", n))
321321
.unwrap_or_else(|| "the mutable reference".to_string()),
322322
),
323-
format!("&mut *"),
323+
"&mut *".to_string(),
324324
Applicability::MachineApplicable,
325325
);
326326
}

compiler/rustc_mir/src/borrow_check/diagnostics/mutability_errors.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -721,7 +721,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
721721
if suggestions.peek().is_some() {
722722
err.span_suggestions(
723723
path_segment.ident.span,
724-
&format!("use mutable method"),
724+
"use mutable method",
725725
suggestions,
726726
Applicability::MaybeIncorrect,
727727
);

compiler/rustc_mir/src/transform/check_consts/ops.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ impl NonConstOp for CellBorrow {
255255
);
256256
err.span_label(
257257
span,
258-
format!("this borrow of an interior mutable value may end up in the final value"),
258+
"this borrow of an interior mutable value may end up in the final value",
259259
);
260260
if let hir::ConstContext::Static(_) = ccx.const_kind() {
261261
err.help(

compiler/rustc_mir/src/transform/coverage/debug.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ impl DebugCounters {
344344
return if counter_format.id {
345345
format!("{}#{}", block_label, id.index())
346346
} else {
347-
format!("{}", block_label)
347+
block_label.to_string()
348348
};
349349
}
350350
}
@@ -369,7 +369,7 @@ impl DebugCounters {
369369
}
370370
return format!("({})", self.format_counter_kind(counter_kind));
371371
}
372-
return format!("{}", self.format_counter_kind(counter_kind));
372+
return self.format_counter_kind(counter_kind).to_string();
373373
}
374374
}
375375
format!("#{}", operand.index().to_string())

compiler/rustc_mir/src/transform/lower_intrinsics.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,8 @@ fn validate_simd_shuffle(tcx: TyCtxt<'tcx>, args: &[Operand<'tcx>], span: Span)
147147
match &args[2] {
148148
Operand::Constant(_) => {} // all good
149149
_ => {
150-
let msg = format!("last argument of `simd_shuffle` is required to be a `const` item");
151-
tcx.sess.span_err(span, &msg);
150+
let msg = "last argument of `simd_shuffle` is required to be a `const` item";
151+
tcx.sess.span_err(span, msg);
152152
}
153153
}
154154
}

compiler/rustc_mir/src/util/pretty.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,7 @@ impl Visitor<'tcx> for ExtraComments<'tcx> {
479479
uv.promoted
480480
),
481481
ty::ConstKind::Value(val) => format!("Value({:?})", val),
482-
ty::ConstKind::Error(_) => format!("Error"),
482+
ty::ConstKind::Error(_) => "Error".to_string(),
483483
};
484484
self.push(&format!("+ val: {}", val));
485485
}

compiler/rustc_passes/src/check_attr.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -855,7 +855,7 @@ impl CheckAttrVisitor<'tcx> {
855855
hir_id,
856856
meta.span(),
857857
|lint| {
858-
lint.build(&format!("invalid `doc` attribute")).emit();
858+
lint.build(&"invalid `doc` attribute").emit();
859859
},
860860
);
861861
is_valid = false;

compiler/rustc_passes/src/entry.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ fn no_main_err(tcx: TyCtxt<'_>, visitor: &EntryContext<'_, '_>) {
229229
if let Some(main_def) = tcx.resolutions(()).main_def {
230230
if main_def.opt_fn_def_id().is_none() {
231231
// There is something at `crate::main`, but it is not a function definition.
232-
err.span_label(main_def.span, &format!("non-function item at `crate::main` is found"));
232+
err.span_label(main_def.span, "non-function item at `crate::main` is found");
233233
}
234234
}
235235

compiler/rustc_query_system/src/query/plumbing.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -618,8 +618,8 @@ fn incremental_verify_ich<CTX, K, V: Debug>(
618618
};
619619
tcx.sess().struct_err(&format!("internal compiler error: encountered incremental compilation error with {:?}", dep_node))
620620
.help(&format!("This is a known issue with the compiler. Run {} to allow your project to compile", run_cmd))
621-
.note(&format!("Please follow the instructions below to create a bug report with the provided information"))
622-
.note(&format!("See <https://github.com/rust-lang/rust/issues/84970> for more information"))
621+
.note(&"Please follow the instructions below to create a bug report with the provided information")
622+
.note(&"See <https://github.com/rust-lang/rust/issues/84970> for more information")
623623
.emit();
624624
panic!("Found unstable fingerprints for {:?}: {:?}", dep_node, result);
625625
}

compiler/rustc_resolve/src/late/diagnostics.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1061,7 +1061,7 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> {
10611061
}
10621062
err.span_suggestion(
10631063
span,
1064-
&format!("use this syntax instead"),
1064+
&"use this syntax instead",
10651065
format!("{path_str}"),
10661066
Applicability::MaybeIncorrect,
10671067
);

compiler/rustc_target/src/spec/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2018,7 +2018,7 @@ impl Target {
20182018

20192019
if base.is_builtin {
20202020
// This can cause unfortunate ICEs later down the line.
2021-
return Err(format!("may not set is_builtin for targets not built-in"));
2021+
return Err("may not set is_builtin for targets not built-in".to_string());
20222022
}
20232023
// Each field should have been read using `Json::remove_key` so any keys remaining are unused.
20242024
let remaining_keys = obj.as_object().ok_or("Expected JSON object for target")?.keys();

compiler/rustc_typeck/src/check/method/prelude2021.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
342342
if let Ok(expr_text) = self.sess().source_map().span_to_snippet(expr.span) {
343343
(expr_text, true)
344344
} else {
345-
(format!("(..)"), false)
345+
("(..)".to_string(), false)
346346
};
347347

348348
let adjusted_text = if let Some(probe::AutorefOrPtrAdjustment::ToConstPtr) =

0 commit comments

Comments
 (0)