clippy::useless_format

This commit is contained in:
Matthias Krüger 2021-07-21 22:43:19 +02:00
parent d0a8a12dc6
commit 3fd8cbb404
14 changed files with 17 additions and 17 deletions

View file

@ -906,7 +906,7 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> {
} else { } else {
return FfiUnsafe { return FfiUnsafe {
ty, ty,
reason: format!("box cannot be represented as a single pointer"), reason: "box cannot be represented as a single pointer".to_string(),
help: None, help: None,
}; };
} }

View file

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

View file

@ -320,7 +320,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
.map(|n| format!("`{}`", n)) .map(|n| format!("`{}`", n))
.unwrap_or_else(|| "the mutable reference".to_string()), .unwrap_or_else(|| "the mutable reference".to_string()),
), ),
format!("&mut *"), "&mut *".to_string(),
Applicability::MachineApplicable, Applicability::MachineApplicable,
); );
} }

View file

@ -721,7 +721,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
if suggestions.peek().is_some() { if suggestions.peek().is_some() {
err.span_suggestions( err.span_suggestions(
path_segment.ident.span, path_segment.ident.span,
&format!("use mutable method"), "use mutable method",
suggestions, suggestions,
Applicability::MaybeIncorrect, Applicability::MaybeIncorrect,
); );

View file

@ -255,7 +255,7 @@ impl NonConstOp for CellBorrow {
); );
err.span_label( err.span_label(
span, span,
format!("this borrow of an interior mutable value may end up in the final value"), "this borrow of an interior mutable value may end up in the final value",
); );
if let hir::ConstContext::Static(_) = ccx.const_kind() { if let hir::ConstContext::Static(_) = ccx.const_kind() {
err.help( err.help(

View file

@ -344,7 +344,7 @@ impl DebugCounters {
return if counter_format.id { return if counter_format.id {
format!("{}#{}", block_label, id.index()) format!("{}#{}", block_label, id.index())
} else { } else {
format!("{}", block_label) block_label.to_string()
}; };
} }
} }
@ -369,7 +369,7 @@ impl DebugCounters {
} }
return format!("({})", self.format_counter_kind(counter_kind)); return format!("({})", self.format_counter_kind(counter_kind));
} }
return format!("{}", self.format_counter_kind(counter_kind)); return self.format_counter_kind(counter_kind).to_string();
} }
} }
format!("#{}", operand.index().to_string()) format!("#{}", operand.index().to_string())

View file

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

View file

@ -479,7 +479,7 @@ impl Visitor<'tcx> for ExtraComments<'tcx> {
uv.promoted uv.promoted
), ),
ty::ConstKind::Value(val) => format!("Value({:?})", val), ty::ConstKind::Value(val) => format!("Value({:?})", val),
ty::ConstKind::Error(_) => format!("Error"), ty::ConstKind::Error(_) => "Error".to_string(),
}; };
self.push(&format!("+ val: {}", val)); self.push(&format!("+ val: {}", val));
} }

View file

@ -855,7 +855,7 @@ impl CheckAttrVisitor<'tcx> {
hir_id, hir_id,
meta.span(), meta.span(),
|lint| { |lint| {
lint.build(&format!("invalid `doc` attribute")).emit(); lint.build(&"invalid `doc` attribute").emit();
}, },
); );
is_valid = false; is_valid = false;

View file

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

View file

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

View file

@ -1061,7 +1061,7 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> {
} }
err.span_suggestion( err.span_suggestion(
span, span,
&format!("use this syntax instead"), &"use this syntax instead",
format!("{path_str}"), format!("{path_str}"),
Applicability::MaybeIncorrect, Applicability::MaybeIncorrect,
); );

View file

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

View file

@ -342,7 +342,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
if let Ok(expr_text) = self.sess().source_map().span_to_snippet(expr.span) { if let Ok(expr_text) = self.sess().source_map().span_to_snippet(expr.span) {
(expr_text, true) (expr_text, true)
} else { } else {
(format!("(..)"), false) ("(..)".to_string(), false)
}; };
let adjusted_text = if let Some(probe::AutorefOrPtrAdjustment::ToConstPtr) = let adjusted_text = if let Some(probe::AutorefOrPtrAdjustment::ToConstPtr) =